rubyx/test/risc/interpreter/test_change.rb
Torsten Ruger 5fe0ba06ab stash old vm
moving on to getting mom to work and can’t have both
interpreter and elf broke, about 100 tests  went
2018-03-11 17:02:42 +05:30

49 lines
1.4 KiB
Ruby

require_relative "helper"
module Risc
class AddChange < MiniTest::Test
include Ticker
def setup
@input = s(:statements, s(:return, s(:operator_value, :+, s(:int, 5), s(:int, 7))))
@state_events = {}
@instruction_events = []
super
end
def state_changed( a , b)
@state_events[:state_changed] = [a , b]
end
def instruction_changed(was , is )
@instruction_events << was
end
def pest_state_change
@interpreter.register_event :state_changed , self
ticks 30
assert @state_events[:state_changed]
assert_equal 2 , @state_events[:state_changed].length
assert_equal :running, @state_events[:state_changed][0]
@interpreter.unregister_event :state_changed , self
end
def pest_instruction_events
@interpreter.register_event :instruction_changed , self
ticks 30
assert_equal 20 , @instruction_events.length
@interpreter.unregister_event :instruction_changed , self
end
def pest_chain
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
LoadConstant, OperatorInstruction, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, Label, FunctionReturn, RiscTransfer, Syscall,
NilClass]
end
end
end