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
|
2019-09-12 21:27:10 +02:00
|
|
|
@preload = "Integer.div4"
|
|
|
|
@input = "@classes.div4"
|
2019-08-23 18:24:18 +02:00
|
|
|
@expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, #5
|
|
|
|
OperatorInstruction, IsZero, SlotToReg, SlotToReg, SlotToReg, #10
|
|
|
|
LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #15
|
|
|
|
SlotToReg, Label, LoadConstant, OperatorInstruction, IsZero, #20
|
|
|
|
SlotToReg, OperatorInstruction, IsZero, SlotToReg, Branch, #25
|
|
|
|
Label, LoadConstant, SlotToReg, Transfer, Syscall, #30
|
|
|
|
Transfer, Transfer, SlotToReg, RegToSlot, Label, #35
|
|
|
|
RegToSlot, Label, LoadConstant, SlotToReg, SlotToReg, #40
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, #45
|
|
|
|
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, #50
|
|
|
|
SlotToReg, DynamicJump, Label, SlotToReg, RegToSlot, #55
|
|
|
|
Branch,] #60
|
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-11-24 21:40:22 +01:00
|
|
|
assert_equal Syscall , produced.next(29).class
|
2019-09-09 10:47:37 +02:00
|
|
|
assert_equal :died , produced.next(29).name
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
def test_load_address
|
|
|
|
produced = produce_body
|
2019-08-23 14:31:04 +02:00
|
|
|
assert_equal LoadConstant , produced.next(26).class
|
|
|
|
assert_equal Parfait::Factory , produced.next(26).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
|
2019-08-23 18:24:18 +02:00
|
|
|
assert_equal DynamicJump , produced.next(51).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
|
2018-11-24 21:40:22 +01:00
|
|
|
assert_equal Label , produced.next(36).class
|
|
|
|
assert_equal produced.next(36) , produced.next(6).label
|
2018-03-21 17:28:43 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|