From 92f1921e2f8630906085f3dcbd6ee2923c6d41bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Tue, 17 Sep 2019 14:16:56 +0300 Subject: [PATCH] Last mom instruction test --- test/mom/instruction/test_check.rb | 46 ------------------------ test/mom/instruction/test_simple_call.rb | 34 ++++++++++++++++++ 2 files changed, 34 insertions(+), 46 deletions(-) delete mode 100644 test/mom/instruction/test_check.rb create mode 100644 test/mom/instruction/test_simple_call.rb diff --git a/test/mom/instruction/test_check.rb b/test/mom/instruction/test_check.rb deleted file mode 100644 index d7e5e828..00000000 --- a/test/mom/instruction/test_check.rb +++ /dev/null @@ -1,46 +0,0 @@ -require_relative "helper" - -module Mom - class TestNotSameCheck < MomInstructionTest - def instruction - target = SlotDefinition.new(:message , :caller) - NotSameCheck.new(target , target , Label.new("ok" , "land")) - end - def test_len - assert_equal 5 , all.length , all_str - end - def test_2_slot - assert_slot_to_reg risc(2) ,:r0 , 1 , :r2 - end - end -# [Label, SlotToReg, SlotToReg, OperatorInstruction, IsZero,] #5 -end -module X - class Y - def test_1_load - assert_load risc(1) , Risc::Label , :r1 - assert_label risc(1).constant , "continue_" - end - def test_2_slot - assert_slot_to_reg risc(2) ,:r0 , 1 , :r2 - end - def test_3_reg - assert_reg_to_slot risc(3) , :r1 , :r2 , 4 - end - def test_4_slot - assert_slot_to_reg risc(4) ,:r0 , 1 , :r0 - end - def test_5_load - assert_load risc(5) , Parfait::CacheEntry , :r3 - end - def test_6_slot - assert_slot_to_reg risc(6) ,:r3 , 2 , :r3 - end - def test_7_jump - assert_equal Risc::DynamicJump , risc(7).class - end - def test_8_label - assert_label risc(8) , "continue_" - end - end -end diff --git a/test/mom/instruction/test_simple_call.rb b/test/mom/instruction/test_simple_call.rb new file mode 100644 index 00000000..83c98d2c --- /dev/null +++ b/test/mom/instruction/test_simple_call.rb @@ -0,0 +1,34 @@ +require_relative "helper" + +module Mom + class TestSimpleCall < MomInstructionTest + include Parfait::MethodHelper + + def instruction + SimpleCall.new( make_method ) + end + def test_len + assert_equal 7 , all.length , all_str + end + def test_1_load_return_label + assert_load risc(1) , Risc::Label , :r1 + assert_label risc(1).constant , "continue_" + end + def test_2_load_next_message + assert_slot_to_reg risc(2) ,:r0 , 1 , :r2 + end + def test_3_store_return_address + assert_reg_to_slot risc(3) , :r1 , :r2 , 4 + end + def test_4_swap_messages + assert_slot_to_reg risc(4) ,:r0 , 1 , :r0 + end + def test_5_call + assert_equal Risc::FunctionCall , risc(5).class + assert_equal :meth , risc(5).method.name + end + def test_6_label + assert_label risc(6) , "continue_" + end + end +end