create return address as own class to hold return addresses
to distinguish from integer, which does not need adjusting
This commit is contained in:
@ -48,4 +48,18 @@ module Parfait
|
||||
assert_equal 1 , @int.value
|
||||
end
|
||||
end
|
||||
class AddressTest < ParfaitTest
|
||||
def test_address
|
||||
assert ReturnAddress.new(55)
|
||||
end
|
||||
def test_value
|
||||
assert_equal 55 , ReturnAddress.new(55).value
|
||||
end
|
||||
def test_value_set
|
||||
addr = ReturnAddress.new(55)
|
||||
addr.set_value(33)
|
||||
assert_equal 33 , addr.value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ module Risc
|
||||
ret = main_ticks(63)
|
||||
assert_equal FunctionReturn , ret.class
|
||||
assert_equal :r1 , ret.register.symbol
|
||||
assert_equal 19460 , @interpreter.get_register(ret.register)
|
||||
assert_equal 20612 , @interpreter.get_register(ret.register)
|
||||
end
|
||||
def test_sys
|
||||
sys = main_ticks(65)
|
||||
|
@ -52,7 +52,7 @@ module Risc
|
||||
end
|
||||
def test_pc1
|
||||
@interpreter.tick
|
||||
assert_equal 19224 , @interpreter.pc
|
||||
assert_equal 20376 , @interpreter.pc
|
||||
end
|
||||
def test_tick2
|
||||
@interpreter.tick
|
||||
@ -66,7 +66,7 @@ module Risc
|
||||
def test_pc2
|
||||
@interpreter.tick
|
||||
@interpreter.tick
|
||||
assert_equal 19228 , @interpreter.pc
|
||||
assert_equal 20380 , @interpreter.pc
|
||||
end
|
||||
def test_tick_14_jump
|
||||
14.times {@interpreter.tick}
|
||||
|
@ -17,6 +17,22 @@ module Risc
|
||||
def test_constant
|
||||
assert @machine.add_constant( Parfait::Integer.new(5) )
|
||||
end
|
||||
def test_address_get
|
||||
assert_equal Parfait::ReturnAddress , @machine.get_address.class
|
||||
end
|
||||
def test_address_is_constant
|
||||
addr = @machine.get_address
|
||||
assert @machine.constants.include?(addr)
|
||||
end
|
||||
def test_address_count
|
||||
addr = @machine.get_address
|
||||
count = 0
|
||||
while(addr)
|
||||
count += 1
|
||||
addr = addr.next_integer
|
||||
end
|
||||
assert_equal 5, count
|
||||
end
|
||||
end
|
||||
class TestMachineInit < MiniTest::Test
|
||||
def setup
|
||||
@ -29,10 +45,10 @@ module Risc
|
||||
assert_equal 0 , Position.get(@machine.cpu_init).at
|
||||
end
|
||||
def test_cpu_at
|
||||
assert_equal "0x5a54" , Position.get(@machine.cpu_init.first).to_s
|
||||
assert_equal "0x5ed4" , Position.get(@machine.cpu_init.first).to_s
|
||||
end
|
||||
def test_cpu_bin
|
||||
assert_equal "0x5a4c" , Position.get(Position.get(@machine.cpu_init.first).binary).to_s
|
||||
assert_equal "0x5ecc" , Position.get(Position.get(@machine.cpu_init.first).binary).to_s
|
||||
end
|
||||
def test_cpu_label
|
||||
assert_equal Position::InstructionPosition , Position.get(@machine.cpu_init.first).class
|
||||
|
Reference in New Issue
Block a user