rubyx/test/slot_machine/instructions/helper.rb
Torsten db5a59f735 Unify instruction namings also dirs
Was getting confused myself, where it was instruction or instructions, when if the base class was inside or out of dir.
Now dirs are plural, and base class is inside.
2020-03-22 14:31:43 +02:00

41 lines
1.1 KiB
Ruby

require_relative '../helper'
module SlotMachine
# Most SlotMachineInstructionTests test the risc instructions of the slot instruction
# quite carefully, ie every instruction, every register.
#
# This is done with the assert methods in risc_assert
#
# Most tests go through instructions from top to bottom.
# For working code, one can get a list of those instructions by using the all_str as message
# Most tests will test for length and give the all_str as message to see where it went wrong
# like: assert_equal 8 , all.length , all_str
class SlotMachineInstructionTest < MiniTest::Test
include Output
def setup
Parfait.boot!(Parfait.default_test_options)
@instruction = instruction
@compiler = Risc::MethodCompiler.new(Risc::FakeCallable.new , Label.new("source","start"))
@instruction.to_risc(@compiler)
@risc = @compiler.risc_instructions
end
def risc(at)
return @risc if at == 0
@risc.next( at )
end
def all
ret = []
@risc.each {|i| ret << i}
ret
end
def all_str
class_list(all.collect{|i|i.class})
end
end
end