introduce the LabeListener to move instructions along when first code position changes

This commit is contained in:
Torsten Ruger
2018-06-09 22:13:43 +03:00
parent ec1d38f5a6
commit c7ad1d98ca
7 changed files with 94 additions and 12 deletions

View File

@ -0,0 +1,25 @@
require_relative "helper"
module Risc
class TestLabelListener < MiniTest::Test
def setup
Risc.machine.boot
@label = Label.new("Hi","Ho" , FakeAddress.new(5))
@label_pos = Position.new(@label , -1)
@code = Parfait::BinaryCode.new(1)
@code_pos = Position.new(@code , -1)
@code_pos.position_listener( LabelListener.new(@label))
end
def test_move
@code_pos.set(0)
assert_equal 8 , @label_pos.at
end
def test_move_twice
@code_pos.set(0)
@code_pos.set(0x40)
assert_equal 72 , @label_pos.at
end
end
end