diff --git a/test/compiler/fragments/test_all.rb b/test/compiler/fragments/test_all.rb index f0e8d4f1..569ca4d3 100644 --- a/test/compiler/fragments/test_all.rb +++ b/test/compiler/fragments/test_all.rb @@ -1,9 +1,10 @@ require_relative "test_if" -#require_relative "test_foo" -#require_relative "test_hello" require_relative "test_class" -#require_relative "test_putint" -#require_relative "test_functions" -#require_relative "test_recursive_fibo" +require_relative "test_foo" +require_relative "test_functions" +require_relative "test_hello" +require_relative "test_if" +require_relative "test_putint" +require_relative "test_recursive_fibo" #require_relative "test_while_fibo" diff --git a/test/compiler/fragments/test_foo.rb b/test/compiler/fragments/test_foo.rb index a8a088dc..89bcd3b1 100644 --- a/test/compiler/fragments/test_foo.rb +++ b/test/compiler/fragments/test_foo.rb @@ -16,8 +16,7 @@ class Object end end HERE - @expect = [ [SaveReturn,Register::GetSlot,Register::Set,Register::Set, - Register::Set,Register::Set,RegisterTransfer,FunctionCall] ,[RegisterTransfer,GetSlot,FunctionReturn] ] + @length = 36 check end diff --git a/test/compiler/fragments/test_functions.rb b/test/compiler/fragments/test_functions.rb index d2cc1f81..4c91b8dc 100644 --- a/test/compiler/fragments/test_functions.rb +++ b/test/compiler/fragments/test_functions.rb @@ -7,36 +7,28 @@ class TestFunctions < MiniTest::Test @string_input = < 1 ) - int tmp = a - a = b - b = tmp + b - n = n - 1 - end - b.putint() - return b + int a = 0 + int b = 1 + while_plus( n ) + int tmp = a + a = b + b = tmp + b + n = n - 1 + end + b.putint() + return b end int main() @@ -24,25 +24,8 @@ class Object end end HERE - @expect = [ [SaveReturn,Register::GetSlot,Register::Set,Register::Set, - Register::Set,Register::Set,RegisterTransfer,FunctionCall] ,[RegisterTransfer,GetSlot,FunctionReturn] ] + @length = 5 check end - # a hand coded version of the fibonachi numbers (moved to kernel to be able to call it) - # not my hand off course, found in the net from a basic introduction - def ttest_kernel_fibo - int = Register::Integer.new(Register::RegisterMachine.instance.receiver_register) - fibo = @object_space.get_class_by_name(:Object).resolve_method(:fibo) - main = @object_space.main - main.mov int , 10 - main.call( fibo ) - main.mov( Register::RegisterMachine.instance.receiver_register , Register::RegisterMachine.instance.return_register ) - putint = @object_space.get_class_by_name(:Object).resolve_method(:putint) - main.call( putint ) - @should = [0x0,0x40,0x2d,0xe9,0x1,0x0,0x52,0xe3,0x2,0x0,0xa0,0xd1,0x7,0x0,0x0,0xda,0x1,0x30,0xa0,0xe3,0x0,0x40,0xa0,0xe3,0x4,0x30,0x83,0xe0,0x4,0x40,0x43,0xe0,0x1,0x20,0x42,0xe2,0x1,0x0,0x52,0xe3,0xfa,0xff,0xff,0x1a,0x3,0x0,0xa0,0xe1,0x0,0x80,0xbd,0xe8] - @target = [:Object , :fibo] - write "fibo" - end - end diff --git a/test/compiler/statements/test_class.rb b/test/compiler/statements/test_class.rb index d977b359..e8aab309 100644 --- a/test/compiler/statements/test_class.rb +++ b/test/compiler/statements/test_class.rb @@ -1,7 +1,7 @@ require_relative 'helper' module Register -class TestBasicClass < MiniTest::Test +class TestClassStatements < MiniTest::Test include Statements def test_class_def @@ -34,7 +34,6 @@ class Object end end HERE - @length = 30 @expect = [Label, SaveReturn,GetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot, RegisterTransfer,FunctionCall,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] check @@ -62,7 +61,6 @@ class Object end end HERE - @length = 17 @expect = [Label, SaveReturn,GetSlot,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] check end