2018-05-12 17:32:10 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestPlaform < MiniTest::Test
|
|
|
|
|
2018-05-17 08:31:36 +02:00
|
|
|
def test_arm_factory_exists
|
2018-05-12 17:32:10 +02:00
|
|
|
assert Platform.for("Arm")
|
|
|
|
end
|
2018-05-17 08:31:36 +02:00
|
|
|
def test_inter_factory_exists
|
|
|
|
assert Platform.for("Interpreter")
|
|
|
|
end
|
2018-05-12 17:32:10 +02:00
|
|
|
def test_factory_raise
|
|
|
|
assert_raises{ Platform.for("NotArm")}
|
|
|
|
end
|
2020-03-18 14:27:40 +01:00
|
|
|
def test_allocate
|
2020-03-19 17:18:22 +01:00
|
|
|
allocator = Platform.for("Interpreter").allocator(FakeCompiler.new)
|
2020-03-18 14:27:40 +01:00
|
|
|
assert_equal FakeCompiler , allocator.compiler.class
|
|
|
|
end
|
2020-03-19 17:18:22 +01:00
|
|
|
def test_map_message
|
2020-03-22 10:29:56 +01:00
|
|
|
assert_equal :r13 , Platform.new.assign_reg?(:message)
|
2020-03-19 17:18:22 +01:00
|
|
|
end
|
|
|
|
def test_map_sys
|
|
|
|
assert_equal :r0 , Platform.new.assign_reg?(:syscall_1)
|
|
|
|
end
|
|
|
|
def test_map_id
|
|
|
|
assert_nil Platform.new.assign_reg?(:id_some_id)
|
|
|
|
end
|
|
|
|
def test_names_len
|
2020-03-22 10:29:56 +01:00
|
|
|
assert_equal 13 , Platform.new.register_names.length
|
2020-03-19 17:18:22 +01:00
|
|
|
end
|
|
|
|
def test_names_r
|
|
|
|
assert_equal "r" , Platform.new.register_names.first.to_s[0]
|
|
|
|
assert_equal "r" , Platform.new.register_names.last.to_s[0]
|
|
|
|
end
|
2018-05-12 17:32:10 +02:00
|
|
|
end
|
|
|
|
end
|