use a constant for the binary code offset

where the instructions start
This commit is contained in:
Torsten Ruger
2018-05-23 21:35:22 +03:00
parent 8ca70a6835
commit 0293320bb8
4 changed files with 33 additions and 26 deletions

View File

@ -3,16 +3,16 @@ require_relative "helper"
module Risc
class TestInterpreterBasics < MiniTest::Test
def test_class
def pest_class
assert_equal Risc::Interpreter , Interpreter.new.class
end
def test_starts_stopped
def pest_starts_stopped
assert_equal :stopped , Interpreter.new.state
end
def test_has_regs
def pest_has_regs
assert_equal 12 , Interpreter.new.registers.length
end
def test_has_r0
def pest_has_r0
assert_equal :r0 , Interpreter.new.registers.keys.first
end
end
@ -23,14 +23,14 @@ module Risc
@machine.position_all
@interpreter = Interpreter.new
end
def test_starts
def pest_starts
assert_equal 0 , @interpreter.start_machine
end
def test_started
def pest_started
@interpreter.start_machine
assert_equal :running , @interpreter.state
end
def test_pos
def pest_pos
@interpreter.start_machine
assert_equal 1 , @interpreter.clock
end
@ -43,30 +43,33 @@ module Risc
@interpreter = Interpreter.new
@interpreter.start_machine
end
def test_tick1
def pest_tick1
assert_equal 2 , @interpreter.tick
end
def test_clock1
def pest_clock1
@interpreter.tick
assert_equal 2 , @interpreter.clock
end
def test_pc1
def pest_pc1
@interpreter.tick
assert_equal 19484 , @interpreter.pc
end
def test_tick2
def pest_tick2
@interpreter.tick
assert_equal 3 , @interpreter.tick
end
def test_clock2
def pest_clock2
@interpreter.tick
@interpreter.tick
assert_equal 3 , @interpreter.clock
end
def test_pc2
def pest_pc2
@interpreter.tick
@interpreter.tick
assert_equal 19488 , @interpreter.pc
end
def test_tick_15
15.times {@interpreter.tick}
end
end
end