diff --git a/test/helper.rb b/test/helper.rb index 2e886af7..86116324 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -14,7 +14,7 @@ end require "minitest/color" require "minitest/autorun" -#require "minitest/fail_fast" unless ENV["TEST_ALL"] +require "minitest/fail_fast" unless ENV["TEST_ALL"] require 'minitest/profile' #require "minitest/reporters" #Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new diff --git a/test/mom/blocks/test_block_setup.rb b/test/mom/blocks/test_block_setup.rb index 20d1bb2a..b5d063ef 100644 --- a/test/mom/blocks/test_block_setup.rb +++ b/test/mom/blocks/test_block_setup.rb @@ -7,55 +7,48 @@ module Risc def setup super @input = as_block("return 5") - @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #4 - RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, #9 - RegToSlot, RegToSlot, RegToSlot, RegToSlot, SlotToReg, #14 - SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #19 - SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #24 - SlotToReg, FunctionCall, Label] #29 + @expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, #4 + SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #9 + RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant, #14 + SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #19 + RegToSlot, SlotToReg, FunctionCall, Label] #24 end def test_send_instructions assert_nil msg = check_nil(:main) , msg end - def test_load_5 + def test_load_5_block produced = produce_block.next assert_load( produced , Parfait::Integer) assert_equal 5 , produced.constant.value end - def test_load_5 produced = produce_body assert_load( produced , Parfait::Integer) assert_equal 5 , produced.constant.value end - def test_load_block - produced = produce_body.next(3) - assert_load( produced , Parfait::Block) - assert_equal :main_block , produced.constant.name - end - def test_load_method_to_call - produced = produce_body.next(6) - assert_load( produced , Parfait::CallableMethod) - assert_equal :main , produced.constant.name - end def test_load_next_message - produced = produce_body.next(7) + produced = produce_body.next(4) assert_load( produced , Parfait::Factory) assert_equal "Message_Type" , produced.constant.for_type.name end + def test_load_block + produced = produce_body.next(14) + assert_load( produced , Parfait::Block) + assert_equal :main_block , produced.constant.name + end def test_load_return - produced = produce_body.next(22) + produced = produce_body.next(18) assert_load( produced , Label) assert produced.constant.name.start_with?("continue_") end def test_function_call - produced = produce_body.next(26) + produced = produce_body.next(22) assert_equal FunctionCall , produced.class assert_equal :main , produced.method.name end def test_check_continue - produced = produce_body.next(27) + produced = produce_body.next(23) assert_equal Label , produced.class assert produced.name.start_with?("continue_") end diff --git a/test/parfait/test_vool_method.rb b/test/parfait/test_vool_method.rb index 30a3e8ea..052ff624 100644 --- a/test/parfait/test_vool_method.rb +++ b/test/parfait/test_vool_method.rb @@ -13,9 +13,9 @@ module Vool @clazz.body.first end def test_setup - assert_equal ClassStatement , @clazz.class + assert_equal ClassExpression , @clazz.class assert_equal Statements , @clazz.body.class - assert_equal MethodStatement , method.class + assert_equal MethodExpression , method.class end def test_class assert_equal Parfait::Class , @clazz.create_class_object.class @@ -24,9 +24,5 @@ module Vool clazz = @clazz.create_class_object assert_equal Parfait::VoolMethod , method.make_method(clazz).class end - - #create CallableMethod - - #create Compiler end end diff --git a/test/risc/interpreter/blocks/test_assign_outer.rb b/test/risc/interpreter/blocks/test_assign_outer.rb index afdfeb4d..df9f09cd 100644 --- a/test/risc/interpreter/blocks/test_assign_outer.rb +++ b/test/risc/interpreter/blocks/test_assign_outer.rb @@ -11,52 +11,56 @@ module Risc def test_chain # show_main_ticks # get output of what is - check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, - RegToSlot, LoadConstant, LoadConstant, SlotToReg, SlotToReg, # 10 - RegToSlot, RegToSlot, RegToSlot, Branch, RegToSlot, - SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, # 20 - SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, - RegToSlot, SlotToReg, Branch, FunctionCall, LoadConstant, # 30 - SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, - LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, # 40 - RegToSlot, RegToSlot, Branch, SlotToReg, SlotToReg, - RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg, # 50 - SlotToReg, SlotToReg, DynamicJump, LoadConstant, SlotToReg, - SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, # 60 + check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, + SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, # 10 + RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot, + LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 20 + SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, + SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, # 30 + LoadConstant, SlotToReg, SlotToReg, RegToSlot, RegToSlot, + RegToSlot, RegToSlot, Branch, SlotToReg, SlotToReg, # 40 + RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg, + SlotToReg, SlotToReg, DynamicJump, LoadConstant, SlotToReg, # 50 + SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot, + Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 60 + SlotToReg, Branch, RegToSlot, RegToSlot, SlotToReg, + SlotToReg, SlotToReg, FunctionReturn, SlotToReg, RegToSlot, # 70 Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, - SlotToReg, Branch, RegToSlot, RegToSlot, SlotToReg, # 70 - SlotToReg, SlotToReg, FunctionReturn, SlotToReg, RegToSlot, - Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 80 - SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, - SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, # 90 - Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, - SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, # 100 - SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, + SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 80 + SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot, + Branch, Branch, SlotToReg, SlotToReg, RegToSlot, # 90 + LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, + SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, # 100 SlotToReg, Syscall, NilClass, ] assert_equal 10 , get_return end def test_block_jump - load_ins = main_ticks(53) + load_ins = main_ticks(48) assert_equal DynamicJump , load_ins.class assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class end def test_block_load - load_ins = main_ticks(54) + load_ins = main_ticks(49) assert_load load_ins , Parfait::Integer , :r1 assert_equal 10 , @interpreter.get_register(load_ins.register).value end + def test_ret_load + load_ins = main_ticks(54) + assert_load load_ins , Parfait::Integer , :r1 + assert_equal 15 , @interpreter.get_register(load_ins.register).value + end def test_block_slot1 - assert_slot_to_reg main_ticks(55) ,:r0 , 6 , :r2 + assert_slot_to_reg main_ticks(50) ,:r0 , 6 , :r2 end def test_block_slot2 - assert_slot_to_reg main_ticks(56) ,:r2 , 6 , :r2 + assert_slot_to_reg main_ticks(51) ,:r2 , 6 , :r2 end def test_block_slot3 - assert_slot_to_reg main_ticks(57) ,:r2 , 3 , :r2 + assert_slot_to_reg main_ticks(52) ,:r2 , 3 , :r2 end def test_block_reg - assert_reg_to_slot main_ticks(58) ,:r1 , :r2 , 1 + assert_reg_to_slot main_ticks(53) ,:r1 , :r2 , 1 end end end diff --git a/test/risc/interpreter/blocks/test_block_return.rb b/test/risc/interpreter/blocks/test_block_return.rb index ea60bd7b..b8c8d24e 100644 --- a/test/risc/interpreter/blocks/test_block_return.rb +++ b/test/risc/interpreter/blocks/test_block_return.rb @@ -11,38 +11,38 @@ module Risc def test_chain #show_main_ticks # get output of what is - check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, - SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, # 10 - RegToSlot, SlotToReg, SlotToReg, Branch, RegToSlot, - SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, # 20 - LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, - LoadConstant, SlotToReg, OperatorInstruction, IsZero, SlotToReg, # 30 - SlotToReg, LoadConstant, SlotToReg, SlotToReg, RegToSlot, - RegToSlot, RegToSlot, RegToSlot, Branch, SlotToReg, # 40 - SlotToReg, RegToSlot, SlotToReg, LoadConstant, RegToSlot, - SlotToReg, SlotToReg, SlotToReg, DynamicJump, LoadConstant, # 50 - RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, - LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, # 60 - SlotToReg, SlotToReg, Branch, FunctionReturn, SlotToReg, - RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, # 70 - LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, - SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg, # 80 - Branch, RegToSlot, SlotToReg, SlotToReg, RegToSlot, - Branch, SlotToReg, SlotToReg, RegToSlot, LoadConstant, # 90 - SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, - SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, # 100 + check_main_chain [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, + RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 10 + RegToSlot, LoadConstant, SlotToReg, Branch, SlotToReg, + RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, # 20 + FunctionCall, LoadConstant, SlotToReg, OperatorInstruction, IsZero, + SlotToReg, SlotToReg, LoadConstant, SlotToReg, SlotToReg, # 30 + RegToSlot, RegToSlot, RegToSlot, RegToSlot, Branch, + SlotToReg, SlotToReg, RegToSlot, SlotToReg, LoadConstant, # 40 + RegToSlot, SlotToReg, SlotToReg, SlotToReg, DynamicJump, + LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg, # 50 + RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, + SlotToReg, SlotToReg, SlotToReg, Branch, FunctionReturn, # 60 + SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, + RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot, # 70 + SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, + SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, # 80 + Branch, Branch, SlotToReg, SlotToReg, RegToSlot, + LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg, # 90 + SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ] + assert_equal 15 , get_return end def test_load_return - load_ins = main_ticks(44) + load_ins = main_ticks(40) assert_equal LoadConstant , load_ins.class assert_equal Parfait::ReturnAddress , @interpreter.get_register(load_ins.register).class end def test_load_block - load_ins = main_ticks(49) + load_ins = main_ticks(45) assert_equal DynamicJump , load_ins.class assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class assert_equal :main_block , @interpreter.get_register(load_ins.register).name diff --git a/test/risc/test_method_compiler.rb b/test/risc/test_method_compiler.rb index 2d1c4d89..58e2be99 100644 --- a/test/risc/test_method_compiler.rb +++ b/test/risc/test_method_compiler.rb @@ -42,7 +42,7 @@ module Risc def test_creates_method_statement_in_class clazz = in_test_vool("def meth; @ivar = 5 ;return;end") assert_equal Vool::Statements , clazz.body.class - assert_equal Vool::MethodStatement , clazz.body.first.class + assert_equal Vool::MethodExpression , clazz.body.first.class end def test_callable_method_instance_type diff --git a/test/rubyx/parfait/test_object.rb b/test/rubyx/parfait/test_object.rb index 8dd2e778..9961f30a 100644 --- a/test/rubyx/parfait/test_object.rb +++ b/test/rubyx/parfait/test_object.rb @@ -13,7 +13,7 @@ module RubyX end def test_vool vool = compiler.ruby_to_vool source - assert_equal Vool::ClassStatement , vool.class + assert_equal Vool::ClassExpression , vool.class assert_equal :Object , vool.name end def test_mom diff --git a/test/rubyx/test_rubyx_compiler.rb b/test/rubyx/test_rubyx_compiler.rb index 56eb2aff..bbe1d005 100644 --- a/test/rubyx/test_rubyx_compiler.rb +++ b/test/rubyx/test_rubyx_compiler.rb @@ -18,7 +18,7 @@ module RubyX def test_class_body_is_scope clazz = ruby_to_vool in_Test("def meth; @ivar = 5 ;end") assert_equal Vool::Statements , clazz.body.class - assert_equal Vool::MethodStatement , clazz.body.first.class + assert_equal Vool::MethodExpression , clazz.body.first.class end def test_space_is_unchanged_by_compile diff --git a/test/rubyx/test_rubyx_compiler3.rb b/test/rubyx/test_rubyx_compiler3.rb index 471987fc..822bb5b2 100644 --- a/test/rubyx/test_rubyx_compiler3.rb +++ b/test/rubyx/test_rubyx_compiler3.rb @@ -20,7 +20,7 @@ module RubyX def test_one_vool_call compiler = RubyXCompiler.new(RubyX.default_test_options) compiler.ruby_to_vool(space_source_for("main")) - assert_equal Vool::ClassStatement , compiler.vool.class + assert_equal Vool::ClassExpression , compiler.vool.class end def test_two_vool_calls compiler = RubyXCompiler.new(RubyX.default_test_options)