2018-03-21 17:28:43 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestSendDynamic < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@input = "@a.mod4"
|
2018-03-22 18:14:22 +01:00
|
|
|
@expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, NotSame, SlotToReg ,
|
2018-03-21 17:28:43 +01:00
|
|
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot ,
|
2018-03-22 18:14:22 +01:00
|
|
|
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot ,
|
|
|
|
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot ,
|
2018-03-21 17:28:43 +01:00
|
|
|
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
|
|
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant ,
|
|
|
|
FunctionCall, Label, SlotToReg, RegToSlot, Label, LoadConstant ,
|
2018-03-22 18:14:22 +01:00
|
|
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
|
|
|
RegToSlot, LoadConstant, SlotToReg, DynamicJump]
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_send_instructions
|
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
|
|
|
def test_function_call
|
|
|
|
produced = produce_body
|
2018-03-22 18:14:22 +01:00
|
|
|
assert_equal DynamicJump , produced.next(63).class
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
def test_load_address
|
|
|
|
produced = produce_body
|
2018-03-22 18:14:22 +01:00
|
|
|
assert_equal LoadConstant , produced.next(61).class
|
|
|
|
assert_equal Parfait::CacheEntry , produced.next(61).constant.class
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
def test_cache_check
|
|
|
|
produced = produce_body
|
2018-03-22 18:14:22 +01:00
|
|
|
assert_equal NotSame , produced.next(4).class
|
|
|
|
assert_equal produced.next(40) , produced.next(4).label
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
def test_check_resolve
|
|
|
|
produced = produce_body
|
2018-03-22 18:14:22 +01:00
|
|
|
assert_equal FunctionCall , produced.next(36).class
|
|
|
|
assert_equal :resolve_method ,produced.next(36).method.name
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|