summaryrefslogtreecommitdiff
path: root/test/ripper
diff options
context:
space:
mode:
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/dummyparser.rb38
-rw-r--r--test/ripper/test_parser_events.rb2
2 files changed, 29 insertions, 11 deletions
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb
index 07a7eda..d9bd69e 100644
--- a/test/ripper/dummyparser.rb
+++ b/test/ripper/dummyparser.rb
@@ -130,44 +130,44 @@ class DummyParser < Ripper
on_args_add_block(m.children, b)
m
end
-
+
def on_paren(params)
params
end
-
+
def on_brace_block(params, code)
Node.new('block', params, code)
end
-
+
def on_block_var(params, shadow)
params
end
-
+
def on_rest_param(var)
"*#{var}"
end
-
+
def on_blockarg(var)
"&#{var}"
end
-
+
def on_params(required, optional, rest, more, block)
args = NodeList.new
-
+
required.each do |req|
args.push(req)
end if required
-
+
optional.each do |var, val|
args.push("#{var}=#{val}")
end if optional
-
+
args.push(rest) if rest
-
+
more.each do |m|
args.push(m)
end if more
-
+
args.push(block) if block
args
end
@@ -184,6 +184,22 @@ class DummyParser < Ripper
Node.new('assocs', *a)
end
+ def on_words_new
+ NodeList.new
+ end
+
+ def on_words_add(words, word)
+ words.push word
+ end
+
+ def on_qwords_new
+ NodeList.new
+ end
+
+ def on_qwords_add(words, word)
+ words.push word
+ end
+
(Ripper::PARSER_EVENTS.map(&:to_s) - instance_methods(false).map {|n|n.to_s.sub(/^on_/, '')}).each do |event|
define_method(:"on_#{event}") do |*args|
Node.new(event, *args)
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 829b405..9f97dba 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -160,6 +160,8 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
def test_array # array literal
assert_equal '[array([1,2,3])]', parse('[1,2,3]')
+ assert_equal '[array([abc,def])]', parse('%w[abc def]')
+ assert_equal '[array([abc,def])]', parse('%W[abc def]')
end
def test_assign # generic assignment