2018-05-17 08:31:36 +02:00
|
|
|
require_relative "helper"
|
2018-03-25 18:38:59 +02:00
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestTranslator < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@machine = Risc.machine.boot
|
|
|
|
@translator = Arm::Translator.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_translate_label
|
|
|
|
label = Parfait.object_space.get_main.risc_instructions
|
2018-05-01 18:19:37 +02:00
|
|
|
assert_equal "Space_Type.main" ,label.to_cpu(@translator).name , label
|
2018-03-25 18:38:59 +02:00
|
|
|
end
|
2018-03-26 18:43:03 +02:00
|
|
|
|
|
|
|
def test_translate_space
|
2018-05-16 20:00:14 +02:00
|
|
|
assert @machine.translate(:arm)
|
2018-03-26 18:43:03 +02:00
|
|
|
end
|
2018-03-28 10:37:17 +02:00
|
|
|
|
|
|
|
def test_no_loops_in_chain
|
2018-05-16 20:00:14 +02:00
|
|
|
@machine.translate(:arm)
|
2018-03-28 10:37:17 +02:00
|
|
|
@machine.position_all
|
|
|
|
init = Parfait.object_space.get_init
|
|
|
|
all = []
|
|
|
|
init.cpu_instructions.each do |ins|
|
|
|
|
assert !all.include?(ins)
|
|
|
|
all << ins
|
|
|
|
end
|
|
|
|
end
|
2018-03-28 12:00:03 +02:00
|
|
|
def test_no_risc #by assembling, risc doesnt have assemble method
|
2018-05-16 20:00:14 +02:00
|
|
|
@machine.translate(:arm)
|
2018-03-28 10:37:17 +02:00
|
|
|
@machine.position_all
|
|
|
|
@machine.objects.each do |id , method|
|
|
|
|
next unless method.is_a? Parfait::TypedMethod
|
|
|
|
method.cpu_instructions.each do |ins|
|
2018-05-08 19:22:04 +02:00
|
|
|
ins.assemble(DevNull.new)
|
2018-03-28 10:37:17 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-28 11:50:07 +02:00
|
|
|
|
2018-03-25 18:38:59 +02:00
|
|
|
end
|
|
|
|
end
|