2020-03-17 20:46:57 +01:00
|
|
|
require_relative "../helper"
|
2018-07-02 22:03:00 +02:00
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestMachinePos < MiniTest::Test
|
|
|
|
def setup
|
2018-09-02 12:57:19 +02:00
|
|
|
code = "class Space; def main(arg);a = 1;return a;end;end"
|
2019-08-12 23:13:29 +02:00
|
|
|
@linker = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_binary(code, :arm)
|
2018-07-02 22:03:00 +02:00
|
|
|
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
|
2018-07-04 07:28:29 +02:00
|
|
|
def test_one_main
|
2018-07-30 09:23:42 +02:00
|
|
|
mains = @linker.assemblers.find_all{|asm| asm.callable.name == :main }
|
2018-07-04 07:28:29 +02:00
|
|
|
assert_equal 1 , mains.length
|
|
|
|
end
|
2019-09-10 13:49:02 +02:00
|
|
|
def test_assembler_num
|
2019-09-15 14:13:11 +02:00
|
|
|
assert_equal 3 , @linker.assemblers.length
|
2018-07-04 07:28:29 +02:00
|
|
|
end
|
2018-07-02 22:03:00 +02:00
|
|
|
end
|
|
|
|
end
|