2018-03-30 17:05:38 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestCallSimpleArgs < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@input = "5.get_internal_word(1)"
|
|
|
|
@expect = [LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
|
|
|
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
|
|
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label]
|
|
|
|
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-30 17:05:38 +02:00
|
|
|
produced = produce_body
|
2018-03-30 17:13:17 +02:00
|
|
|
assert_equal 5 , produced.next(16).constant.value
|
2018-03-30 17:05:38 +02:00
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_load_label
|
2018-03-30 17:05:38 +02:00
|
|
|
produced = produce_body
|
2018-03-30 17:13:17 +02:00
|
|
|
assert_equal LoadConstant , produced.next(23).class
|
|
|
|
assert_equal Label , produced.next(23).constant.class
|
2018-03-30 17:05:38 +02:00
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_function_call
|
2018-03-30 17:05:38 +02:00
|
|
|
produced = produce_body
|
2018-03-30 17:13:17 +02:00
|
|
|
assert_equal FunctionCall , produced.next(28).class
|
|
|
|
assert_equal :get_internal_word , produced.next(28).method.name
|
2018-03-30 17:05:38 +02:00
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_call_reg_setup
|
2018-03-30 17:05:38 +02:00
|
|
|
produced = produce_body
|
2018-03-30 17:13:17 +02:00
|
|
|
assert_equal produced.next(27).register , produced.next(28).register
|
2018-03-30 17:05:38 +02:00
|
|
|
end
|
2018-03-30 17:13:17 +02:00
|
|
|
def test_check_continue
|
2018-03-30 17:05:38 +02:00
|
|
|
produced = produce_body
|
2018-03-30 17:13:17 +02:00
|
|
|
assert produced.next(29).name.start_with?("continue_")
|
2018-03-30 17:05:38 +02:00
|
|
|
end
|
|
|
|
#TODO check the message setup, type and frame moves
|
|
|
|
end
|
|
|
|
end
|