2018-04-05 11:19:29 +02:00
|
|
|
require_relative "../helper"
|
2018-03-21 17:28:43 +01:00
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestSendDynamic < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
2018-04-19 09:00:55 +02:00
|
|
|
@input = "@a.div4"
|
2018-04-08 21:59:42 +02:00
|
|
|
@expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
|
|
|
OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg,
|
|
|
|
LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg,
|
|
|
|
SlotToReg, Label, LoadConstant, SlotToReg, OperatorInstruction,
|
|
|
|
IsZero, SlotToReg, OperatorInstruction, IsZero, SlotToReg,
|
|
|
|
Branch, Label, Transfer, Syscall, Transfer,
|
|
|
|
Transfer, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
RegToSlot, RegToSlot, Label, RegToSlot, Label,
|
2018-04-08 22:45:23 +02:00
|
|
|
LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot,
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
|
|
|
|
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
2018-04-09 14:06:46 +02:00
|
|
|
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant,
|
|
|
|
SlotToReg, DynamicJump, Label]
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_send_instructions
|
|
|
|
assert_nil msg = check_nil , msg
|
|
|
|
end
|
2018-04-08 21:30:18 +02:00
|
|
|
def test_sys
|
2018-03-21 17:28:43 +01:00
|
|
|
produced = produce_body
|
2018-04-08 21:59:42 +02:00
|
|
|
assert_equal Syscall , produced.next(28).class
|
|
|
|
assert_equal :exit , produced.next(28).name
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
def test_load_address
|
|
|
|
produced = produce_body
|
2018-04-08 21:59:42 +02:00
|
|
|
assert_equal LoadConstant , produced.next(40).class
|
|
|
|
assert_equal Parfait::CacheEntry , produced.next(40).constant.class
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
2018-04-08 21:30:18 +02:00
|
|
|
def test_function_call
|
2018-03-21 17:28:43 +01:00
|
|
|
produced = produce_body
|
2018-04-09 14:06:46 +02:00
|
|
|
assert_equal DynamicJump , produced.next(66).class
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
2018-04-08 21:30:18 +02:00
|
|
|
def test_cache_check
|
2018-03-21 17:28:43 +01:00
|
|
|
produced = produce_body
|
2018-04-08 21:59:42 +02:00
|
|
|
assert_equal IsZero , produced.next(6).class
|
|
|
|
assert_equal Label , produced.next(39).class
|
|
|
|
assert_equal produced.next(39) , produced.next(6).label
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|