aboutsummaryrefslogtreecommitdiffstats
path: root/test/yarp
diff options
context:
space:
mode:
authorMike Dalessio <mike.dalessio@gmail.com>2023-08-27 16:19:12 -0400
committergit <svn-admin@ruby-lang.org>2023-08-28 12:37:28 +0000
commit8926fd20f612aa6bae77844b8b6f5d14bf659cb1 (patch)
treea4155d46f7f06eca5fd76cd55f5b891a7c122743 /test/yarp
parent2b9a05374032b3d287b91e6307d2817b6c962612 (diff)
downloadruby-8926fd20f612aa6bae77844b8b6f5d14bf659cb1.tar.gz
[ruby/yarp] test: backfill tests for %q/%Q spanning a heredoc
Also rename the fixture file https://github.com/ruby/yarp/commit/c148d955fd
Diffstat (limited to 'test/yarp')
-rw-r--r--test/yarp/fixtures/spanning_heredoc.txt25
-rw-r--r--test/yarp/fixtures/wrapping_heredoc.txt13
-rw-r--r--test/yarp/parse_test.rb2
-rw-r--r--test/yarp/snapshots/spanning_heredoc.txt115
-rw-r--r--test/yarp/snapshots/wrapping_heredoc.txt80
5 files changed, 141 insertions, 94 deletions
diff --git a/test/yarp/fixtures/spanning_heredoc.txt b/test/yarp/fixtures/spanning_heredoc.txt
new file mode 100644
index 0000000000..5040840e76
--- /dev/null
+++ b/test/yarp/fixtures/spanning_heredoc.txt
@@ -0,0 +1,25 @@
+# test regex, string, and lists that span a heredoc thanks to an escaped newline
+
+# ripper incorrectly creates a "b\nb" token instead of two separate string tokens
+pp <<-A.gsub(/b\
+a
+A
+b/, "")
+
+# ripper incorrectly creates a "d\nd" token instead of two separate string tokens
+pp <<-A, "d\
+c
+A
+d"
+
+# ripper gets this right
+pp <<-A, %q[f\
+e
+A
+f]
+
+# ripper incorrectly creates a "h\nh" token instead of two separate string tokens
+pp <<-A, %Q[h\
+g
+A
+h]
diff --git a/test/yarp/fixtures/wrapping_heredoc.txt b/test/yarp/fixtures/wrapping_heredoc.txt
deleted file mode 100644
index d5fc710178..0000000000
--- a/test/yarp/fixtures/wrapping_heredoc.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-# test regex, string, and lists that wrap a heredoc thanks to an escaped newline
-
-# ripper incorrectly creates a "b\nc" string instead of two separate string tokens
-pp <<-A.gsub(/b\
-a
-A
-c/, "")
-
-# ripper incorrectly creates a "e\nf" string instead of two separate string tokens
-pp <<-A + "e\
-d
-A
-f"
diff --git a/test/yarp/parse_test.rb b/test/yarp/parse_test.rb
index 70f061242b..1eb0033208 100644
--- a/test/yarp/parse_test.rb
+++ b/test/yarp/parse_test.rb
@@ -77,7 +77,7 @@ class ParseTest < Test::Unit::TestCase
# into a single token. See https://bugs.ruby-lang.org/issues/19838.
#
# Additionally, Ripper cannot parse the %w[] fixture in this file, so set ripper_should_parse to false.
- ripper_should_match = false if relative == "wrapping_heredoc.txt"
+ ripper_should_match = false if relative == "spanning_heredoc.txt"
define_method "test_filepath_#{relative}" do
# First, read the source from the filepath. Use binmode to avoid converting CRLF on Windows,
diff --git a/test/yarp/snapshots/spanning_heredoc.txt b/test/yarp/snapshots/spanning_heredoc.txt
new file mode 100644
index 0000000000..244ced125b
--- /dev/null
+++ b/test/yarp/snapshots/spanning_heredoc.txt
@@ -0,0 +1,115 @@
+ProgramNode(164...448)(
+ [],
+ StatementsNode(164...448)(
+ [CallNode(164...192)(
+ nil,
+ nil,
+ (164...166),
+ nil,
+ ArgumentsNode(167...192)(
+ [CallNode(167...192)(
+ InterpolatedStringNode(167...171)(
+ (167...171),
+ [StringNode(181...183)(nil, (181...183), nil, "a\n")],
+ (183...185)
+ ),
+ (171...172),
+ (172...176),
+ (176...177),
+ ArgumentsNode(177...191)(
+ [InterpolatedRegularExpressionNode(177...187)(
+ (177...178),
+ [StringNode(178...181)(nil, (178...181), nil, "b"),
+ StringNode(185...186)(nil, (185...186), nil, "b")],
+ (186...187),
+ 0
+ ),
+ StringNode(189...191)(
+ (189...190),
+ (190...190),
+ (190...191),
+ ""
+ )]
+ ),
+ (191...192),
+ nil,
+ 0,
+ "gsub"
+ )]
+ ),
+ nil,
+ nil,
+ 0,
+ "pp"
+ ),
+ CallNode(276...295)(
+ nil,
+ nil,
+ (276...278),
+ nil,
+ ArgumentsNode(279...295)(
+ [InterpolatedStringNode(279...283)(
+ (279...283),
+ [StringNode(289...291)(nil, (289...291), nil, "c\n")],
+ (291...293)
+ ),
+ InterpolatedStringNode(285...295)(
+ (285...286),
+ [StringNode(286...289)(nil, (286...289), nil, "d"),
+ StringNode(293...294)(nil, (293...294), nil, "d")],
+ (294...295)
+ )]
+ ),
+ nil,
+ nil,
+ 0,
+ "pp"
+ ),
+ CallNode(322...343)(
+ nil,
+ nil,
+ (322...324),
+ nil,
+ ArgumentsNode(325...343)(
+ [InterpolatedStringNode(325...329)(
+ (325...329),
+ [StringNode(337...339)(nil, (337...339), nil, "e\n")],
+ (339...341)
+ ),
+ InterpolatedStringNode(331...343)(
+ (331...334),
+ [StringNode(334...337)(nil, (334...337), nil, "f\\\n"),
+ StringNode(341...342)(nil, (341...342), nil, "f")],
+ (342...343)
+ )]
+ ),
+ nil,
+ nil,
+ 0,
+ "pp"
+ ),
+ CallNode(427...448)(
+ nil,
+ nil,
+ (427...429),
+ nil,
+ ArgumentsNode(430...448)(
+ [InterpolatedStringNode(430...434)(
+ (430...434),
+ [StringNode(442...444)(nil, (442...444), nil, "g\n")],
+ (444...446)
+ ),
+ InterpolatedStringNode(436...448)(
+ (436...439),
+ [StringNode(439...442)(nil, (439...442), nil, "h"),
+ StringNode(446...447)(nil, (446...447), nil, "h")],
+ (447...448)
+ )]
+ ),
+ nil,
+ nil,
+ 0,
+ "pp"
+ )]
+ )
+)
diff --git a/test/yarp/snapshots/wrapping_heredoc.txt b/test/yarp/snapshots/wrapping_heredoc.txt
deleted file mode 100644
index 674db56ed1..0000000000
--- a/test/yarp/snapshots/wrapping_heredoc.txt
+++ /dev/null
@@ -1,80 +0,0 @@
-ProgramNode(165...298)(
- [],
- StatementsNode(165...298)(
- [CallNode(165...193)(
- nil,
- nil,
- (165...167),
- nil,
- ArgumentsNode(168...193)(
- [CallNode(168...193)(
- InterpolatedStringNode(168...172)(
- (168...172),
- [StringNode(182...184)(nil, (182...184), nil, "a\n")],
- (184...186)
- ),
- (172...173),
- (173...177),
- (177...178),
- ArgumentsNode(178...192)(
- [InterpolatedRegularExpressionNode(178...188)(
- (178...179),
- [StringNode(179...182)(nil, (179...182), nil, "b"),
- StringNode(186...187)(nil, (186...187), nil, "c")],
- (187...188),
- 0
- ),
- StringNode(190...192)(
- (190...191),
- (191...191),
- (191...192),
- ""
- )]
- ),
- (192...193),
- nil,
- 0,
- "gsub"
- )]
- ),
- nil,
- nil,
- 0,
- "pp"
- ),
- CallNode(278...298)(
- nil,
- nil,
- (278...280),
- nil,
- ArgumentsNode(281...298)(
- [CallNode(281...298)(
- InterpolatedStringNode(281...285)(
- (281...285),
- [StringNode(292...294)(nil, (292...294), nil, "d\n")],
- (294...296)
- ),
- nil,
- (286...287),
- nil,
- ArgumentsNode(288...298)(
- [InterpolatedStringNode(288...298)(
- (288...289),
- [StringNode(289...292)(nil, (289...292), nil, "e"),
- StringNode(296...297)(nil, (296...297), nil, "f")],
- (297...298)
- )]
- ),
- nil,
- nil,
- 0,
- "+"
- )]
- ),
- nil,
- nil,
- 0,
- "pp"
- )]
- )
-)