2019-08-08 11:19:27 +02:00
|
|
|
require_relative "helper"
|
|
|
|
module Risc
|
|
|
|
class TestCallableCompiler < MiniTest::Test
|
2020-02-27 10:57:18 +01:00
|
|
|
def setup
|
|
|
|
Parfait.boot!({})
|
2020-02-28 11:54:17 +01:00
|
|
|
@compiler = Risc.test_compiler
|
2020-02-27 10:57:18 +01:00
|
|
|
end
|
|
|
|
def test_ok
|
|
|
|
assert @compiler
|
|
|
|
end
|
|
|
|
def test_current
|
|
|
|
assert @compiler.current
|
|
|
|
end
|
|
|
|
def test_current_label
|
|
|
|
assert_equal Label , @compiler.current.class
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal "start_label" , @compiler.current.name
|
2020-02-27 10:57:18 +01:00
|
|
|
end
|
|
|
|
def test_slot
|
|
|
|
assert @compiler.risc_instructions
|
|
|
|
end
|
|
|
|
def test_const
|
|
|
|
assert_equal Array , @compiler.constants.class
|
|
|
|
end
|
2020-03-01 09:52:21 +01:00
|
|
|
def test_load_class
|
|
|
|
object = @compiler.load_object(Parfait.object_space)
|
|
|
|
assert_equal RegisterValue , object.class
|
|
|
|
assert object.is_object?
|
2019-08-08 11:19:27 +02:00
|
|
|
end
|
2020-03-01 09:52:21 +01:00
|
|
|
def test_load_code
|
|
|
|
object = @compiler.load_object(Parfait.object_space)
|
|
|
|
assert_equal LoadConstant , @compiler.current.class
|
|
|
|
assert_equal Parfait::Space , @compiler.current.constant.class
|
2019-08-08 11:19:27 +02:00
|
|
|
end
|
2020-03-08 11:05:25 +01:00
|
|
|
def test_load_data
|
|
|
|
object = @compiler.load_object(1)
|
|
|
|
assert_equal LoadData , @compiler.current.class
|
|
|
|
assert_equal Integer , @compiler.current.constant.class
|
|
|
|
end
|
2019-08-08 11:19:27 +02:00
|
|
|
end
|
|
|
|
end
|