fix label positioning bug
where a label at the end of a binary code resulted in the label actually taking up a position, instead of sharing it with it's next
This commit is contained in:
@ -2,22 +2,28 @@ require_relative "helper"
|
||||
|
||||
module Risc
|
||||
class TestMachinePositions < MiniTest::Test
|
||||
def setup
|
||||
def setup_for(platform)
|
||||
@machine = Risc.machine.boot
|
||||
@machine.translate(platform)
|
||||
@machine.position_all
|
||||
end
|
||||
def test_cpu_init
|
||||
@machine.translate(:interpreter)
|
||||
@machine.position_all
|
||||
setup_for(:interpreter)
|
||||
assert Position.get @machine.cpu_init
|
||||
end
|
||||
def test_cpu_label
|
||||
@machine.translate(:interpreter)
|
||||
@machine.position_all
|
||||
setup_for(:interpreter)
|
||||
assert Position.get( @machine.cpu_init.label )
|
||||
end
|
||||
def test_label_positions_match
|
||||
setup_for(:interpreter)
|
||||
Position.positions.each do |object , position|
|
||||
next unless object.is_a?(Label) and object.next
|
||||
assert_equal position.at , Position.get(object.next).at
|
||||
end
|
||||
end
|
||||
def test_cpu_first_arm
|
||||
@machine.translate(:arm)
|
||||
@machine.position_all
|
||||
setup_for(:arm)
|
||||
assert Position.get( @machine.cpu_init.first )
|
||||
end
|
||||
def test_has_arm_pos
|
||||
@ -27,8 +33,7 @@ module Risc
|
||||
has_positions(:interpreter)
|
||||
end
|
||||
def has_positions(platform)
|
||||
@machine.translate(:arm)
|
||||
@machine.position_all
|
||||
setup_for(platform)
|
||||
@machine.objects.each do |id,obj|
|
||||
assert Position.get(obj)
|
||||
end
|
||||
@ -40,8 +45,7 @@ module Risc
|
||||
meth_positions(:interpreter)
|
||||
end
|
||||
def meth_positions(platform)
|
||||
@machine.translate(:arm)
|
||||
@machine.position_all
|
||||
setup_for(platform)
|
||||
Parfait.object_space.each_type do |type|
|
||||
type.each_method do |method|
|
||||
assert Position.get(method.binary)
|
||||
|
Reference in New Issue
Block a user