2018-07-31 17:00:42 +02:00
|
|
|
module Minitest
|
2018-04-05 19:10:00 +02:00
|
|
|
module Assertions
|
|
|
|
def assert_slot_to_reg( slot , array = nil, index = nil , register = nil)
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_equal Risc::SlotToReg , slot.class
|
2018-04-05 19:37:03 +02:00
|
|
|
assert_equal( array , slot.array.symbol , "wrong source register") if array
|
|
|
|
assert_equal( index , slot.index, "wrong source index") if index
|
|
|
|
assert_equal( register , slot.register.symbol, "wrong destination") if register
|
|
|
|
end
|
|
|
|
def assert_reg_to_slot( slot , register = nil, array = nil, index = nil )
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_equal Risc::RegToSlot , slot.class
|
2018-04-05 19:37:03 +02:00
|
|
|
assert_equal( register , slot.register.symbol, "wrong source register") if register
|
|
|
|
assert_equal( array , slot.array.symbol, "wrong destination register") if array
|
|
|
|
assert_equal( index , slot.index, "wrong destination index") if index
|
2018-04-05 19:10:00 +02:00
|
|
|
end
|
|
|
|
def assert_load(load , clazz = nil , register = nil)
|
2018-07-31 17:00:42 +02:00
|
|
|
assert_equal Risc::LoadConstant , load.class
|
2018-04-05 19:10:00 +02:00
|
|
|
assert_equal( clazz , load.constant.class) if clazz
|
2018-04-05 19:37:03 +02:00
|
|
|
assert_equal( register , load.register.symbol, "wrong destination register") if register
|
2018-04-05 19:10:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|