rubyx/test/vool/compilers/test_local_collect.rb

28 lines
563 B
Ruby
Raw Normal View History

2017-04-08 11:11:52 +02:00
require_relative "helper"
module Vool
module Compilers
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|
node.add_local(vars)
2017-04-08 11:11:52 +02:00
end
vars
end
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
vars = compile( "var = 5 ; return var" )
2017-04-08 11:11:52 +02:00
assert_equal :var , vars.first
end
end
end
end