rubyx/test/risc/test_position.rb
Torsten Ruger 8966a50a8a getter by position
extract and expand position testing
never return labels (that have the same position as their target)
2018-05-17 20:13:33 +03:00

54 lines
1.3 KiB
Ruby

require_relative "helper"
module Risc
class TestMachinePositions < MiniTest::Test
def setup
@machine = Risc.machine.boot
end
def test_cpu_init
@machine.translate(:interpreter)
@machine.position_all
assert Position.get @machine.cpu_init
end
def test_cpu_label
@machine.translate(:interpreter)
@machine.position_all
assert Position.get( @machine.cpu_init.label )
end
def test_cpu_first_arm
@machine.translate(:arm)
@machine.position_all
assert Position.get( @machine.cpu_init.first )
end
def test_has_arm_pos
has_positions(:arm)
end
def test_has_int_pos
has_positions(:interpreter)
end
def has_positions(platform)
@machine.translate(:arm)
@machine.position_all
@machine.objects.each do |id,obj|
assert Position.get(obj)
end
end
def test_has_arm_meth
meth_positions(:arm)
end
def test_has_int_meth
meth_positions(:interpreter)
end
def meth_positions(platform)
@machine.translate(:arm)
@machine.position_all
Parfait.object_space.each_type do |type|
type.each_method do |method|
assert Position.get(method.binary)
assert Position.get(method.cpu_instructions)
end
end
end
end
end