better way to test object registers
also some cleaning, by using more helpers
This commit is contained in:
@ -20,32 +20,17 @@ module SlotMachine
|
||||
assert_equal Risc::RegToSlot , @instructions.next(3).class
|
||||
assert_equal NilClass , @instructions.next(4).class
|
||||
end
|
||||
def test_ins_next_reg
|
||||
assert_equal :"message.caller.type" , @instructions.next.register.symbol
|
||||
def test_ins
|
||||
assert_slot_to_reg @instructions ,:message , 6 , "message.caller"
|
||||
end
|
||||
def test_ins_next_arr
|
||||
assert_equal :"message.caller" , @instructions.next.array.symbol
|
||||
def test_ins_next
|
||||
assert_slot_to_reg @instructions.next ,"message.caller" , 0 , "message.caller.type"
|
||||
end
|
||||
def test_ins_next_index
|
||||
assert_equal 0 , @instructions.next.index
|
||||
def test_ins_next_2
|
||||
assert_slot_to_reg @instructions.next(2) , :message , 6 , "message.caller"
|
||||
end
|
||||
def test_ins_next_2_reg
|
||||
assert_equal :"message.caller" , @instructions.next(2).register.symbol
|
||||
end
|
||||
def test_ins_next_2_arr
|
||||
assert_equal :"message" , @instructions.next(2).array.symbol
|
||||
end
|
||||
def test_ins_next_2_index
|
||||
assert_equal 6 , @instructions.next(2).index
|
||||
end
|
||||
def test_ins_next_3_reg
|
||||
assert_equal :"message.caller.type" , @instructions.next(3).register.symbol
|
||||
end
|
||||
def test_ins_next_3_arr
|
||||
assert_equal :"message.caller" , @instructions.next(3).array.symbol
|
||||
end
|
||||
def test_ins_next_3_index
|
||||
assert_equal 0 , @instructions.next(3).index
|
||||
def test_ins_next_3
|
||||
assert_reg_to_slot @instructions.next(3) ,"message.caller.type" , "message.caller" , 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -17,34 +17,18 @@ module SlotMachine
|
||||
assert_equal Risc::SlotToReg , @instructions.class
|
||||
assert_equal Risc::LoadConstant, @instructions.next.class
|
||||
end
|
||||
|
||||
def test_ins_next_class
|
||||
assert_equal Risc::RegToSlot , @instructions.next(2).class
|
||||
assert_equal NilClass , @instructions.next(3).class
|
||||
end
|
||||
def test_ins_load
|
||||
assert @instructions.next.register.is_object?
|
||||
assert_equal Parfait::CacheEntry , @instructions.next.constant.class
|
||||
def test_ins
|
||||
assert_slot_to_reg @instructions , :message , 0 , "message.type"
|
||||
end
|
||||
|
||||
def test_ins_next_reg
|
||||
assert_equal :"message.type" , @instructions.register.symbol
|
||||
def test_ins_next
|
||||
assert_load @instructions.next , Parfait::CacheEntry , "id_"
|
||||
end
|
||||
def test_ins_next_arr
|
||||
assert_equal :message , @instructions.array.symbol
|
||||
end
|
||||
def test_ins_next_index
|
||||
assert_equal 0 , @instructions.index
|
||||
end
|
||||
|
||||
def test_ins_next_2_reg
|
||||
assert_equal :"message.type" , @instructions.next(2).register.symbol
|
||||
end
|
||||
def test_ins_next_2_arr
|
||||
assert @instructions.next(2).array.is_object?
|
||||
end
|
||||
def test_ins_next_2_index
|
||||
assert_equal 1 , @instructions.next(2).index
|
||||
def test_ins_next_2
|
||||
assert_reg_to_slot @instructions.next(2) , :"message.type" , "id_", 1
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -14,26 +14,20 @@ module SlotMachine
|
||||
assert_slot_to_reg risc(1) ,:message , 6 , :"message.caller"
|
||||
end
|
||||
def test_2_load
|
||||
assert_load risc(2) , Parfait::FalseClass
|
||||
assert_load risc(2) , Parfait::FalseClass, "id_"
|
||||
end
|
||||
def test_3_op
|
||||
assert_equal Risc::OperatorInstruction , risc(3).class
|
||||
assert risc(3).left.is_object?
|
||||
assert_equal :"message.caller" , risc(3).right.symbol
|
||||
assert_equal :- , risc(3).operator
|
||||
assert_operator risc(3) , :- , "id_" , "message.caller"
|
||||
end
|
||||
def test_4_zero
|
||||
assert_equal Risc::IsZero , risc(4).class
|
||||
assert_label risc(4).label , "target"
|
||||
end
|
||||
def test_5_load
|
||||
assert_load risc(5) , Parfait::NilClass
|
||||
assert_load risc(5) , Parfait::NilClass , "id_"
|
||||
end
|
||||
def test_6_op
|
||||
assert_equal Risc::OperatorInstruction , risc(6).class
|
||||
assert risc(6).left.is_object?
|
||||
assert_equal :"message.caller" , risc(6).right.symbol
|
||||
assert_equal :- , risc(6).operator
|
||||
assert_operator risc(6), :- , "id_", "message.caller"
|
||||
end
|
||||
def test_7_zero
|
||||
assert_equal Risc::IsZero , risc(7).class
|
||||
|
Reference in New Issue
Block a user