summaryrefslogtreecommitdiff
path: root/test/ripper/test_scanner_events.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-03 14:56:42 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-03 15:15:54 +0900
commitc990b3c41af5957a739dfb235dfbb821e73a74df (patch)
tree3b238c404c143522973016b03b2e7f4b242c2e46 /test/ripper/test_scanner_events.rb
parent22da5d71eaa50a749f8a08beb9bd6fe59e489449 (diff)
Fix the error token on "invalid hex escape"
* parse.y (tok_hex): flush token after dispatching the "invalid hex escape" parse error.
Diffstat (limited to 'test/ripper/test_scanner_events.rb')
-rw-r--r--test/ripper/test_scanner_events.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
index 0b4814a73e..339a66d5ec 100644
--- a/test/ripper/test_scanner_events.rb
+++ b/test/ripper/test_scanner_events.rb
@@ -976,4 +976,14 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
assert_match /Invalid char/, err[1]
assert_equal "\e", err[2]
end
+
+ def test_invalid_hex_escape
+ err = nil
+ assert_equal ['U'], scan('tstring_content', '"\\xU"') {|*e| err = e}
+ assert_equal [:on_parse_error, "invalid hex escape", "\\x"], err
+
+ err = nil
+ assert_equal ['U'], scan('tstring_content', '/\\xU/') {|*e| err = e}
+ assert_equal [:on_parse_error, "invalid hex escape", "\\x"], err
+ end
end if ripper_test