diff --git a/test/mom/blocks/test_block_compiler.rb b/test/mom/blocks/test_block_compiler.rb index 84a4d7ba..15db5990 100644 --- a/test/mom/blocks/test_block_compiler.rb +++ b/test/mom/blocks/test_block_compiler.rb @@ -7,7 +7,7 @@ module Risc def setup super @input = as_block("return 5") - @mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(as_test_main) + @mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(as_main) end def main_risc @mom.to_risc.method_compilers.find{|c| c.callable.name == :main } diff --git a/test/mom/helper.rb b/test/mom/helper.rb index 83f5b434..a62113ba 100644 --- a/test/mom/helper.rb +++ b/test/mom/helper.rb @@ -22,13 +22,13 @@ module Risc def as_block( block_input , method_input = "main_local = 5") "#{method_input} ; self.main{|val| #{block_input}}" end - def as_test_main - "class Test; #{@class_input if @class_input};def main(arg);#{@input};end;end" + def as_main + "class Space; #{@class_input if @class_input};def main(arg);#{@input};end;end" end def to_target assert @expect , "No output given" compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options) - vool = compiler.ruby_to_vool(as_test_main) + vool = compiler.ruby_to_vool(as_main) compiler.to_target(:interpreter) end def produce_main diff --git a/test/mom/macro/helper.rb b/test/mom/macro/helper.rb index 3c123684..e5a1050c 100644 --- a/test/mom/macro/helper.rb +++ b/test/mom/macro/helper.rb @@ -5,7 +5,7 @@ module Mom class BootTest < MiniTest::Test def setup Parfait.boot!(Parfait.default_test_options) - Builtin.compiler_for( Parfait.object_space.get_class.instance_type , Space , :main) + MomCollection.compiler_for( Parfait.object_space.get_class.instance_type , Parfait::Space , :main) end def get_int_compiler(name) obj_type = Parfait.object_space.get_type_by_class_name(:Integer) diff --git a/test/mom/test_block_compiler.rb b/test/mom/test_block_compiler.rb index 84ae40a6..70b4f3d7 100644 --- a/test/mom/test_block_compiler.rb +++ b/test/mom/test_block_compiler.rb @@ -5,7 +5,7 @@ module Mom include ScopeHelper def setup - code = as_test_main_block("return 5" , "a = 1") + code = as_main_block("return 5" , "a = 1") @risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code) end @@ -24,7 +24,7 @@ module Mom include ScopeHelper def setup - code = as_test_main_block("return arg" , "arg = 1") + code = as_main_block("return arg" , "arg = 1") @risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code) end diff --git a/test/mom/test_block_statement.rb b/test/mom/test_block_statement.rb index c8a6d6b7..21097869 100644 --- a/test/mom/test_block_statement.rb +++ b/test/mom/test_block_statement.rb @@ -6,7 +6,7 @@ module Vool include MomCompile def setup - @ret = compile_mom( as_test_main("self.main {|elem| elem = 5 } ")) + @ret = compile_mom( as_main("self.main {|elem| elem = 5 } ")) end def test_is_compiler assert_equal Mom::MomCollection , @ret.class @@ -21,7 +21,7 @@ module Vool class TestBlockLocal < MiniTest::Test include MomCompile def setup - @ret = compile_mom( as_test_main("self.main {|elem| local = 5 } ")) + @ret = compile_mom( as_main("self.main {|elem| local = 5 } ")) @block = @ret.method_compilers.first.get_method.blocks end def test_block_arg_type @@ -43,11 +43,11 @@ module Vool def setup end def test_method_arg_compiles - ret = compile_mom( as_test_main("self.main {|elem| arg = 5 } ")) + ret = compile_mom( as_main("self.main {|elem| arg = 5 } ")) assert ret end def test_method_local_compiles - ret = compile_mom( as_test_main("local = 5 ; self.main {|elem| local = 10 } ")) + ret = compile_mom( as_main("local = 5 ; self.main {|elem| local = 10 } ")) assert ret end end diff --git a/test/mom/test_builtin.rb b/test/mom/test_builtin.rb deleted file mode 100644 index 694a101b..00000000 --- a/test/mom/test_builtin.rb +++ /dev/null @@ -1,23 +0,0 @@ -require_relative "helper" - -module Mom - class TestBuiltinFunction < MiniTest::Test - - def setup - Parfait.boot!(Parfait.default_test_options) - @functions = Builtin.boot_functions({}) - end - def test_has_boot_function - assert @functions - end - def test_boot_function_type - assert_equal Array, @functions.class - end - def test_boot_function_length - assert_equal 21, @functions.length - end - def test_boot_function_first - assert_equal Mom::MethodCompiler, @functions.first.class - end - end -end diff --git a/test/mom/test_class_statement.rb b/test/mom/test_class_statement.rb index bb8e4311..3da0f66c 100644 --- a/test/mom/test_class_statement.rb +++ b/test/mom/test_class_statement.rb @@ -6,7 +6,7 @@ module Vool include MomCompile def setup - @ret = compile_mom( as_test_main("return 1")) + @ret = compile_mom( as_main("return 1")) end def test_return_class diff --git a/test/mom/test_mom_collection.rb b/test/mom/test_mom_collection.rb index e78eff1b..4fc3f894 100644 --- a/test/mom/test_mom_collection.rb +++ b/test/mom/test_mom_collection.rb @@ -12,13 +12,13 @@ module Mom assert_equal MomCollection , @comp.class end def test_compilers - assert_equal 23 , @comp.compilers.length + assert_equal 2 , @comp.compilers.length end - def test_boot_compilers - assert_equal 22 , @comp.boot_compilers.length + def test_init_compiler + assert_equal Mom::MethodCompiler , @comp.init_compiler.class end def test_compilers_bare - assert_equal 22 , MomCollection.new.compilers.length + assert_equal 1 , MomCollection.new.compilers.length end def test_append_class assert_equal MomCollection, (@comp.append @comp).class @@ -31,7 +31,7 @@ module Mom include MomCompile def setup - @comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;") + @comp = compile_mom( "class Space ; def main(); return 'Hi'; end; end;") @collection = @comp.to_risc() end def compiler @@ -42,7 +42,7 @@ module Mom end def test_has_risc_compiler assert_equal Risc::MethodCompiler, compiler.class - assert_equal 23, @collection.method_compilers.length + assert_equal 2, @collection.method_compilers.length end def test_has_risc_instructions assert_equal Risc::Label, compiler.risc_instructions.class diff --git a/test/parfait/test_vool_method.rb b/test/parfait/test_vool_method.rb index 052ff624..1910cb92 100644 --- a/test/parfait/test_vool_method.rb +++ b/test/parfait/test_vool_method.rb @@ -6,7 +6,7 @@ module Vool def setup Parfait.boot!(Parfait.default_test_options) - ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") ) + ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") ) @clazz = ruby_tree.to_vool end def method diff --git a/test/ruby/test_class_statement.rb b/test/ruby/test_class_statement.rb index ccb0a3a1..2bbddd6e 100644 --- a/test/ruby/test_class_statement.rb +++ b/test/ruby/test_class_statement.rb @@ -49,11 +49,11 @@ module Ruby include RubyTests def test_compile_one_method - lst = compile( as_test_main("@ivar = 4") ) + lst = compile( as_main("@ivar = 4") ) assert_equal IvarAssignment , lst.body.first.body.class end def test_compile_two_stats - lst = compile( as_test_main("false; true;") ) + lst = compile( as_main("false; true;") ) assert_equal ScopeStatement , lst.body.first.body.class assert_equal TrueConstant , lst.body.first.body.statements[1].class end diff --git a/test/support/compiling.rb b/test/support/compiling.rb index a88b3ebc..88e315e7 100644 --- a/test/support/compiling.rb +++ b/test/support/compiling.rb @@ -1,10 +1,6 @@ module ScopeHelper - def in_Test(statements) - "class Test ; #{statements} ; end" - end - def in_Space(statements) "class Space ; #{statements} ; end" end @@ -13,12 +9,8 @@ module ScopeHelper in_Space("def main(arg) ; #{statements}; end") end - def as_test_main( statements ) - in_Test("def main(arg) ; #{statements}; end") - end - - def as_test_main_block( block_input = "return 5", method_input = "main_local = 5") - as_test_main("#{method_input} ; self.main{|val| #{block_input}}") + def as_main_block( block_input = "return 5", method_input = "main_local = 5") + as_main("#{method_input} ; self.main{|val| #{block_input}}") end end @@ -26,8 +18,8 @@ module VoolCompile include ScopeHelper include Mom - def compile_first_method( input ) - input = as_test_main( input ) + def compile_main( input ) + input = 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 @@ -35,8 +27,8 @@ module VoolCompile assert_equal Mom::MethodCompiler , compiler.class compiler end - def compile_first_block( block_input , method_input = "main_local = 5") - source = as_test_main("#{method_input} ; self.main{|val| #{block_input}}") + def compile_main_block( block_input , method_input = "main_local = 5") + source = 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/vool/class_send/helper.rb b/test/vool/class_send/helper.rb index 9cbfb409..7cfca00c 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_first_method( send_method ) + @compiler = compile_main( send_method ) @ins = @compiler.mom_instructions.next end diff --git a/test/vool/lambdas/test_assign.rb b/test/vool/lambdas/test_assign.rb index 46bd5dcf..6c31a043 100644 --- a/test/vool/lambdas/test_assign.rb +++ b/test/vool/lambdas/test_assign.rb @@ -5,7 +5,7 @@ module VoolBlocks include VoolCompile def setup - @ins = compile_first_block( "local = 5" ) + @ins = compile_main_block( "local = 5" ) end def test_block_compiles assert_equal Mom::SlotLoad , @ins.class , @ins @@ -30,7 +30,7 @@ module VoolBlocks class TestAssignMomInstanceToLocal < MiniTest::Test include VoolCompile def setup - @ins = compile_first_block( "local = @a" , "@a = 5") #second arg in method scope + @ins = compile_main_block( "local = @a" , "@a = 5") #second arg in method scope end def test_class_compiles assert_equal Mom::SlotLoad , @ins.class , @ins @@ -47,7 +47,7 @@ module VoolBlocks include VoolCompile def setup - @ins = compile_first_block( "arg = 5") + @ins = compile_main_block( "arg = 5") end def test_class_compiles @@ -66,12 +66,12 @@ module VoolBlocks def setup end def test_assigns_const - @ins = compile_first_block( "@a = 5") + @ins = compile_main_block( "@a = 5") assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins end def test_assigns_move - @ins = compile_first_block( "@a = arg") + @ins = compile_main_block( "@a = arg") assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::SlotDefinition , @ins.right.class , @ins end diff --git a/test/vool/lambdas/test_if_condition.rb b/test/vool/lambdas/test_if_condition.rb index 69b74f9e..1c2b80cf 100644 --- a/test/vool/lambdas/test_if_condition.rb +++ b/test/vool/lambdas/test_if_condition.rb @@ -5,7 +5,7 @@ module VoolBlocks include VoolCompile def setup - @ins = compile_first_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end") + @ins = compile_main_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end") end def test_condition diff --git a/test/vool/lambdas/test_while_simple.rb b/test/vool/lambdas/test_while_simple.rb index 2fbc1ca4..195b2c36 100644 --- a/test/vool/lambdas/test_while_simple.rb +++ b/test/vool/lambdas/test_while_simple.rb @@ -5,7 +5,7 @@ module VoolBlocks include VoolCompile def setup - @ins = compile_first_block( "while(@a) ; @a = 5 ; end") + @ins = compile_main_block( "while(@a) ; @a = 5 ; end") end def test_compiles_as_while diff --git a/test/vool/send/helper.rb b/test/vool/send/helper.rb index 3b455509..32686150 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_first_method( send_method ) + @compiler = compile_main( send_method ) @ins = @compiler.mom_instructions.next end diff --git a/test/vool/send/test_not_found.rb b/test/vool/send/test_not_found.rb index de62fbf7..0274f77b 100644 --- a/test/vool/send/test_not_found.rb +++ b/test/vool/send/test_not_found.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "5.div8") + @compiler = compile_main( "5.div8") @ins = @compiler.mom_instructions.next end def test_check_type diff --git a/test/vool/send/test_send_args_send.rb b/test/vool/send/test_send_args_send.rb index d847909b..37fc43a1 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_first_method( "a = main(1 + 2);return a" ) + @compiler = compile_main( "a = main(1 + 2);return a" ) @ins = @compiler.mom_instructions.next end diff --git a/test/vool/send/test_send_cached_simple.rb b/test/vool/send/test_send_cached_simple.rb index bd3f1840..722b862c 100644 --- a/test/vool/send/test_send_cached_simple.rb +++ b/test/vool/send/test_send_cached_simple.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "a = 5; a.div4;return ") + @compiler = compile_main( "a = 5; a.div4;return ") @ins = @compiler.mom_instructions.next end def test_check_type diff --git a/test/vool/test_assignment.rb b/test/vool/test_assignment.rb index 89396473..fc837803 100644 --- a/test/vool/test_assignment.rb +++ b/test/vool/test_assignment.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "local = 5;return") + @compiler = compile_main( "local = 5;return") @ins = @compiler.mom_instructions.next end @@ -33,7 +33,7 @@ module Vool class TestAssignMomInstanceToLocal < MiniTest::Test include VoolCompile def setup - @compiler = compile_first_method( "@a = 5 ; local = @a;return") + @compiler = compile_main( "@a = 5 ; local = @a;return") @ins = @compiler.mom_instructions.next end def test_class_compiles @@ -46,7 +46,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "arg = 5;return") + @compiler = compile_main( "arg = 5;return") @ins = @compiler.mom_instructions.next end @@ -70,13 +70,13 @@ module Vool Parfait.boot!(Parfait.default_test_options) end def test_assigns_const - @compiler = compile_first_method( "@a = 5;return") + @compiler = compile_main( "@a = 5;return") @ins = @compiler.mom_instructions.next assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins end def test_assigns_move - @compiler = compile_first_method( "@a = arg;return") + @compiler = compile_main( "@a = arg;return") @ins = @compiler.mom_instructions.next assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::SlotDefinition , @ins.right.class , @ins diff --git a/test/vool/test_class_expression.rb b/test/vool/test_class_expression.rb index e2d94a0a..b0941465 100644 --- a/test/vool/test_class_expression.rb +++ b/test/vool/test_class_expression.rb @@ -6,7 +6,7 @@ module Vool include ScopeHelper def setup Parfait.boot!(Parfait.default_test_options) - ruby_tree = Ruby::RubyCompiler.compile( as_test_main("@a = 5") ) + ruby_tree = Ruby::RubyCompiler.compile( as_main("@a = 5") ) @vool = ruby_tree.to_vool end def test_class @@ -31,7 +31,7 @@ module Vool Parfait.boot!(Parfait.default_test_options) end def assert_type_for(input) - ruby_tree = Ruby::RubyCompiler.compile( as_test_main(input) ) + ruby_tree = Ruby::RubyCompiler.compile( as_main(input) ) vool = ruby_tree.to_vool assert_equal ClassExpression , vool.class clazz = vool.create_class_object @@ -67,7 +67,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return") + @compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return") @ins = @compiler.mom_instructions end diff --git a/test/vool/test_if_no_else.rb b/test/vool/test_if_no_else.rb index 7921839f..5d857b55 100644 --- a/test/vool/test_if_no_else.rb +++ b/test/vool/test_if_no_else.rb @@ -6,7 +6,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "if(@a) ; @a = 5 ; end;return") + @compiler = compile_main( "if(@a) ; @a = 5 ; end;return") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_if_no_if.rb b/test/vool/test_if_no_if.rb index 1e764d9a..7bb1067f 100644 --- a/test/vool/test_if_no_if.rb +++ b/test/vool/test_if_no_if.rb @@ -6,7 +6,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "unless(@a) ; @a = 5 ; end;return") + @compiler = compile_main( "unless(@a) ; @a = 5 ; end;return") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_if_simple.rb b/test/vool/test_if_simple.rb index b5d97ded..883f6ff0 100644 --- a/test/vool/test_if_simple.rb +++ b/test/vool/test_if_simple.rb @@ -6,7 +6,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return") + @compiler = compile_main( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_if_statement.rb b/test/vool/test_if_statement.rb index cc3944bc..b4c68ad6 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_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return") + @compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_ivar.rb b/test/vool/test_ivar.rb index 0e33cb0f..223597f9 100644 --- a/test/vool/test_ivar.rb +++ b/test/vool/test_ivar.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "@a = 5") + @compiler = compile_main( "@a = 5") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_local_assignment.rb b/test/vool/test_local_assignment.rb index 80b203bb..a35dccd4 100644 --- a/test/vool/test_local_assignment.rb +++ b/test/vool/test_local_assignment.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "a = 5") + @compiler = compile_main( "a = 5") @ins = @compiler.mom_instructions.next end @@ -37,7 +37,7 @@ module Vool def setup Parfait.boot!(Parfait.default_test_options) - @compiler = compile_first_method( "arg = 5") + @compiler = compile_main( "arg = 5") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_macro_expression.rb b/test/vool/test_macro_expression.rb index c82b62a2..955f9a66 100644 --- a/test/vool/test_macro_expression.rb +++ b/test/vool/test_macro_expression.rb @@ -15,7 +15,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "X.plus_equals(arg,1)") + @compiler = compile_main( "X.plus_equals(arg,1)") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_method_expression.rb b/test/vool/test_method_expression.rb index 84fbfb53..e73de4ff 100644 --- a/test/vool/test_method_expression.rb +++ b/test/vool/test_method_expression.rb @@ -6,7 +6,7 @@ module Vool def setup Parfait.boot!(Parfait.default_test_options) - ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") ) + ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") ) @clazz = ruby_tree.to_vool end def method diff --git a/test/vool/test_return.rb b/test/vool/test_return.rb index ab88e041..bd14acae 100644 --- a/test/vool/test_return.rb +++ b/test/vool/test_return.rb @@ -1,11 +1,11 @@ require_relative "helper" module Vool - class TestReturnMom < MiniTest::Test + class TestReturnMom #< MiniTest::Test include VoolCompile def setup - @compiler = compile_first_method( "return 5") + @compiler = compile_main( "return 5") @ins = @compiler.mom_instructions.next end @@ -41,7 +41,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "return 5.div4") + @compiler = compile_main( "return 5.div4") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_while_statement.rb b/test/vool/test_while_statement.rb index 7fbe5048..9ba421cd 100644 --- a/test/vool/test_while_statement.rb +++ b/test/vool/test_while_statement.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "while(@a) ; @a = 5 ; end;return") + @compiler = compile_main( "while(@a) ; @a = 5 ; end;return") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_while_statement1.rb b/test/vool/test_while_statement1.rb index 1119b59d..d5f61449 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_first_method( "while(5.div4) ; 5.div4 ; end;return") + @compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return") @ins = @compiler.mom_instructions.next end diff --git a/test/vool/test_yield_statement.rb b/test/vool/test_yield_statement.rb index 1d03e546..c4c2df38 100644 --- a/test/vool/test_yield_statement.rb +++ b/test/vool/test_yield_statement.rb @@ -5,7 +5,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "return yield(1)" ) + @compiler = compile_main( "return yield(1)" ) @ins = @compiler.mom_instructions.next end @@ -69,7 +69,7 @@ module Vool include VoolCompile def setup - @compiler = compile_first_method( "return yield(some.extra.calls)" ) + @compiler = compile_main( "return yield(some.extra.calls)" ) @ins = @compiler.mom_instructions.next end def test_check_label