2019-09-17 13:16:56 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 19:55:41 +02:00
|
|
|
module SlotMachine
|
|
|
|
class TestSimpleCall < SlotMachineInstructionTest
|
2019-09-17 13:16:56 +02:00
|
|
|
include Parfait::MethodHelper
|
|
|
|
|
|
|
|
def instruction
|
|
|
|
SimpleCall.new( make_method )
|
|
|
|
end
|
2020-03-01 22:38:23 +01:00
|
|
|
def est_len
|
2019-09-17 13:16:56 +02:00
|
|
|
assert_equal 7 , all.length , all_str
|
|
|
|
end
|
|
|
|
def test_1_load_return_label
|
2020-03-02 16:50:49 +01:00
|
|
|
assert_load risc(1) , Risc::Label , "id_"
|
2019-09-17 13:16:56 +02:00
|
|
|
assert_label risc(1).constant , "continue_"
|
|
|
|
end
|
|
|
|
def test_2_load_next_message
|
2020-03-01 22:38:23 +01:00
|
|
|
assert_slot_to_reg risc(2) ,:message , 1 , :"message.next_message"
|
2019-09-17 13:16:56 +02:00
|
|
|
end
|
|
|
|
def test_3_store_return_address
|
2020-03-02 16:50:49 +01:00
|
|
|
assert_reg_to_slot risc(3) , "id_" , :"message.next_message" , 4
|
2019-09-17 13:16:56 +02:00
|
|
|
end
|
|
|
|
def test_4_swap_messages
|
2020-03-01 22:38:23 +01:00
|
|
|
assert_slot_to_reg risc(4) ,:message , 1 , :message
|
2019-09-17 13:16:56 +02:00
|
|
|
end
|
|
|
|
def test_5_call
|
|
|
|
assert_equal Risc::FunctionCall , risc(5).class
|
|
|
|
assert_equal :meth , risc(5).method.name
|
|
|
|
end
|
|
|
|
def test_6_label
|
2020-03-01 22:38:23 +01:00
|
|
|
assert_equal Risc::Label , risc(6).class
|
2019-09-17 13:16:56 +02:00
|
|
|
assert_label risc(6) , "continue_"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|