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