diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-08 20:03:32 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-27 21:53:01 +0900 |
commit | 9fd342f8d26b1a94c70ff2b76131cdac4f534672 (patch) | |
tree | 4609db0cd07fa85eba2d78d9e2999e030e35fab5 /test/yarp | |
parent | e1250a5f9778f463a541bc1ee5a951f64c131bbf (diff) | |
download | ruby-9fd342f8d26b1a94c70ff2b76131cdac4f534672.tar.gz |
Block exits are now syntax error in ripper
Diffstat (limited to 'test/yarp')
-rw-r--r-- | test/yarp/parse_test.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/yarp/parse_test.rb b/test/yarp/parse_test.rb index bdfce882f9..0baa099e94 100644 --- a/test/yarp/parse_test.rb +++ b/test/yarp/parse_test.rb @@ -85,9 +85,20 @@ module YARP # and explicitly set the external encoding to UTF-8 to override the binmode default. source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8) - # Make sure that it can be correctly parsed by Ripper. If it can't, then we have a fixture - # that is invalid Ruby. - refute_nil(Ripper.sexp_raw(source), "Ripper failed to parse") if ripper_should_parse + if ripper_should_parse + src = source + + case relative + when /break|next|redo|if|unless|rescue|control|keywords/ + # Uncaught syntax errors: Invalid break, Invalid next + src = "->{\n#{src}\n}" + ripper_should_match = false + end + + # Make sure that it can be correctly parsed by Ripper. If it can't, then we have a fixture + # that is invalid Ruby. + refute_nil(Ripper.sexp_raw(src), "Ripper failed to parse") + end # Next, assert that there were no errors during parsing. result = YARP.parse(source, relative) |