Skip to content

Commit

Permalink
Add support for dynamic symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Schirp committed Aug 20, 2012
1 parent 49846f6 commit d01dc88
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/to_source/visitor.rb
Expand Up @@ -398,6 +398,19 @@ def dynamic_string(node)
emit('"')
end

# Emit dynamic symbol
#
# @param [Rubinius::AST::Node] node
#
# @return [undefined]
#
# @api private
#
def dynamic_symbol(node)
emit(':')
dynamic_string(node)
end

# Emit to array
#
# @param [Rubinius::AST::Node] node
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/to_source/visitor/class_methods/run_spec.rb
Expand Up @@ -283,6 +283,16 @@ def foo
end
end

context 'dynamic symbol' do
context 'simple' do
assert_source ':"foo#{bar}baz"'
end

context 'with escapes' do
assert_source ':"fo\no#{bar}b\naz"'
end
end

context 'dynamic execute' do
context 'simple' do
assert_source '`foo#{bar}baz`'
Expand Down

0 comments on commit d01dc88

Please sign in to comment.