rubyx/test/vool/compilers/test_local_collect.rb

28 lines
563 B
Ruby
Raw Normal View History

2017-04-08 12:11:52 +03:00
require_relative "helper"
module Vool
module Compilers
class TestLocalCollect < MiniTest::Test
2017-04-08 12:11:52 +03:00
def compile(input)
2018-03-12 17:23:16 +05:30
lst = VoolCompiler.ruby_to_vool( input )
2017-04-08 12:11:52 +03:00
vars = []
lst.collect([]).each do |node|
node.add_local(vars)
2017-04-08 12:11:52 +03:00
end
vars
end
def test_assign_collect
vars = compile( "var = 5" )
2017-04-08 12:11:52 +03:00
assert_equal :var , vars.first
end
def test_return_collect
vars = compile( "var = 5 ; return var" )
2017-04-08 12:11:52 +03:00
assert_equal :var , vars.first
end
end
end
end