rubyx/test/vool/compilers/test_ivar_collect.rb

33 lines
663 B
Ruby
Raw Normal View History

2017-04-08 11:11:52 +02:00
require_relative "helper"
module Vool
module Compilers
class TestIvarCollect < MiniTest::Test
def compile(input)
lst = VoolCompiler.compile( input )
vars = []
lst.collect([]).each do |node|
node.add_ivar(vars)
end
vars
end
def test_instance_collect
vars = compile( "@var" )
assert_equal :var , vars.first
end
def test_return_collect
vars = compile( "return @var" )
assert_equal :var , vars.first
end
2017-04-08 11:18:10 +02:00
def test_assign_collect
2017-04-08 11:11:52 +02:00
vars = compile( "@var = 5" )
assert_equal :var , vars.first
end
end
end
end