fix argument hoisting

arguments in vool must be simple variables
finally did the hoisting to do that
This commit is contained in:
Torsten Ruger
2018-04-27 09:59:01 +03:00
parent 08d0aae79e
commit 672ccb351d
4 changed files with 76 additions and 12 deletions

View File

@ -0,0 +1,13 @@
require_relative "../helper"
module Vool
module Norm
class NormTest < MiniTest::Test
def normalize(input)
RubyCompiler.compile(input).normalize
end
end
end
end

View File

@ -0,0 +1,35 @@
require_relative "helper"
module Vool
module Norm
class TestSendSimple < NormTest
def test_simple
lst = normalize("foo")
assert_equal SendStatement , lst.class
end
def test_constant_args
lst = normalize("foo(1,2)")
assert_equal SendStatement , lst.class
end
end
class TestSendSend < NormTest
def setup
super
@stm = normalize("foo(1 - 2)")
end
def test_many
assert_equal Statements , @stm.class
end
def test_assignment
assert_equal LocalAssignment , @stm.first.class
end
def test_name
assert @stm.first.name.to_s.start_with?("tmp_") , @stm.first.name
end
def test_assigned
assert_equal SendStatement , @stm.first.value.class
end
end
end
end