rubyx/test/risc/interpreter/test_plus.rb

60 lines
1.9 KiB
Ruby
Raw Normal View History

require_relative "helper"
module Risc
class InterpreterPlusTest < MiniTest::Test
2017-01-03 21:42:40 +01:00
include Ticker
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
2018-03-30 17:05:38 +02:00
def est_add
show_ticks # get output of what is
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]
#assert_equal 10 , get_return
2017-01-03 21:42:40 +01:00
end
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
def pest_zero
2017-01-03 21:42:40 +01:00
ticks( 12 )
assert @interpreter.flags[:zero]
end
end
end