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