2018-08-06 09:11:12 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestBuilderInfer < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
|
|
|
Parfait.boot!
|
|
|
|
Risc.boot!
|
|
|
|
@init = Parfait.object_space.get_init
|
|
|
|
@compiler = Risc::MethodCompiler.new( @init )
|
2018-08-19 12:16:07 +02:00
|
|
|
@builder = @compiler.builder(@init)
|
2018-08-06 09:11:12 +02:00
|
|
|
end
|
|
|
|
def test_list
|
|
|
|
assert_equal :List , @builder.infer_type(:list).class_name
|
|
|
|
end
|
|
|
|
def test_name
|
|
|
|
assert_equal :Word , @builder.infer_type(:name).class_name
|
|
|
|
end
|
|
|
|
def test_word
|
|
|
|
assert_equal :Word , @builder.infer_type(:word).class_name
|
|
|
|
end
|
|
|
|
def test_caller
|
|
|
|
assert_equal :Message , @builder.infer_type(:caller).class_name
|
|
|
|
end
|
|
|
|
def test_caller_reg
|
|
|
|
assert_equal :Message , @builder.infer_type(:caller_reg).class_name
|
|
|
|
end
|
2018-08-15 18:59:17 +02:00
|
|
|
def test_define_twice
|
|
|
|
@builder.caller_reg!
|
|
|
|
assert_raises{ @builder.caller_reg! }
|
|
|
|
end
|
|
|
|
def test_define_conditionally_first
|
|
|
|
assert_equal :r1 , @builder.caller_reg?.symbol
|
|
|
|
end
|
|
|
|
def test_define_conditionally_again
|
|
|
|
first = @builder.caller_reg!
|
|
|
|
assert_equal first , @builder.caller_reg?
|
|
|
|
end
|
2018-08-13 17:02:34 +02:00
|
|
|
def test_caller_tmp
|
|
|
|
assert_equal :Message , @builder.infer_type(:caller_tmp).class_name
|
|
|
|
end
|
2018-08-06 09:11:12 +02:00
|
|
|
def test_caller_obj
|
|
|
|
assert_equal :Message , @builder.infer_type(:caller_obj).class_name
|
|
|
|
end
|
2018-08-15 17:18:21 +02:00
|
|
|
def test_caller_const
|
|
|
|
assert_equal :Message , @builder.infer_type(:caller_const).class_name
|
|
|
|
end
|
|
|
|
def test_caller_self
|
|
|
|
assert_equal :Message , @builder.infer_type(:caller_self).class_name
|
|
|
|
end
|
|
|
|
def test_caller_1
|
|
|
|
assert_equal :Message , @builder.infer_type(:caller_1).class_name
|
|
|
|
end
|
2018-08-06 09:11:12 +02:00
|
|
|
def test_message
|
|
|
|
assert_equal :Message , @builder.infer_type(:message).class_name
|
|
|
|
end
|
|
|
|
def test_next_message
|
|
|
|
assert_equal :Message , @builder.infer_type(:next_message).class_name
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|