2015-11-08 13:30:28 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2018-03-30 16:09:02 +02:00
|
|
|
class InterpreterPlusTest < MiniTest::Test
|
2017-01-03 21:42:40 +01:00
|
|
|
include Ticker
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2017-01-03 21:42:40 +01:00
|
|
|
def setup
|
2018-03-30 17:05:38 +02:00
|
|
|
@string_input = as_main("a = 5 + 5")
|
2017-01-03 21:42:40 +01:00
|
|
|
super
|
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2018-03-30 17:05:38 +02:00
|
|
|
def est_add
|
|
|
|
show_ticks # get output of what is
|
2018-03-30 16:09:02 +02:00
|
|
|
check_chain [Branch, Label, LoadConstant, SlotToReg, LoadConstant,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
|
|
|
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall,
|
2018-03-30 17:05:38 +02:00
|
|
|
Label, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
|
|
|
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
|
|
|
|
RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg,
|
|
|
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
|
|
|
LoadConstant, SlotToReg, SlotToReg]
|
2018-03-30 16:09:02 +02:00
|
|
|
#assert_equal 10 , get_return
|
2017-01-03 21:42:40 +01:00
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2018-03-30 17:05:38 +02:00
|
|
|
def est_slot3
|
|
|
|
sl = ticks( 49 )
|
|
|
|
assert_equal SlotToReg , sl.class
|
|
|
|
assert_equal :r2 , sl.array.symbol #load from message
|
|
|
|
assert_equal 9 , sl.index
|
|
|
|
assert_equal :r3 , sl.register.symbol
|
|
|
|
end
|
|
|
|
def test_slot2 #load arg from args
|
|
|
|
sl = ticks( 48 )
|
|
|
|
assert_equal SlotToReg , sl.class
|
|
|
|
assert_equal :r2 , sl.array.symbol #load from message
|
|
|
|
assert_equal 9 , sl.index
|
|
|
|
assert_equal :r3 , sl.register.symbol
|
|
|
|
end
|
|
|
|
def est_slot1 #load args from message
|
|
|
|
sl = ticks( 47 )
|
|
|
|
assert_equal SlotToReg , sl.class
|
|
|
|
assert_equal :r0 , sl.array.symbol #load from message
|
|
|
|
assert_equal 2 , sl.index
|
|
|
|
assert_equal :r2 , sl.register.symbol
|
|
|
|
end
|
|
|
|
def est_load_2
|
|
|
|
lod = ticks( 46 )
|
|
|
|
assert_equal LoadConstant , lod.class
|
|
|
|
assert_equal 5 , lod.constant.value
|
2017-01-03 21:42:40 +01:00
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
|
2018-03-11 12:32:42 +01:00
|
|
|
def pest_zero
|
2017-01-03 21:42:40 +01:00
|
|
|
ticks( 12 )
|
|
|
|
assert @interpreter.flags[:zero]
|
|
|
|
end
|
2015-11-08 14:15:55 +01:00
|
|
|
end
|
2015-11-08 13:30:28 +01:00
|
|
|
end
|