rubyx/test/risc/test_linker.rb
Torsten Ruger 474cd4b348 linker and collector test work again
had to give space a fixed number of addresses
2018-07-02 16:19:01 +03:00

66 lines
1.8 KiB
Ruby

require_relative "helper"
module Risc
class TestMachineObjects < MiniTest::Test
def setup
Parfait.boot!
Risc.boot!
@linker = Mom::MomCompiler.new.translate(:arm)
end
def test_objects
objects = @linker.object_positions
assert_equal Hash , objects.class
assert 350 < objects.length
end
def test_constant_fail
assert_raises {@machine.add_constant( 1 )}
end
end
class TestMachinePos < MiniTest::Test
def setup
Parfait.boot!
Risc.boot!
@linker = Mom::MomCompiler.new.translate(:arm)
@linker.position_all
end
def test_positions_set
@linker.object_positions.each do |obj , position|
assert Position.get(obj).valid? , "#{Position.get(obj)} , #{obj.object_id.to_s(16)}"
end
end
end
class TestMachineInit < MiniTest::Test
def setup
Parfait.boot!
Risc.boot!
@linker = Mom::MomCompiler.new.translate(:arm)
@linker.position_all
@linker.create_binary
end
def test_pos_cpu
assert_equal 0 , Position.get(@linker.cpu_init).at
end
def test_cpu_at
assert_equal "0x624c" , Position.get(@linker.cpu_init.first).to_s
end
def test_cpu_label
assert_equal Position , Position.get(@linker.cpu_init.first).class
end
def test_first_binary_jump
bin = Parfait.object_space.get_init.binary
assert 0 != bin.get_word(Parfait::BinaryCode.data_length) , "index 0 is 0 #{bin.inspect}"
end
def test_second_binary_first
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
@linker.object_positions.each do |obj,position|
assert position.valid? , "#{position} , #{obj.object_id.to_s(16)}"
end
end
end
end