summaryrefslogtreecommitdiff
path: root/test/ripper/dummyparser.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-01 01:29:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-01 01:29:22 +0000
commit046f8469f322756c4fb7676e551ed7d62e4d629f (patch)
treebb90b71ec58be98adf8c7acec847033a0a8cdc6b /test/ripper/dummyparser.rb
parent24171da2226cf82bdd46b691d56ccffafb6b30b4 (diff)
test_parser_events.rb: simplify
* test/ripper/dummyparser.rb (DummyParser): simplified mlhs node representation. * test/ripper/test_parser_events.rb (test_mlhs_add_star): simplified assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper/dummyparser.rb')
-rw-r--r--test/ripper/dummyparser.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb
index 05220dc..6de7e19 100644
--- a/test/ripper/dummyparser.rb
+++ b/test/ripper/dummyparser.rb
@@ -38,6 +38,11 @@ class NodeList
self
end
+ def concat(item)
+ @list.concat item
+ self
+ end
+
def prepend(items)
@list.unshift items
end
@@ -209,6 +214,34 @@ class DummyParser < Ripper
words.push word
end
+ def on_mlhs_new
+ NodeList.new
+ end
+
+ def on_mlhs_paren(list)
+ Node.new(:mlhs, list)
+ end
+
+ def on_mlhs_add(list, node)
+ list.push node
+ end
+
+ def on_mlhs_add_block(list, blk)
+ if blk
+ list.push('&' + blk.to_s)
+ else
+ list
+ end
+ end
+
+ def on_mlhs_add_star(list, arg)
+ list.push('*' + arg.to_s)
+ end
+
+ def on_mlhs_add_post(list, post)
+ list.concat(post.list)
+ end
+
def on_rescue(exc, *rest)
Node.new('rescue', (exc && NodeList.new(exc)), *rest)
end