better way to test object registers

also some cleaning, by using more helpers
This commit is contained in:
2020-03-02 17:50:03 +02:00
parent ece1e8c87b
commit d0036ed95b
8 changed files with 73 additions and 136 deletions

View File

@ -9,10 +9,7 @@ module Risc
Risc.load_constant("source" , const)
end
def test_const
assert_equal LoadConstant , load.class
end
def test_const_reg
assert load.register.is_object?
assert_load load , SlotMachine::StringConstant , "id_"
end
end
class TestLoadConstant1 < MiniTest::Test
@ -23,10 +20,7 @@ module Risc
Risc.load_constant("source" , const)
end
def test_parf
assert_equal LoadConstant , load.class
end
def test_parf_reg
assert load.register.is_object?
assert_load load , Parfait::Word , "id_"
end
end
end

View File

@ -52,10 +52,11 @@ module Risc
end
def test_operator
ret = @r0.op :<< , @r1
assert_equal OperatorInstruction , ret.class
assert_equal @r0 , ret.left
assert_equal @r1 , ret.right
assert_equal :<< , ret.operator
assert_operator ret , :<< , :message , "id_"
end
def test_operator_slot
ret = @r0.op :<< , @r1[:type]
assert_operator ret , :<< , :message , "id_.type"
end
def test_byte_to_reg
instr = @r0 <= @r1[1]
@ -66,10 +67,7 @@ module Risc
end
def test_slot_to_reg
instr = @r0 << @r2[:next_object]
assert_equal SlotToReg , instr.class
assert_equal :message , instr.register.symbol
assert_equal 2 , instr.index
assert instr.array.is_object?
assert_slot_to_reg instr , "id_" , 2 , :message
end
def test_reg_to_byte
instr = @r1[1] <= @r0