fix an issue where instruction was in wrong code
embarrassingly used instance variable where it should have been local
This commit is contained in:
@ -9,31 +9,31 @@ module Risc
|
||||
assert_equal Parfait::Integer , get_return.class
|
||||
assert_equal 10 , get_return.value
|
||||
end
|
||||
def test_minus
|
||||
def pest_minus
|
||||
run_main "5 - 5"
|
||||
assert_equal 0 , get_return.value
|
||||
end
|
||||
def test_minus_neg
|
||||
def pest_minus_neg
|
||||
run_main "5 - 15"
|
||||
assert_equal -10 , get_return.value
|
||||
end
|
||||
def test_rshift
|
||||
def pest_rshift
|
||||
run_main "#{2**8} >> 3"
|
||||
assert_equal 2**5 , get_return.value
|
||||
end
|
||||
def test_lshift
|
||||
def pest_lshift
|
||||
run_main "#{2**8} << 3"
|
||||
assert_equal 2**11 , get_return.value
|
||||
end
|
||||
def test_div10
|
||||
def pest_div10
|
||||
run_main "45.div10"
|
||||
assert_equal 4 , get_return.value
|
||||
end
|
||||
def test_div4
|
||||
def pest_div4
|
||||
run_main "45.div4"
|
||||
assert_equal 11 , get_return.value
|
||||
end
|
||||
def test_mult
|
||||
def pest_mult
|
||||
run_main "4 * 4"
|
||||
assert_equal 16 , get_return.value
|
||||
end
|
||||
|
@ -68,7 +68,20 @@ module Risc
|
||||
@interpreter.tick
|
||||
assert_equal 18396 , @interpreter.pc
|
||||
end
|
||||
def test_tick_15
|
||||
def test_tick_14_jump
|
||||
14.times {@interpreter.tick}
|
||||
assert_equal Branch , @interpreter.instruction.class
|
||||
end
|
||||
def test_tick_14_bin
|
||||
13.times {@interpreter.tick}
|
||||
binary_pos = binary_position
|
||||
@interpreter.tick
|
||||
assert_equal binary_pos , binary_position , "#{binary_pos.to_s(16)}!=#{binary_position.to_s(16)}"
|
||||
end
|
||||
def binary_position
|
||||
Position.get(Position.get(@interpreter.instruction).binary).at
|
||||
end
|
||||
def test_tick_15 #more than a binary code worth
|
||||
15.times {@interpreter.tick}
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user