From e6729b8b60a85c094f9d959448b675b75eaad6e8 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sun, 8 Mar 2020 17:31:16 +0200 Subject: [PATCH] fixing instruction tests --- lib/slot_machine/instructions/simple_call.rb | 2 +- .../instructions/test_argument_transfer.rb | 14 +++++++------- .../instructions/test_block_yield.rb | 14 +++++++------- .../instructions/test_dynamic_call.rb | 16 ++++++++-------- test/slot_machine/instructions/test_jump.rb | 2 +- test/slot_machine/instructions/test_label.rb | 4 ++-- .../instructions/test_message_setup.rb | 14 +++++++------- .../instructions/test_not_same_check.rb | 8 ++++---- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/slot_machine/instructions/simple_call.rb b/lib/slot_machine/instructions/simple_call.rb index b55b3ac4..fac2a664 100644 --- a/lib/slot_machine/instructions/simple_call.rb +++ b/lib/slot_machine/instructions/simple_call.rb @@ -25,7 +25,7 @@ module SlotMachine # return_address of the next_message, for the ReturnSequence to pick it up. def to_risc(compiler) method = @method - return_label = Risc.label(self,"continue_#{object_id}") + return_label = Risc.label(self,"after_#{@method.name}_#{object_id}") return_address = compiler.load_object( return_label ) compiler.build(self.to_s) do message[:next_message][:return_address] << return_address diff --git a/test/slot_machine/instructions/test_argument_transfer.rb b/test/slot_machine/instructions/test_argument_transfer.rb index d8799062..d89afff5 100644 --- a/test/slot_machine/instructions/test_argument_transfer.rb +++ b/test/slot_machine/instructions/test_argument_transfer.rb @@ -11,25 +11,25 @@ module SlotMachine assert_equal 8 , all.length , all_str end def test_1_slot - assert_slot_to_reg risc(1) ,:message , 9 , :"message.arg1" + assert_slot_to_reg 1,:message , 9 , :"message.arg1" end def test_2_slot - assert_slot_to_reg risc(2) ,:message , 1 , :"message.next_message" + assert_slot_to_reg 2,:message , 1 , :"message.next_message" end def test_3_reg - assert_reg_to_slot risc(3) , :"message.arg1" , :"message.next_message" , 2 + assert_reg_to_slot 3, :"message.arg1" , :"message.next_message" , 2 end def test_4_slot - assert_slot_to_reg risc(4) ,:message , 2 , :"message.receiver" + assert_slot_to_reg 4,:message , 2 , :"message.receiver" end def test_5 - assert_slot_to_reg risc(5) ,:"message.receiver" , 0 , :"message.receiver.type" + assert_slot_to_reg 5,:"message.receiver" , 0 , :"message.receiver.type" end def test_6 - assert_slot_to_reg risc(6) ,:message , 1 , :"message.next_message" + assert_slot_to_reg 6,:message , 1 , :"message.next_message" end def test_7 - assert_reg_to_slot risc(7) , :"message.receiver.type" , :"message.next_message" , 9 + assert_reg_to_slot 7, :"message.receiver.type" , :"message.next_message" , 9 end end end diff --git a/test/slot_machine/instructions/test_block_yield.rb b/test/slot_machine/instructions/test_block_yield.rb index 009e5980..cf75dbe6 100644 --- a/test/slot_machine/instructions/test_block_yield.rb +++ b/test/slot_machine/instructions/test_block_yield.rb @@ -9,27 +9,27 @@ module SlotMachine assert_equal 8 , all.length , all_str end def test_1_load - assert_load risc(1) , Risc::Label , "id_" - assert_label risc(1).constant , "continue_" + assert_load 1, Risc::Label , "id_" + assert_label risc(1).constant , "continue_" ,1 end def test_2_slot - assert_slot_to_reg risc(2) ,:message , 1 , "message.next_message" + assert_slot_to_reg 2,:message , 1 , "message.next_message" end def test_3_reg - assert_reg_to_slot risc(3) , "id_" , "message.next_message" , 4 + assert_reg_to_slot 3, "id_" , "message.next_message" , 4 end def test_4_slot - assert_slot_to_reg risc(4) ,:message , 9 , "message.arg1" + assert_slot_to_reg 4,:message , 9 , "message.arg1" end def test_5_swap - assert_slot_to_reg risc(5) ,:message , 1 , :message + assert_slot_to_reg 5,:message , 1 , :message end def test_6_jump assert_equal Risc::DynamicJump , risc(6).class assert_equal :"message.arg1" , risc(6).register.symbol end def test_7_label - assert_label risc(7) , "continue_" + assert_label 7, "continue_" end end end diff --git a/test/slot_machine/instructions/test_dynamic_call.rb b/test/slot_machine/instructions/test_dynamic_call.rb index 16ff9e62..ed234af1 100644 --- a/test/slot_machine/instructions/test_dynamic_call.rb +++ b/test/slot_machine/instructions/test_dynamic_call.rb @@ -9,30 +9,30 @@ module SlotMachine assert_equal 9 , all.length , all_str end def test_1_load - assert_load risc(1) , Parfait::CacheEntry , "id_" + assert_load 1, Parfait::CacheEntry , "id_" end def test_2_slot - assert_slot_to_reg risc(2) , "id_" , 2 , "id_.cached_method" + assert_slot_to_reg 2, "id_" , 2 , "id_.cached_method" end def test_3_load - assert_load risc(3) , Risc::Label , "id_" - assert_label risc(3).constant , "continue_" + assert_load 3, Risc::Label , "id_" + assert_label risc(3).constant , "continue_" , 3 end def test_4_slot - assert_slot_to_reg risc(4) , :message , 1 , "message.next_message" + assert_slot_to_reg 4, :message , 1 , "message.next_message" end def test_5_reg - assert_reg_to_slot risc(5) , "id_" , "message.next_message" , 4 + assert_reg_to_slot 5, "id_" , "message.next_message" , 4 end def test_6_slot - assert_slot_to_reg risc(6) , :message , 1 , :message + assert_slot_to_reg 6, :message , 1 , :message end def test_7_jump assert_equal Risc::DynamicJump , risc(7).class assert_register :jump , "id_.cached_method" , risc(7).register end def test_8_label - assert_label risc(8) , "continue_" + assert_label 8, "continue_" end end end diff --git a/test/slot_machine/instructions/test_jump.rb b/test/slot_machine/instructions/test_jump.rb index 4a8c37c7..eb7c8727 100644 --- a/test/slot_machine/instructions/test_jump.rb +++ b/test/slot_machine/instructions/test_jump.rb @@ -9,7 +9,7 @@ module SlotMachine assert_equal 2 , all.length , all_str end def test_1_slot - assert_branch risc(1) , "target" + assert_branch 1, "target" end end end diff --git a/test/slot_machine/instructions/test_label.rb b/test/slot_machine/instructions/test_label.rb index 951abe28..af0acc2d 100644 --- a/test/slot_machine/instructions/test_label.rb +++ b/test/slot_machine/instructions/test_label.rb @@ -10,11 +10,11 @@ module SlotMachine assert_equal Risc::Label , all.first.class end def test_1_label - assert_equal Risc::Label , risc(1).class + assert_label 1 , "target" end def test_2_slot label = @instruction.risc_label( @compiler) - assert_equal risc(1) , label + assert_label label , "target" , 1 end end end diff --git a/test/slot_machine/instructions/test_message_setup.rb b/test/slot_machine/instructions/test_message_setup.rb index 50f6e2b2..8992a6e9 100644 --- a/test/slot_machine/instructions/test_message_setup.rb +++ b/test/slot_machine/instructions/test_message_setup.rb @@ -9,13 +9,13 @@ module SlotMachine assert_equal 4 , all.length , all_str end def test_1_slot - assert_slot_to_reg risc(1) ,:message , 9 , :"message.arg1" + assert_slot_to_reg 1 ,:message , 9 , :"message.arg1" end def test_2_slot - assert_slot_to_reg risc(2) ,:message , 1 , :"message.next_message" + assert_slot_to_reg 2 ,:message , 1 , :"message.next_message" end def test_3_reg - assert_reg_to_slot risc(3) , :"message.arg1" , :"message.next_message" , 7 + assert_reg_to_slot 3 , :"message.arg1" , :"message.next_message" , 7 end end class TestMessageSetupCache < SlotMachineInstructionTest @@ -30,16 +30,16 @@ module SlotMachine assert_equal 5 , all.length , all_str end def test_1_load - assert_load risc(1) , Parfait::CacheEntry , "id_" + assert_load 1 , Parfait::CacheEntry , "id_" end def test_2_slot - assert_slot_to_reg risc(2) ,"id_" , 2 , "id_.cached_method" + assert_slot_to_reg 2 ,"id_" , 2 , "id_.cached_method" end def test_3_slot - assert_slot_to_reg risc(3) ,:message , 1 , :"message.next_message" + assert_slot_to_reg 3 ,:message , 1 , :"message.next_message" end def test_4_reg - assert_reg_to_slot risc(4) , "id_.cached_method" , :"message.next_message" , 7 + assert_reg_to_slot 4 , "id_.cached_method" , :"message.next_message" , 7 end end diff --git a/test/slot_machine/instructions/test_not_same_check.rb b/test/slot_machine/instructions/test_not_same_check.rb index e4af014e..8387d129 100644 --- a/test/slot_machine/instructions/test_not_same_check.rb +++ b/test/slot_machine/instructions/test_not_same_check.rb @@ -11,16 +11,16 @@ module SlotMachine assert_equal 5 , all.length , all_str end def test_1_slot - assert_slot_to_reg risc(1) ,:message , 6 , :"message.caller" + assert_slot_to_reg 1,:message , 6 , :"message.caller" end def test_2_slot - assert_slot_to_reg risc(2) ,:message , 1 , :"message.next_message" + assert_slot_to_reg 2,:message , 1 , :"message.next_message" end def test_3_op - assert_operator risc(3) , :-, :"message.caller" , :"message.next_message" + assert_operator 3, :-, :"message.caller" , :"message.next_message" end def test_4_zero - assert_zero risc(4) , "target" + assert_not_zero 4, "target" end end end