rubyx/test/risc/instructions/test_slot_to_reg.rb
Torsten 6267bf3ad0 fix slot_to_reg to allow register indexes
we mostly use pre-calculated indexes, ie integers
but registers are allowed (in arm/risc), so we try to check the registers type at least is right.
The return is really a machine word, but we call it Object (yes, more work that way)
2020-03-22 14:31:43 +02:00

27 lines
661 B
Ruby

require_relative "../helper"
module Risc
class TestSlotToReg < MiniTest::Test
def setup
Parfait.boot!({})
end
def slot
Risc.slot_to_reg("source" , Risc.message_named_reg , :type)
end
def test_slot
assert_equal SlotToReg , slot.class
end
def test_slot_reg
assert_equal :"message.type" , slot.register.symbol
end
def test_reg_as_index
reg = RegisterValue.new(:name , :Integer)
Risc.slot_to_reg("source" , Risc.message_named_reg , reg)
end
def test_reg_as_index_fail
reg = Risc.message_named_reg
assert_raises {Risc.slot_to_reg("source" , reg , reg)}
end
end
end