aboutsummaryrefslogtreecommitdiffstats
path: root/test/ripper/dummyparser.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-22 07:10:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-22 07:10:31 +0000
commitf5063b7ea7e774519602f7a112d9acf536a1da33 (patch)
treee8ae2d61cdb231f4b0f7590b8d66970f178806c5 /test/ripper/dummyparser.rb
parentd551e813cacd693c4c47405c267f72211d450f57 (diff)
downloadruby-f5063b7ea7e774519602f7a112d9acf536a1da33.tar.gz
dummyparser.rb: on_rescue
* test/ripper/dummyparser.rb (on_rescue): add to turn exception class list into NodeList, to test exception class list. * test/ripper/test_parser_events.rb (test_rescue_class): add missing test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper/dummyparser.rb')
-rw-r--r--test/ripper/dummyparser.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb
index 1403203dae..35c08b52bb 100644
--- a/test/ripper/dummyparser.rb
+++ b/test/ripper/dummyparser.rb
@@ -26,8 +26,8 @@ class Node
end
class NodeList
- def initialize
- @list = []
+ def initialize(list = [])
+ @list = list
end
attr_reader :list
@@ -208,6 +208,10 @@ class DummyParser < Ripper
words.push word
end
+ def on_rescue(exc, *rest)
+ Node.new('rescue', (exc && NodeList.new(exc)), *rest)
+ 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)