rubyx/test/slot_language/test_variable.rb

36 lines
949 B
Ruby
Raw Normal View History

require_relative "helper"
module SlotLanguage
class TestVariable < MiniTest::Test
include SlotHelper
2020-02-13 13:09:00 +01:00
def compile_var(str)
var = compile(str)
assert var.is_a?(Variable)
assert_equal :a , var.name
var
end
def test_local
assert_equal Variable , compile_var("a").class
end
def test_inst
assert_equal MessageVariable , compile_var("@a").class
end
def test_local_chain
chain = compile_var("a.b")
assert_equal Variable , chain.chain.class
assert_equal :b , chain.chain.name
end
def test_local_chain2
chain = compile_var("a.b.c")
assert_equal Variable , chain.chain.chain.class
assert_equal :c , chain.chain.chain.name
end
def test_inst_chain
chain = compile_var("@a.b")
assert_equal MessageVariable , chain.class
assert_equal Variable , chain.chain.class
assert_equal :b , chain.chain.name
end
end
end