2018-03-24 16:55:01 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class InterpreterDynamicCall < MiniTest::Test
|
|
|
|
include Ticker
|
|
|
|
|
|
|
|
def setup
|
2019-09-13 13:07:12 +02:00
|
|
|
@preload = "Integer.div4"
|
2018-04-19 09:00:55 +02:00
|
|
|
@string_input = as_main("a = 5 ; return a.div4")
|
2018-03-24 16:55:01 +01:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_chain
|
2020-03-14 13:05:23 +01:00
|
|
|
#show_main_ticks # get output of what is
|
2020-03-22 09:42:50 +01:00
|
|
|
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, SlotToReg, #5
|
2019-08-23 14:31:22 +02:00
|
|
|
SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, #10
|
|
|
|
LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #15
|
|
|
|
SlotToReg, LoadConstant, OperatorInstruction, IsZero, SlotToReg, #20
|
2020-03-22 14:58:19 +01:00
|
|
|
OperatorInstruction, IsZero, RegToSlot, LoadConstant, Branch, #25
|
2020-03-14 13:05:23 +01:00
|
|
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #30
|
|
|
|
RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, #35
|
|
|
|
RegToSlot, SlotToReg, DynamicJump, LoadConstant, LoadConstant, #40
|
|
|
|
SlotToReg, OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, #45
|
2019-09-17 15:08:49 +02:00
|
|
|
SlotToReg, SlotToReg, LoadData, OperatorInstruction, RegToSlot, #50
|
|
|
|
RegToSlot, SlotToReg, RegToSlot, Branch, SlotToReg, #55
|
2020-03-14 13:05:23 +01:00
|
|
|
Branch, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #60
|
2019-09-17 15:08:49 +02:00
|
|
|
FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #65
|
2020-03-14 13:05:23 +01:00
|
|
|
SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn, #70
|
2020-03-22 09:42:50 +01:00
|
|
|
Transfer, SlotToReg, SlotToReg, Transfer, Syscall, #75
|
|
|
|
NilClass,] #80
|
2020-03-15 09:39:09 +01:00
|
|
|
assert_equal ::Integer , get_return.class
|
|
|
|
assert_equal 1 , get_return
|
2018-03-24 16:55:01 +01:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_load_entry
|
2019-08-23 09:20:39 +02:00
|
|
|
call_ins = main_ticks(3)
|
2018-04-08 21:30:18 +02:00
|
|
|
assert_equal LoadConstant , call_ins.class
|
|
|
|
assert_equal Parfait::CacheEntry , call_ins.constant.class
|
2018-04-03 11:55:28 +02:00
|
|
|
end
|
2020-03-14 13:05:23 +01:00
|
|
|
def test_dyn
|
2019-09-17 15:08:49 +02:00
|
|
|
cal = main_ticks(38)
|
2018-04-02 15:36:43 +02:00
|
|
|
assert_equal DynamicJump , cal.class
|
|
|
|
end
|
2018-03-24 16:55:01 +01:00
|
|
|
end
|
|
|
|
end
|