2018-05-17 08:31:36 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestInterpreterPlatform < MiniTest::Test
|
|
|
|
def setup
|
|
|
|
@inter = Platform.for("Interpreter")
|
|
|
|
end
|
|
|
|
def test_platform_class
|
|
|
|
assert_equal Risc::InterpreterPlatform , @inter.class
|
|
|
|
end
|
|
|
|
def test_platform_translator_class
|
|
|
|
assert_equal Risc::IdentityTranslator , @inter.translator.class
|
|
|
|
end
|
|
|
|
def test_platform_loaded_class
|
2019-02-07 17:24:35 +01:00
|
|
|
assert_equal ::Integer , @inter.loaded_at.class
|
2018-05-17 08:31:36 +02:00
|
|
|
end
|
|
|
|
def test_translator
|
|
|
|
assert IdentityTranslator.new
|
|
|
|
end
|
2020-02-26 18:01:01 +01:00
|
|
|
def test_registers
|
|
|
|
assert_equal 16 , @inter.num_registers
|
|
|
|
end
|
2018-05-17 08:31:36 +02:00
|
|
|
end
|
2018-05-17 08:49:01 +02:00
|
|
|
class TestIdentityTranslator < MiniTest::Test
|
2018-05-17 08:31:36 +02:00
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-07-02 22:20:54 +02:00
|
|
|
Risc.boot!
|
2018-05-17 08:31:36 +02:00
|
|
|
@translator = IdentityTranslator.new
|
|
|
|
end
|
|
|
|
|
2018-05-24 18:20:06 +02:00
|
|
|
def test_load_translates_label
|
2018-05-29 19:26:00 +02:00
|
|
|
label = Risc.label("test" , "test",nil)
|
2020-03-13 14:49:36 +01:00
|
|
|
load = Risc.load_constant("source" , label )
|
2018-05-24 18:20:06 +02:00
|
|
|
translated = @translator.translate(load)
|
|
|
|
assert label != translated.constant
|
|
|
|
end
|
2018-05-17 08:31:36 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|