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
|
@ -34,6 +34,18 @@ module Risc
|
||||
assert_equal 5, count
|
||||
end
|
||||
end
|
||||
class TestMachinePos < MiniTest::Test
|
||||
def setup
|
||||
@machine = Risc.machine.boot
|
||||
@machine.translate(:arm)
|
||||
@machine.position_all
|
||||
end
|
||||
def test_positions_set
|
||||
@machine.objects.each do |id,obj|
|
||||
assert Position.get(obj).valid? , "#{Position.get(obj)} , #{obj.object_id.to_s(16)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
class TestMachineInit < MiniTest::Test
|
||||
def setup
|
||||
@machine = Risc.machine.boot
|
||||
@ -45,10 +57,7 @@ module Risc
|
||||
assert_equal 0 , Position.get(@machine.cpu_init).at
|
||||
end
|
||||
def test_cpu_at
|
||||
assert_equal "0x5e08" , Position.get(@machine.cpu_init.first).to_s
|
||||
end
|
||||
def pest_cpu_bin
|
||||
assert_equal "0x5ecc" , Position.get(@machine.cpu_init).to_s
|
||||
assert_equal "0x5eb4" , Position.get(@machine.cpu_init.first).to_s
|
||||
end
|
||||
def test_cpu_label
|
||||
assert_equal Position , Position.get(@machine.cpu_init.first).class
|
||||
@ -61,5 +70,11 @@ module Risc
|
||||
bin = Parfait.object_space.get_init.binary.next
|
||||
assert 0 != bin.get_word(0) , "index 0 is 0 #{bin.inspect}"
|
||||
end
|
||||
def test_positions_set
|
||||
@machine.objects.each do |id,obj|
|
||||
assert Position.get(obj).valid? , "#{Position.get(obj)} , #{obj.object_id.to_s(16)}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user