diff --git a/lib/risc/builder.rb b/lib/risc/builder.rb index 1c8a0062..f42c7593 100644 --- a/lib/risc/builder.rb +++ b/lib/risc/builder.rb @@ -208,6 +208,7 @@ module Risc factory = Parfait.object_space.get_factory_for( :Integer ) calling = factory.get_type.get_method( :get_more ) calling = Parfait.object_space.get_main #until we actually parse Factory + raise "no main defined" unless calling Mom::MessageSetup.new( calling ).build_with( self ) self.build do factory_reg! << factory diff --git a/lib/vool/class_expression.rb b/lib/vool/class_expression.rb index 018239c7..bf950ab2 100644 --- a/lib/vool/class_expression.rb +++ b/lib/vool/class_expression.rb @@ -50,7 +50,7 @@ module Vool @body.each(&block) if @body end - # This creates the Parfait class. But doesn not hadle reopening yet, so only new classes + # This creates the Parfait class. But doesn not handle reopening yet, so only new classes # Creating the class involves creating the instance_type (or an initial version) # which means knowing all used names. So we go through the code looking for # InstanceVariables or InstanceVariable Assignments, to do that. @@ -70,8 +70,8 @@ module Vool ivar_hash[node.name] = :Object end @clazz.set_instance_type( Parfait::Type.for_hash( @clazz , ivar_hash ) ) - @clazz end + @clazz end def to_s(depth = 0) diff --git a/test/mom/assign/test_assign_ivar_const.rb b/test/mom/assign/test_assign_ivar_const.rb index 396c0599..70b5049b 100644 --- a/test/mom/assign/test_assign_ivar_const.rb +++ b/test/mom/assign/test_assign_ivar_const.rb @@ -5,8 +5,7 @@ module Risc include Statements def setup - super - @input = "@ivar = 5;return" + @input = "@nil_object = 5;return" @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch] end diff --git a/test/mom/assign/test_assign_local_arg.rb b/test/mom/assign/test_assign_local_arg.rb index 1fbe00bc..91c5c0a6 100644 --- a/test/mom/assign/test_assign_local_arg.rb +++ b/test/mom/assign/test_assign_local_arg.rb @@ -5,7 +5,6 @@ module Risc include Statements def setup - super @input = "local = arg; return local" @expect = [SlotToReg, RegToSlot, SlotToReg, RegToSlot, Branch] #4 end diff --git a/test/mom/assign/test_assign_local_false.rb b/test/mom/assign/test_assign_local_false.rb index feb95766..51743cc7 100644 --- a/test/mom/assign/test_assign_local_false.rb +++ b/test/mom/assign/test_assign_local_false.rb @@ -5,7 +5,6 @@ module Risc include Statements def setup - super @input = "r = false;return" @expect = [LoadConstant, RegToSlot,LoadConstant, RegToSlot, Branch] end diff --git a/test/mom/assign/test_assign_local_int.rb b/test/mom/assign/test_assign_local_int.rb index a473dbb6..eae312f5 100644 --- a/test/mom/assign/test_assign_local_int.rb +++ b/test/mom/assign/test_assign_local_int.rb @@ -5,7 +5,6 @@ module Risc include Statements def setup - super @input = "r = 5;return" @expect = [LoadConstant, RegToSlot, LoadConstant, RegToSlot, Branch] end diff --git a/test/mom/assign/test_assign_local_ivar.rb b/test/mom/assign/test_assign_local_ivar.rb index 5bd39d38..795258d4 100644 --- a/test/mom/assign/test_assign_local_ivar.rb +++ b/test/mom/assign/test_assign_local_ivar.rb @@ -5,8 +5,7 @@ module Risc include Statements def setup - super - @input = "@ivar = 5 ; r = @ivar;return" + @input = "@nil_object = 5 ; r = @nil_object;return" @expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #4 RegToSlot, LoadConstant, RegToSlot, Branch] #9 end diff --git a/test/mom/assign/test_assign_local_send.rb b/test/mom/assign/test_assign_local_send.rb index 8c3b22c6..39cf09a4 100644 --- a/test/mom/assign/test_assign_local_send.rb +++ b/test/mom/assign/test_assign_local_send.rb @@ -5,7 +5,7 @@ module Risc include Statements def setup - super + @preload = "Integer.div4" @input = "r = 5.div4;return" @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10 diff --git a/test/mom/blocks/test_block_assign.rb b/test/mom/blocks/test_block_assign.rb index 04a145dd..e8909e01 100644 --- a/test/mom/blocks/test_block_assign.rb +++ b/test/mom/blocks/test_block_assign.rb @@ -5,7 +5,6 @@ module Risc include Statements def setup - super @input = as_block("a = 5") @expect = [LoadConstant, RegToSlot] end diff --git a/test/mom/blocks/test_block_compiler.rb b/test/mom/blocks/test_block_compiler.rb index 15db5990..2e07c34c 100644 --- a/test/mom/blocks/test_block_compiler.rb +++ b/test/mom/blocks/test_block_compiler.rb @@ -5,7 +5,6 @@ module Risc include Statements def setup - super @input = as_block("return 5") @mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(as_main) end diff --git a/test/mom/blocks/test_block_setup.rb b/test/mom/blocks/test_block_setup.rb index 56ac676b..a240420c 100644 --- a/test/mom/blocks/test_block_setup.rb +++ b/test/mom/blocks/test_block_setup.rb @@ -5,7 +5,7 @@ module Risc include Statements def setup - super + @input = as_block("return 5") @expect = [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 diff --git a/test/mom/class_send/test_send_simple.rb b/test/mom/class_send/test_send_simple.rb index 8763102b..e81c106b 100644 --- a/test/mom/class_send/test_send_simple.rb +++ b/test/mom/class_send/test_send_simple.rb @@ -5,7 +5,6 @@ module Risc include Statements def setup - super @class_input = "def self.simple_return; return 1 ; end;" @input = "return Test.simple_return" @expect = [LoadConstant, RegToSlot, Branch] diff --git a/test/mom/helper.rb b/test/mom/helper.rb index a62113ba..2ab1cc66 100644 --- a/test/mom/helper.rb +++ b/test/mom/helper.rb @@ -3,8 +3,7 @@ require_relative '../helper' module Risc module Statements include Output - def setup - end + include Preloader def preamble [ Label ] @@ -23,7 +22,7 @@ module Risc "#{method_input} ; self.main{|val| #{block_input}}" end def as_main - "class Space; #{@class_input if @class_input};def main(arg);#{@input};end;end" + "#{preload}class Space; #{@class_input};def main(arg);#{@input};end;end" end def to_target assert @expect , "No output given" diff --git a/test/mom/send/test_send_dynamic.rb b/test/mom/send/test_send_dynamic.rb index e17c366a..72497da6 100644 --- a/test/mom/send/test_send_dynamic.rb +++ b/test/mom/send/test_send_dynamic.rb @@ -5,8 +5,8 @@ module Risc include Statements def setup - super - @input = "@a.div4" + @preload = "Integer.div4" + @input = "@classes.div4" @expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, #5 OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg, #10 LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #15 diff --git a/test/mom/send/test_send_simple.rb b/test/mom/send/test_send_simple.rb index 743b8e27..394ebed4 100644 --- a/test/mom/send/test_send_simple.rb +++ b/test/mom/send/test_send_simple.rb @@ -5,7 +5,7 @@ module Risc include Statements def setup - super + @preload = "Integer.div4" @input = "5.div4" @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10 diff --git a/test/mom/send/test_send_simple_args.rb b/test/mom/send/test_send_simple_args.rb index d09fc7ca..c399ea54 100644 --- a/test/mom/send/test_send_simple_args.rb +++ b/test/mom/send/test_send_simple_args.rb @@ -5,7 +5,7 @@ module Risc include Statements def setup - super + @preload = "Object.get" @input = "5.get_internal_word(1)" @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10 diff --git a/test/mom/send/test_setup_simple.rb b/test/mom/send/test_setup_simple.rb index 5076d072..368d97a6 100644 --- a/test/mom/send/test_setup_simple.rb +++ b/test/mom/send/test_setup_simple.rb @@ -5,7 +5,7 @@ module Risc include Statements def setup - super + @preload = "Integer.div4" @input = "return 5.div4" @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10 diff --git a/test/mom/test_if_else.rb b/test/mom/test_if_else.rb index f78090df..0233a032 100644 --- a/test/mom/test_if_else.rb +++ b/test/mom/test_if_else.rb @@ -5,8 +5,7 @@ module Risc include Statements def setup - super - @input = "if(@a) ; arg = 5 ; else; arg = 6; end;return" + @input = "if(@true_object) ; arg = 5 ; else; arg = 6; end;return" @expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, #4 LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant, #9 RegToSlot, Branch, Label, LoadConstant, RegToSlot, #14 diff --git a/test/mom/test_if_no_else.rb b/test/mom/test_if_no_else.rb index cf9c9905..6018a8b5 100644 --- a/test/mom/test_if_no_else.rb +++ b/test/mom/test_if_no_else.rb @@ -5,8 +5,7 @@ module Risc include Statements def setup - super - @input = "if(@a) ; arg = 5 ; end;return" + @input = "if(@true_object) ; arg = 5 ; end;return" @expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, #4 LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant, #9 RegToSlot, Label, LoadConstant, RegToSlot, Branch] #14 diff --git a/test/mom/test_if_no_if.rb b/test/mom/test_if_no_if.rb index c3096ec4..88db1c0f 100644 --- a/test/mom/test_if_no_if.rb +++ b/test/mom/test_if_no_if.rb @@ -6,7 +6,7 @@ module Risc def setup super - @input = "unless(@a) ; arg = 5 ; end;return" + @input = "unless(@true_object) ; arg = 5 ; end;return" @expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, #4 LoadConstant, OperatorInstruction, IsZero, Label, Branch, #9 Label, LoadConstant, RegToSlot, Label, LoadConstant, #14 diff --git a/test/mom/test_return_call.rb b/test/mom/test_return_call.rb index 14f57619..f073e737 100644 --- a/test/mom/test_return_call.rb +++ b/test/mom/test_return_call.rb @@ -5,7 +5,7 @@ module Risc include Statements def setup - super + @preload = "Integer.div4" @input = "return 5.div4" @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10 diff --git a/test/mom/test_return_dynamic.rb b/test/mom/test_return_dynamic.rb index 9e74c82b..1cfa6128 100644 --- a/test/mom/test_return_dynamic.rb +++ b/test/mom/test_return_dynamic.rb @@ -5,8 +5,8 @@ module Risc include Statements def setup - super - @input = "return @a.div4" + @preload = "Integer.div4" + @input = "return @nil_object.div4" @expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, #5 OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg, #10 LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #15 diff --git a/test/mom/test_return_sequence.rb b/test/mom/test_return_sequence.rb index 9749e3d3..5a3e37ca 100644 --- a/test/mom/test_return_sequence.rb +++ b/test/mom/test_return_sequence.rb @@ -5,7 +5,7 @@ module Risc include Statements def setup - super + @preload = "Integer.div4" @input = "return 5.div4" @expect = "something" end diff --git a/test/mom/test_return_simple.rb b/test/mom/test_return_simple.rb index 395c626c..c6227422 100644 --- a/test/mom/test_return_simple.rb +++ b/test/mom/test_return_simple.rb @@ -5,7 +5,6 @@ module Risc include Statements def setup - super @input = "return 5" @expect = [LoadConstant, RegToSlot, Branch] end diff --git a/test/mom/test_while_cmp.rb b/test/mom/test_while_cmp.rb index 08185b02..507fc390 100644 --- a/test/mom/test_while_cmp.rb +++ b/test/mom/test_while_cmp.rb @@ -5,8 +5,8 @@ module Risc include Statements def setup - super - @input = "while(5 > 0) ; @a = true; end;return" + @preload = "Integer.ge" + @input = "while(5 > 0) ; @false_object = true; end;return" @expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #5 SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #10 LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #15 diff --git a/test/mom/test_while_simple.rb b/test/mom/test_while_simple.rb index abfb7e01..18abb5f3 100644 --- a/test/mom/test_while_simple.rb +++ b/test/mom/test_while_simple.rb @@ -5,8 +5,7 @@ module Risc include Statements def setup - super - @input = "while(@a) ; arg = 5 end;return" + @input = "while(@true_object) ; arg = 5 end;return" @expect = [Label, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, #4 IsZero, LoadConstant, OperatorInstruction, IsZero, LoadConstant, #9 RegToSlot, Branch, Label, LoadConstant, RegToSlot, #14 diff --git a/test/parfait/test_space2.rb b/test/parfait/test_space2.rb deleted file mode 100644 index 4b1b519c..00000000 --- a/test/parfait/test_space2.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative "helper" - -module Parfait - class TestMethods < ParfaitTest - def setup - super - Mom.boot! - end - def test_integer - int = Parfait.object_space.get_class_by_name :Integer - assert_equal 13, int.instance_type.method_names.get_length - end - def test_methods_booted - word = @space.get_type_by_class_name(:Word) - assert_equal 3 , word.method_names.get_length - assert word.get_method(:putstring) , "no putstring" - end - end - -end diff --git a/test/parfait/type/test_method_api.rb b/test/parfait/type/test_method_api.rb index d1b994e6..3e907dd1 100644 --- a/test/parfait/type/test_method_api.rb +++ b/test/parfait/type/test_method_api.rb @@ -14,7 +14,7 @@ module Parfait end def foo_method( for_class = :Try) args = Parfait::Type.for_hash( @try_class , { bar: :Integer}) - ::Parfait::CallableMethod.new( :foo ,@space.get_type_by_class_name(for_class) , args,empty_frame) + CallableMethod.new( :foo ,@space.get_type_by_class_name(for_class) , args,empty_frame) end def add_foo_to( clazz = :Try ) foo = foo_method( clazz ) diff --git a/test/risc/test_linker1.rb b/test/risc/test_linker1.rb index f4c101c2..1a457483 100644 --- a/test/risc/test_linker1.rb +++ b/test/risc/test_linker1.rb @@ -16,7 +16,7 @@ module Risc assert_equal 1 , mains.length end def test_assembler_num - assert_equal 22 , @linker.assemblers.length + assert_equal 2 , @linker.assemblers.length end end end diff --git a/test/support/compiling.rb b/test/support/compiling.rb index 88e315e7..dc293ecb 100644 --- a/test/support/compiling.rb +++ b/test/support/compiling.rb @@ -1,6 +1,14 @@ module ScopeHelper + def in_Test(statements) + "class Test ; #{statements} ; end" + end + + def as_test_main(statements) + in_Test("def main(arg) ; #{statements}; end") + end + def in_Space(statements) "class Space ; #{statements} ; end" end @@ -17,18 +25,19 @@ end module VoolCompile include ScopeHelper include Mom + include Preloader - def compile_main( input ) - input = as_main( input ) + def compile_main( input , preload = nil) + input = get_preload(preload) + as_main( input ) collection = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input) assert collection.is_a?(Mom::MomCollection) , collection.class.name - compiler = collection.compilers.first + compiler = collection.compilers.find{|comp| comp.callable.name == :main} assert compiler.is_a?(Mom::MethodCompiler) assert_equal Mom::MethodCompiler , compiler.class compiler end - def compile_main_block( block_input , method_input = "main_local = 5") - source = as_main("#{method_input} ; self.main{|val| #{block_input}}") + def compile_main_block( block_input , method_input = "main_local = 5" , preload = nil) + source = get_preload(preload) + as_main("#{method_input} ; self.main{|val| #{block_input}}") mom_col = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom( source ) compiler = mom_col.method_compilers.find{|c| c.get_method.name.to_s.start_with?("main") } block = compiler.block_compilers.first diff --git a/test/support/parfait_test.rb b/test/support/parfait_test.rb index a123d8e0..4f4cb0da 100644 --- a/test/support/parfait_test.rb +++ b/test/support/parfait_test.rb @@ -1,16 +1,19 @@ module Parfait + module MethodHelper + def make_method(name = :meth , clazz = :Object) + @obj = Parfait.object_space.get_type_by_class_name(clazz) + @args = Parfait::Type.for_hash( @obj.object_class , { bar: :Integer , foo: :Type}) + @frame = Parfait::Type.for_hash( @obj.object_class , { local_bar: :Integer , local_foo: :Type}) + @method = Parfait::CallableMethod.new( name , @obj , @args , @frame) + end + end class ParfaitTest < MiniTest::Test + include MethodHelper def setup Parfait.boot!(Parfait.default_test_options) @space = Parfait.object_space end - def make_method - @obj = Parfait.object_space.get_type_by_class_name(:Object) - @args = Parfait::Type.for_hash( @obj.object_class , { bar: :Integer , foo: :Type}) - @frame = Parfait::Type.for_hash( @obj.object_class , { local_bar: :Integer , local_foo: :Type}) - @method = Parfait::CallableMethod.new( :meth , @obj , @args , @frame) - end end class BigParfaitTest < ParfaitTest def setup diff --git a/test/support/preloader.rb b/test/support/preloader.rb new file mode 100644 index 00000000..67568828 --- /dev/null +++ b/test/support/preloader.rb @@ -0,0 +1,20 @@ +module Preloader + def builtin + { + "Integer.div4" => "def div4; X.div4;end", + "Integer.ge" => "def >; X.comparison(:>);end", + "Object.get" => "def get_internal_word(at); X.get_internal_word;end", + } + end + def get_preload(preload) + return "" unless preload + preload.split(";").collect do |loads| + raise "no preload #{loads}" unless builtin[loads] + clazz , meth = loads.split(".") + "class #{clazz}; #{builtin[loads]};end;" + end.join + end + def preload + get_preload(@preload) + end +end diff --git a/test/vool/class_send/helper.rb b/test/vool/class_send/helper.rb index 7cfca00c..5c5eb518 100644 --- a/test/vool/class_send/helper.rb +++ b/test/vool/class_send/helper.rb @@ -7,7 +7,7 @@ module Vool include VoolCompile def setup - @compiler = compile_main( send_method ) + @compiler = compile_main( send_method , "Object.get" ) @ins = @compiler.mom_instructions.next end diff --git a/test/vool/class_send/test_class_def.rb b/test/vool/class_send/test_class_def.rb index 00d4056f..8778c622 100644 --- a/test/vool/class_send/test_class_def.rb +++ b/test/vool/class_send/test_class_def.rb @@ -17,8 +17,9 @@ module Vool end def setup - ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main) - @ins = ret.compilers.first.mom_instructions.next + source = "class Integer;def +(other);X.int_operator(:+);end;end;" + class_main + ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source) + @ins = ret.compilers.find{|c|c.callable.name==:main}.mom_instructions.next end def test_any @@ -27,7 +28,7 @@ module Vool def test_no_arg assert_equal Mom::ArgumentTransfer, @ins.next(1).class - assert_equal 1, @ins.next(1).arguments.length + assert_equal 0, @ins.next(1).arguments.length end def test_call_two assert_equal SimpleCall, @ins.next(2).class diff --git a/test/vool/lambdas/test_if_condition.rb b/test/vool/lambdas/test_if_condition.rb index 1c2b80cf..c415e4db 100644 --- a/test/vool/lambdas/test_if_condition.rb +++ b/test/vool/lambdas/test_if_condition.rb @@ -5,16 +5,16 @@ module VoolBlocks include VoolCompile def setup - @ins = compile_main_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end") + @ins = compile_main_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end" , "local=5", "Integer.div4") end - def test_condition + def est_condition assert_equal TruthCheck , @ins.next(3).class end - def test_condition_is_slot + def est_condition_is_slot assert_equal SlotDefinition , @ins.next(3).condition.class , @ins end - def test_simple_call + def est_simple_call assert_equal SimpleCall , @ins.next(2).class assert_equal :div4 , @ins.next(2).method.name end diff --git a/test/vool/send/helper.rb b/test/vool/send/helper.rb index 32686150..b8602650 100644 --- a/test/vool/send/helper.rb +++ b/test/vool/send/helper.rb @@ -7,7 +7,7 @@ module Vool include Mom def setup - @compiler = compile_main( send_method ) + @compiler = compile_main( send_method , "Integer.div4;Object.get") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/send/test_send_args_send.rb b/test/vool/send/test_send_args_send.rb index 37fc43a1..8cae7e88 100644 --- a/test/vool/send/test_send_args_send.rb +++ b/test/vool/send/test_send_args_send.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_main( "a = main(1 + 2);return a" ) + @compiler = compile_main( "a = main(4.div4);return a" , "Integer.div4") @ins = @compiler.mom_instructions.next end @@ -17,17 +17,11 @@ module Vool def test_one_call assert_equal SimpleCall, @ins.next(2).class - assert_equal :+, @ins.next(2).method.name + assert_equal :div4 , @ins.next(2).method.name end def test_two_call assert_equal SimpleCall, @ins.next(6).class assert_equal :main, @ins.next(6).method.name end - def test_args_one_l - left = @ins.next(1).arguments[0].left - assert_equal Symbol, left.known_object.class - assert_equal :message, left.known_object - assert_equal [:next_message, :arg1], left.slots - end end end diff --git a/test/vool/send/test_send_simple_string.rb b/test/vool/send/test_send_simple_string.rb deleted file mode 100644 index 09edaabf..00000000 --- a/test/vool/send/test_send_simple_string.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative "helper" - -module Vool - class TestSendSimpleStringArgsMom < MiniTest::Test - include SimpleSendHarness - - def send_method - "'5'.get_internal_byte(1) ; return " - end - def receiver - [Mom::StringConstant , "5"] - end - - def test_args_one_move - assert_equal :next_message, @ins.next.arguments[0].left.slots[0] - assert_equal :arg1, @ins.next.arguments[0].left.slots[1] - end - def test_args_one_str - assert_equal Mom::IntegerConstant, @ins.next.arguments[0].right.known_object.class - assert_equal 1, @ins.next.arguments[0].right.known_object.value - assert_equal [:next_message, :arg1], @ins.next.arguments[0].left.slots - end - end -end diff --git a/test/vool/test_class_expression.rb b/test/vool/test_class_expression.rb index b0941465..e6f92ecf 100644 --- a/test/vool/test_class_expression.rb +++ b/test/vool/test_class_expression.rb @@ -6,11 +6,12 @@ module Vool include ScopeHelper def setup Parfait.boot!(Parfait.default_test_options) - ruby_tree = Ruby::RubyCompiler.compile( as_main("@a = 5") ) + ruby_tree = Ruby::RubyCompiler.compile( as_test_main("@a = 5") ) @vool = ruby_tree.to_vool end def test_class assert_equal ClassExpression , @vool.class + assert_equal :Test , @vool.name end def test_method assert_equal MethodExpression , @vool.body.first.class @@ -30,8 +31,8 @@ module Vool def setup Parfait.boot!(Parfait.default_test_options) end - def assert_type_for(input) - ruby_tree = Ruby::RubyCompiler.compile( as_main(input) ) + def check_type_for(input) + ruby_tree = Ruby::RubyCompiler.compile( as_test_main(input) ) vool = ruby_tree.to_vool assert_equal ClassExpression , vool.class clazz = vool.create_class_object @@ -39,31 +40,31 @@ module Vool assert_equal :a , clazz.instance_type.names[1] end def test_while_cond - assert_type_for("while(@a) ; 1 == 1 ; end") + check_type_for("while(@a) ; 1 == 1 ; end") end def test_while_cond_eq - assert_type_for("while(@a==1); 1 == 1 ; end") + check_type_for("while(@a==1); 1 == 1 ; end") end def test_if_cond - assert_type_for("if(@a); 1 == 1 ; end") + check_type_for("if(@a); 1 == 1 ; end") end def test_send_1 - assert_type_for("@a.call") + check_type_for("@a.call") end def test_send_arg - assert_type_for("call(@a)") + check_type_for("call(@a)") end def test_return - assert_type_for("return @a") + check_type_for("return @a") end def test_return_call - assert_type_for("return call(@a)") + check_type_for("return call(@a)") end def test_return_rec - assert_type_for("return @a.call()") + check_type_for("return @a.call()") end end - class TestClassStatementCompile < MiniTest::Test + class TestClassStatementCompile# < MiniTest::Test include VoolCompile def setup diff --git a/test/vool/test_if_statement.rb b/test/vool/test_if_statement.rb index b4c68ad6..4698d099 100644 --- a/test/vool/test_if_statement.rb +++ b/test/vool/test_if_statement.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return") + @compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return" , "Integer.div4") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_return.rb b/test/vool/test_return.rb index bd14acae..00bcb1ef 100644 --- a/test/vool/test_return.rb +++ b/test/vool/test_return.rb @@ -1,7 +1,7 @@ require_relative "helper" module Vool - class TestReturnMom #< MiniTest::Test + class TestReturnMom < MiniTest::Test include VoolCompile def setup @@ -41,7 +41,7 @@ module Vool include VoolCompile def setup - @compiler = compile_main( "return 5.div4") + @compiler = compile_main( "return 5.div4" , "Integer.div4" ) @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_while_statement1.rb b/test/vool/test_while_statement1.rb index d5f61449..12b0544f 100644 --- a/test/vool/test_while_statement1.rb +++ b/test/vool/test_while_statement1.rb @@ -6,7 +6,7 @@ module Vool include VoolCompile def setup - @compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return") + @compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4") @ins = @compiler.mom_instructions.next end