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

@ -11,7 +11,7 @@ module Register
tmp = Register.tmp_reg tmp = Register.tmp_reg
index = Register.arg_index 1 index = Register.arg_index 1
plus_function.source.add_code Register.get_slot( plus_function , :message , index , tmp ) 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 plus_function.source.add_code add
return plus_function return plus_function
end end

View File

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