Skip to content

Commit

Permalink
fix #119, add transform for empty array literal
Browse files Browse the repository at this point in the history
  • Loading branch information
baroquebobcat committed Sep 11, 2011
1 parent a474b84 commit 989fd1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/mirah/transform/helper.rb
Expand Up @@ -159,6 +159,10 @@ def transform_sclass(node, parent)
end
end

def transform_zarray(node, parent)
Mirah::AST::Array.new(parent, position(node))
end

def transform_array(node, parent)
Mirah::AST::Array.new(parent, position(node)) do |array|
node.children.map {|child| transformer.transform(child, array)}
Expand Down
7 changes: 7 additions & 0 deletions test/core/test_compilation.rb
Expand Up @@ -124,4 +124,11 @@ def test_empty_array
assert_equal([[:empty_array, nil]], @compiler.calls)
assert_equal(5, size.literal)
end

def test_empty_literal_array
new_ast = AST.parse("[]").body[0]
new_ast.compile(@compiler, true)

assert_equal([:array, a(Mirah::AST::Array), true], @compiler.calls.first)
end
end

0 comments on commit 989fd1b

Please sign in to comment.