summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/yarp/fixtures/wrapping_heredoc.txt13
-rw-r--r--test/yarp/parse_test.rb4
-rw-r--r--test/yarp/snapshots/wrapping_heredoc.txt80
3 files changed, 97 insertions, 0 deletions
diff --git a/test/yarp/fixtures/wrapping_heredoc.txt b/test/yarp/fixtures/wrapping_heredoc.txt
new file mode 100644
index 0000000000..d5fc710178
--- /dev/null
+++ b/test/yarp/fixtures/wrapping_heredoc.txt
@@ -0,0 +1,13 @@
+# 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 c0f3ecf551..f8c1fe12d1 100644
--- a/test/yarp/parse_test.rb
+++ b/test/yarp/parse_test.rb
@@ -112,6 +112,10 @@ class ParseTest < Test::Unit::TestCase
# Waiting for feedback on https://bugs.ruby-lang.org/issues/19838.
return if relative == "seattlerb/heredoc_nested.txt"
+ # Ripper seems to have a bug that the regex portions before and after the heredoc are combined
+ # into a single token.
+ return if relative == "wrapping_heredoc.txt"
+
# Finally, assert that we can lex the source and get the same tokens as
# Ripper.
lex_result = YARP.lex_compat(source)
diff --git a/test/yarp/snapshots/wrapping_heredoc.txt b/test/yarp/snapshots/wrapping_heredoc.txt
new file mode 100644
index 0000000000..674db56ed1
--- /dev/null
+++ b/test/yarp/snapshots/wrapping_heredoc.txt
@@ -0,0 +1,80 @@
+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"
+ )]
+ )
+)