aboutsummaryrefslogtreecommitdiffstats
path: root/test/ripper
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-29 12:48:49 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-29 13:24:24 +0900
commitcc66272e5061020cac6864bbc2f68f7d327ecfbb (patch)
tree7ef38276f291348c06d1dc7b2a769239cf2435e6 /test/ripper
parent8552e9d69693b1d3f99a30d846b9dcc30bf590c2 (diff)
downloadruby-cc66272e5061020cac6864bbc2f68f7d327ecfbb.tar.gz
parse.y: flush invalid char
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_scanner_events.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
index 727e967d67..0b4814a73e 100644
--- a/test/ripper/test_scanner_events.rb
+++ b/test/ripper/test_scanner_events.rb
@@ -24,9 +24,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
lexer = Ripper::Lexer.new(str)
if error
lexer.singleton_class.class_eval do
- define_method(:on_parse_error) {|ev|
+ define_method(:on_error) {|ev|
yield __callee__, ev, token()
}
+ alias on_parse_error on_error
+ alias compile_error on_error
end
end
lexer.lex.select {|_1,type,_2| type == sym }.map {|_1,_2,tok| tok }
@@ -967,4 +969,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('tlambda_arg', '-> {}')
end
+ def test_invalid_char
+ err = nil
+ assert_equal ['a'], scan('ident', "\ea") {|*e| err = e}
+ assert_equal :compile_error, err[0]
+ assert_match /Invalid char/, err[1]
+ assert_equal "\e", err[2]
+ end
end if ripper_test