diff --git a/test/elf/helper.rb b/test/elf/helper.rb index f58628e7..1fc9f765 100644 --- a/test/elf/helper.rb +++ b/test/elf/helper.rb @@ -19,8 +19,8 @@ module Elf in_space("def main(arg);#{input};end") end def check(input, file) - RubyX::RubyXCompiler.new(input).ruby_to_binary( :arm ) - writer = Elf::ObjectWriter.new(Risc.machine) + linker = RubyX::RubyXCompiler.new(input).ruby_to_binary( :arm ) + writer = Elf::ObjectWriter.new(linker) writer.save "test/#{file}.o" end diff --git a/test/parfait/type/test_type_api.rb b/test/parfait/type/test_type_api.rb index 58ad9808..4f6b457b 100644 --- a/test/parfait/type/test_type_api.rb +++ b/test/parfait/type/test_type_api.rb @@ -27,7 +27,7 @@ module Parfait assert_equal Parfait::Space , space.class type = space.get_type assert_equal Parfait::Type , type.class - assert_equal 8 , type.names.get_length + assert_equal 12 , type.names.get_length assert_equal type.object_class.class , Parfait::Class assert_equal type.object_class.name , :Space end diff --git a/test/risc/interpreter/calling/test_plus.rb b/test/risc/interpreter/calling/test_plus.rb index 39050334..a2d3c005 100644 --- a/test/risc/interpreter/calling/test_plus.rb +++ b/test/risc/interpreter/calling/test_plus.rb @@ -82,7 +82,7 @@ module Risc sl = main_ticks(base + 7) assert_equal SlotToReg , sl.class assert_equal :r3 , sl.array.symbol #load from space - assert_equal 4 , sl.index + assert_equal 5 , sl.index assert_equal :r2 , sl.register.symbol assert_equal Parfait::Integer , @interpreter.get_register(:r2).class end @@ -98,7 +98,7 @@ module Risc sl = main_ticks(base + 9) assert_equal RegToSlot , sl.class assert_equal :r3 , sl.array.symbol #store to space - assert_equal 4 , sl.index + assert_equal 5 , sl.index assert_equal :r4 , sl.register.symbol end def test_sys diff --git a/test/risc/position/test_branch_listener.rb b/test/risc/position/test_branch_listener.rb index 18effd46..776aba93 100644 --- a/test/risc/position/test_branch_listener.rb +++ b/test/risc/position/test_branch_listener.rb @@ -6,7 +6,7 @@ module Risc def setup Parfait.boot! @binary = Parfait::BinaryCode.new(1) - @bin_pos = CodeListener.init(@binary).set(0) + @bin_pos = CodeListener.init(@binary,:interpreter).set(0) @label = Label.new("HI","ho" , FakeAddress.new(2)) @branch = DummyBranch.new( "Dummy" , @label ) @branch.insert @label diff --git a/test/risc/test_interpreter.rb b/test/risc/test_interpreter.rb index 75c6a68b..80be4b81 100644 --- a/test/risc/test_interpreter.rb +++ b/test/risc/test_interpreter.rb @@ -11,6 +11,11 @@ module Risc def test_class assert_equal Risc::Interpreter , Interpreter.new(@linker).class end + def test_starts + interpreter = Interpreter.new(@linker) + @linker.position_all + assert_equal 0 , interpreter.start_program + end def test_starts_stopped assert_equal :stopped , Interpreter.new(@linker).state end @@ -27,15 +32,10 @@ module Risc @string_input = as_main("return 5") super end - def test_starts - assert_equal 0 , @interpreter.start_program - end def test_started - @interpreter.start_program assert_equal :running , @interpreter.state end def test_pos - @interpreter.start_program assert_equal 1 , @interpreter.clock end end @@ -44,7 +44,6 @@ module Risc def setup @string_input = as_main("return 5") super - @interpreter.start_program end def test_tick1 assert_equal 2 , @interpreter.tick diff --git a/test/risc/test_method_compiler.rb b/test/risc/test_method_compiler.rb index 67092604..dfbaa887 100644 --- a/test/risc/test_method_compiler.rb +++ b/test/risc/test_method_compiler.rb @@ -9,13 +9,15 @@ module Risc end def in_test_vool(str) - input = in_Test(str) - vool = RubyX::RubyXCompiler.new(input).ruby_to_vool + vool = RubyX::RubyXCompiler.new(in_Test(str)).ruby_to_vool vool.to_mom(nil) vool end - def create_method - vool = in_test_vool("def meth; @ivar = 5;end") + def in_test_mom(str) + RubyX::RubyXCompiler.new(in_Test(str)).ruby_to_mom() + end + def create_method(body = "@ivar = 5") + in_test_vool("def meth; #{body};end") test = Parfait.object_space.get_class_by_name(:Test) test.get_method(:meth) end @@ -48,42 +50,37 @@ module Risc end def test_method_statement_has_class - input = in_Test("def meth; @ivar = 5;end") - vool = RubyX::RubyXCompiler.new(input).ruby_to_vool - clazz = vool.to_mom(nil) + vool = in_test_vool("def meth; @ivar = 5;end") assert vool.body.first.clazz end def test_parfait_class_creation - input = in_Test("def meth; @ivar = 5;end") - vool = RubyX::RubyXCompiler.new(input).ruby_to_vool - clazz = vool.to_mom(nil) + vool = in_test_vool("def meth; @ivar = 5;end") assert_equal Parfait::Class , vool.body.first.clazz.class end def test_typed_method_instance_type - vool = in_test_vool("def meth; @ivar = 5; @ibar = 4;end") + in_test_vool("def meth; @ivar = 5; @ibar = 4;end") test = Parfait.object_space.get_class_by_name(:Test) method = test.instance_type.get_method(:meth) assert_equal 1, method.for_type.variable_index(:ivar) assert_equal 2, method.for_type.variable_index(:ibar) end - - def test_vool_method_has_one_local - vool = in_test_vool("def meth; local = 5 ; a = 6;end") + def test_typed_method_has_one_local + in_test_vool("def meth; local = 5 ; a = 6;end") test = Parfait.object_space.get_class_by_name(:Test) method = test.get_method(:meth) assert_equal 3 , method.frame_type.instance_length assert_equal 1 , method.frame_type.variable_index(:local) assert_equal 2 , method.frame_type.variable_index(:a) end - - def test_typed_method_has_one_local - vool = in_test_vool("def meth; local = 5 ; a = 6;end") - test = Parfait.object_space.get_class_by_name(:Test) - method = test.instance_type.get_method(:meth) - assert_equal 3 , method.frame_type.instance_length - assert_equal 1 , method.frame_type.variable_index(:local) + def test_has_constant + input = in_Test("def meth; return 'Hi';end") + mom = RubyX::RubyXCompiler.new(input).ruby_to_mom + assert_equal Mom::MomCompiler , mom.class + compiler = mom.method_compilers.last + assert_equal MethodCompiler , compiler.class + assert compiler.constants.include?("Hi") end end diff --git a/test/risc/test_padding.rb b/test/risc/test_padding.rb index 764f80d7..93dbf95c 100644 --- a/test/risc/test_padding.rb +++ b/test/risc/test_padding.rb @@ -4,7 +4,7 @@ module Risc class TestPadding < MiniTest::Test def setup - Risc.machine.boot + Parfait.boot! end def test_small