better test for add

This commit is contained in:
Torsten Ruger 2015-08-09 00:53:04 +03:00
parent bae7f5dcb1
commit 4e56056b62
2 changed files with 10 additions and 5 deletions

View File

@ -7,11 +7,11 @@ module Register
plus_function = Virtual::MethodSource.create_method(:Integer,:plus , [:Integer] )
plus_function.source.return_type = Virtual::Integer
plus_function.source.receiver = Virtual::Integer
tmp = Register.tmp_reg
index = Register.arg_index 1
plus_function.source.add_code Register.get_slot( plus_function , :message , index , tmp )
add = Register::OperatorInstruction.new( plus_function, :add , tmp , Register.self_reg )
add = Register::OperatorInstruction.new( plus_function, :add , Register.self_reg , tmp )
plus_function.source.add_code add
return plus_function
end

View File

@ -47,11 +47,16 @@ class AddTest < MiniTest::Test
def test_adding
done = ticks(23)
assert_equal Register::OperatorInstruction , done.class
assert @interpreter.get_register done.left.symbol
puts @interpreter.get_register(done.left.symbol).class
left = @interpreter.get_register(done.left)
rr = done.right
right = @interpreter.get_register(rr)
assert_equal Fixnum , left.class
assert_equal Fixnum , right.class
assert_equal 5 , right
done = ticks(1)
assert_equal Register::RegisterTransfer , done.class
assert @interpreter.get_register done.from.symbol
result = @interpreter.get_register(rr)
assert_equal result , left + right
end
def test_chain