2018-05-17 19:13:33 +02:00
|
|
|
require_relative "helper"
|
2016-12-30 19:48:14 +01:00
|
|
|
|
2017-01-19 08:02:29 +01:00
|
|
|
module Risc
|
2018-07-04 07:28:29 +02:00
|
|
|
class TestLinkerObjects < MiniTest::Test
|
2016-12-30 19:48:14 +01:00
|
|
|
|
|
|
|
def setup
|
2018-06-29 23:39:23 +02:00
|
|
|
Parfait.boot!
|
2018-07-01 13:12:42 +02:00
|
|
|
Risc.boot!
|
2018-07-01 20:51:48 +02:00
|
|
|
@linker = Mom::MomCompiler.new.translate(:arm)
|
2016-12-30 19:48:14 +01:00
|
|
|
end
|
2018-03-27 17:47:39 +02:00
|
|
|
def test_objects
|
2018-07-01 20:51:48 +02:00
|
|
|
objects = @linker.object_positions
|
2018-03-27 17:47:39 +02:00
|
|
|
assert_equal Hash , objects.class
|
2018-03-27 18:06:16 +02:00
|
|
|
assert 350 < objects.length
|
2018-03-27 17:47:39 +02:00
|
|
|
end
|
2018-03-31 12:25:59 +02:00
|
|
|
def test_constant_fail
|
|
|
|
assert_raises {@machine.add_constant( 1 )}
|
|
|
|
end
|
2018-03-28 10:37:17 +02:00
|
|
|
end
|
2018-07-04 07:28:29 +02:00
|
|
|
class TestLinkerInit < MiniTest::Test
|
2018-04-30 12:28:55 +02:00
|
|
|
def setup
|
2018-07-04 08:18:55 +02:00
|
|
|
@linker = RubyX::RubyXCompiler.new("class Space;def main;return 1;end;end").ruby_to_binary(:arm)
|
2018-03-27 19:47:41 +02:00
|
|
|
end
|
2018-05-10 19:56:12 +02:00
|
|
|
def test_pos_cpu
|
2018-07-02 15:19:01 +02:00
|
|
|
assert_equal 0 , Position.get(@linker.cpu_init).at
|
2018-05-10 19:56:12 +02:00
|
|
|
end
|
|
|
|
def test_cpu_at
|
2018-07-07 14:50:43 +02:00
|
|
|
assert_equal "0x61ec" , Position.get(@linker.cpu_init.first).to_s
|
2018-05-10 19:56:12 +02:00
|
|
|
end
|
|
|
|
def test_cpu_label
|
2018-07-02 15:19:01 +02:00
|
|
|
assert_equal Position , Position.get(@linker.cpu_init.first).class
|
2018-05-10 19:56:12 +02:00
|
|
|
end
|
2018-05-28 10:45:04 +02:00
|
|
|
def test_first_binary_jump
|
|
|
|
bin = Parfait.object_space.get_init.binary
|
2018-05-28 14:09:59 +02:00
|
|
|
assert 0 != bin.get_word(Parfait::BinaryCode.data_length) , "index 0 is 0 #{bin.inspect}"
|
2018-05-28 10:45:04 +02:00
|
|
|
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
|
2018-06-09 21:13:43 +02:00
|
|
|
def test_positions_set
|
2018-07-02 15:19:01 +02:00
|
|
|
@linker.object_positions.each do |obj,position|
|
2018-07-04 08:18:55 +02:00
|
|
|
assert position.valid? , "#{position} #{position.object.class}, #{obj.object_id.to_s(16)}"
|
2018-06-09 21:13:43 +02:00
|
|
|
end
|
|
|
|
end
|
2016-12-30 19:48:14 +01:00
|
|
|
end
|
|
|
|
end
|