2018-04-05 11:19:29 +02:00
|
|
|
require_relative "../helper"
|
2018-03-21 14:50:51 +01:00
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestCallSimple < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@input = "5.mod4"
|
2018-04-06 22:37:41 +02:00
|
|
|
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
|
|
|
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
|
|
|
|
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label]
|
2018-03-21 14:50:51 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_send_instructions
|
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_load_5
|
2018-03-21 17:35:51 +01:00
|
|
|
produced = produce_body
|
2018-04-06 22:37:41 +02:00
|
|
|
assert_equal 5 , produced.next(15).constant.value
|
2018-03-21 17:35:51 +01:00
|
|
|
end
|
2018-03-21 14:50:51 +01:00
|
|
|
def test_load_label
|
|
|
|
produced = produce_body
|
2018-04-06 22:37:41 +02:00
|
|
|
assert_equal Label , produced.next(18).constant.class
|
2018-03-21 14:50:51 +01:00
|
|
|
end
|
2018-03-21 14:59:00 +01:00
|
|
|
def test_call_reg_setup
|
2018-03-21 14:50:51 +01:00
|
|
|
produced = produce_body
|
2018-04-06 22:37:41 +02:00
|
|
|
assert_equal produced.next(22).register , produced.next(23).register
|
2018-03-21 14:50:51 +01:00
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_function_call
|
|
|
|
produced = produce_body
|
2018-04-06 22:37:41 +02:00
|
|
|
assert_equal FunctionCall , produced.next(23).class
|
|
|
|
assert_equal :mod4 , produced.next(23).method.name
|
2018-03-30 17:13:17 +02:00
|
|
|
end
|
|
|
|
def test_check_continue
|
|
|
|
produced = produce_body
|
2018-04-06 22:37:41 +02:00
|
|
|
assert produced.next(24).name.start_with?("continue_")
|
2018-03-30 17:13:17 +02:00
|
|
|
end
|
2018-03-21 14:59:00 +01:00
|
|
|
#TODO check the message setup, type and frame moves
|
2018-03-21 14:50:51 +01:00
|
|
|
end
|
|
|
|
end
|