From f5063b7ea7e774519602f7a112d9acf536a1da33 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 22 Nov 2014 07:10:31 +0000 Subject: 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 --- test/ripper/dummyparser.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'test/ripper/dummyparser.rb') 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) -- cgit v1.2.3