2018-04-05 19:10:00 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestMessageSetupSimple < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
2019-08-17 22:29:42 +02:00
|
|
|
@input = "return 5.div4"
|
2018-08-12 14:02:23 +02:00
|
|
|
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
2019-08-17 22:29:42 +02:00
|
|
|
FunctionCall, Label, SlotToReg, RegToSlot, Branch]
|
2018-04-05 19:10:00 +02:00
|
|
|
@produced = produce_body
|
|
|
|
end
|
|
|
|
|
2018-04-06 21:54:54 +02:00
|
|
|
def test_send_instructions
|
2018-04-05 19:10:00 +02:00
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_load_method
|
2018-04-05 19:10:00 +02:00
|
|
|
method = @produced
|
2018-07-07 08:11:09 +02:00
|
|
|
assert_load( method, Parfait::CallableMethod ,:r1)
|
2018-04-19 09:00:55 +02:00
|
|
|
assert_equal :div4 , method.constant.name
|
2018-04-05 19:10:00 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_load_space
|
2018-04-05 19:10:00 +02:00
|
|
|
space = @produced.next(1)
|
2018-09-01 10:28:53 +02:00
|
|
|
assert_load( space , Parfait::Factory , :r2 )
|
2018-04-05 19:10:00 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_load_first_message #from space (ie r2)
|
2018-04-05 19:10:00 +02:00
|
|
|
sl = @produced.next( 2 )
|
2018-09-01 10:28:53 +02:00
|
|
|
assert_slot_to_reg( sl , :r2 , 2 , :r3 )
|
2018-04-05 19:10:00 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_get_next_next #reduce onto itself
|
2018-04-05 19:10:00 +02:00
|
|
|
sl = @produced.next( 3 )
|
2018-08-12 14:02:23 +02:00
|
|
|
assert_slot_to_reg( sl , :r3 , 1 , :r4 )
|
2018-04-05 19:10:00 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_store_next_next_in_space
|
2018-04-05 19:37:03 +02:00
|
|
|
sl = @produced.next( 4 )
|
2018-09-01 10:28:53 +02:00
|
|
|
assert_reg_to_slot( sl , :r4 , :r2 , 2 )
|
2018-04-05 19:37:03 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_store_message_in_current
|
2018-04-05 19:37:03 +02:00
|
|
|
sl = @produced.next( 5 )
|
2018-08-12 14:02:23 +02:00
|
|
|
assert_reg_to_slot( sl , :r3 , :r0 , 1 )
|
2018-04-06 22:11:08 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_store_caller_in_message
|
2018-04-06 22:11:08 +02:00
|
|
|
sl = @produced.next( 6 )
|
2018-08-12 14:02:23 +02:00
|
|
|
assert_reg_to_slot( sl , :r0 , :r3 , 6 )
|
2018-04-06 22:11:08 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_store_method_in_message
|
2018-08-12 14:02:23 +02:00
|
|
|
sl = @produced.next( 7 )
|
2018-07-22 21:29:32 +02:00
|
|
|
assert_reg_to_slot( sl , :r1 , :r3 , 7 )
|
2018-04-06 21:54:54 +02:00
|
|
|
end
|
2019-08-22 21:56:44 +02:00
|
|
|
def pest_label
|
2019-08-17 22:29:42 +02:00
|
|
|
sl = @produced.next( 20 )
|
2018-08-19 16:29:04 +02:00
|
|
|
assert_equal Risc::Label , sl.class
|
|
|
|
assert_equal "return_label" , sl.name
|
|
|
|
end
|
2018-04-05 19:10:00 +02:00
|
|
|
end
|
|
|
|
end
|