2018-05-15 18:29:27 +02:00
|
|
|
require_relative '../helper'
|
|
|
|
|
|
|
|
module Mom
|
|
|
|
class InstructionMock < Instruction
|
2019-08-10 20:59:31 +02:00
|
|
|
def initialize
|
|
|
|
super("mocking")
|
|
|
|
end
|
2018-05-15 18:29:27 +02:00
|
|
|
end
|
2019-09-15 16:44:35 +02:00
|
|
|
|
2019-09-17 12:52:20 +02:00
|
|
|
# Most MomInstructionTests test the risc instructions of the mom 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
|
2019-09-15 16:44:35 +02:00
|
|
|
class MomInstructionTest < MiniTest::Test
|
|
|
|
include Output
|
|
|
|
def setup
|
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
|
|
|
@instruction = instruction
|
2019-09-15 17:31:10 +02:00
|
|
|
@compiler = Risc::MethodCompiler.new(Risc::FakeCallable.new , Label.new("source","start"))
|
2019-09-15 16:44:35 +02:00
|
|
|
@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
|
|
|
|
|
2018-05-15 18:29:27 +02:00
|
|
|
end
|