introduce the LabeListener to move instructions along when first code position changes
This commit is contained in:
25
test/risc/position/test_label_listener.rb
Normal file
25
test/risc/position/test_label_listener.rb
Normal 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
|
Reference in New Issue
Block a user