Skip to content

Commit c148d95

Browse files
committed
test: backfill tests for %q/%Q spanning a heredoc
Also rename the fixture file
1 parent 87f3488 commit c148d95

File tree

5 files changed

+141
-94
lines changed

5 files changed

+141
-94
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# test regex, string, and lists that span a heredoc thanks to an escaped newline
2+
3+
# ripper incorrectly creates a "b\nb" token instead of two separate string tokens
4+
pp <<-A.gsub(/b\
5+
a
6+
A
7+
b/, "")
8+
9+
# ripper incorrectly creates a "d\nd" token instead of two separate string tokens
10+
pp <<-A, "d\
11+
c
12+
A
13+
d"
14+
15+
# ripper gets this right
16+
pp <<-A, %q[f\
17+
e
18+
A
19+
f]
20+
21+
# ripper incorrectly creates a "h\nh" token instead of two separate string tokens
22+
pp <<-A, %Q[h\
23+
g
24+
A
25+
h]

test/yarp/fixtures/wrapping_heredoc.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/yarp/parse_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_parse_lex_file
7777
# into a single token. See https://bugs.ruby-lang.org/issues/19838.
7878
#
7979
# Additionally, Ripper cannot parse the %w[] fixture in this file, so set ripper_should_parse to false.
80-
ripper_should_match = false if relative == "wrapping_heredoc.txt"
80+
ripper_should_match = false if relative == "spanning_heredoc.txt"
8181

8282
define_method "test_filepath_#{relative}" do
8383
# First, read the source from the filepath. Use binmode to avoid converting CRLF on Windows,

test/yarp/snapshots/spanning_heredoc.txt

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/yarp/snapshots/wrapping_heredoc.txt

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)