From d0614b5254d1767cdffdd32f13897dc10facc6a2 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Wed, 11 Oct 2023 13:58:00 -0400 Subject: [ruby/prism] Split up lines in tilde heredocs https://github.com/ruby/prism/commit/21fad0c2ce --- test/prism/snapshots/dos_endings.txt | 20 +- test/prism/snapshots/heredocs_nested.txt | 14 +- .../snapshots/heredocs_with_ignored_newlines.txt | 56 ++++- .../prism/snapshots/seattlerb/heredoc_squiggly.txt | 26 +- ...edoc_squiggly_blank_line_plus_interpolation.txt | 4 +- .../seattlerb/heredoc_squiggly_blank_lines.txt | 26 +- .../seattlerb/heredoc_squiggly_interp.txt | 26 +- .../snapshots/seattlerb/heredoc_squiggly_tabs.txt | 20 +- .../seattlerb/heredoc_squiggly_tabs_extra.txt | 20 +- .../heredoc_squiggly_visually_blank_lines.txt | 26 +- test/prism/snapshots/tilde_heredocs.txt | 262 ++++++++++++++++----- .../snapshots/unparser/corpus/semantic/dstr.txt | 42 +++- .../snapshots/whitequark/dedenting_heredoc.txt | 204 ++++++++++++---- ...nterpolating_heredoc_fake_line_continuation.txt | 20 +- ...non_interpolating_heredoc_line_continuation.txt | 20 +- test/prism/snapshots/whitequark/parser_bug_640.txt | 2 +- test/prism/snapshots/whitequark/ruby_bug_11989.txt | 2 +- .../whitequark/slash_newline_in_heredocs.txt | 20 +- test/prism/unescape_test.rb | 54 +++-- 19 files changed, 655 insertions(+), 209 deletions(-) (limited to 'test') diff --git a/test/prism/snapshots/dos_endings.txt b/test/prism/snapshots/dos_endings.txt index d01c5a7ac9..7e553ed932 100644 --- a/test/prism/snapshots/dos_endings.txt +++ b/test/prism/snapshots/dos_endings.txt @@ -72,12 +72,22 @@ │ │ └── arguments: (length: 1) │ │ └── @ CallNode (location: (17,8)-(17,19)) │ │ ├── receiver: - │ │ │ @ StringNode (location: (17,8)-(17,14)) - │ │ │ ├── flags: ∅ + │ │ │ @ InterpolatedStringNode (location: (17,8)-(17,14)) │ │ │ ├── opening_loc: (17,8)-(17,14) = "<<~EOF" - │ │ │ ├── content_loc: (18,0)-(19,0) = "\r\n baz\r\n" - │ │ │ ├── closing_loc: (20,0)-(20,0) = " EOF\r\n" - │ │ │ └── unescaped: "\nbaz\r\n" + │ │ │ ├── parts: (length: 2) + │ │ │ │ ├── @ StringNode (location: (18,0)-(18,0)) + │ │ │ │ │ ├── flags: ∅ + │ │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ │ ├── content_loc: (18,0)-(18,0) = "\r\n" + │ │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ │ └── unescaped: "\n" + │ │ │ │ └── @ StringNode (location: (19,0)-(19,0)) + │ │ │ │ ├── flags: ∅ + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── content_loc: (19,0)-(19,0) = " baz\r\n" + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ └── unescaped: "baz\r\n" + │ │ │ └── closing_loc: (20,0)-(20,0) = " EOF\r\n" │ │ ├── call_operator_loc: (17,14)-(17,15) = "." │ │ ├── message_loc: (17,15)-(17,19) = "chop" │ │ ├── opening_loc: ∅ diff --git a/test/prism/snapshots/heredocs_nested.txt b/test/prism/snapshots/heredocs_nested.txt index 8680dd2346..0e76652072 100644 --- a/test/prism/snapshots/heredocs_nested.txt +++ b/test/prism/snapshots/heredocs_nested.txt @@ -5,7 +5,7 @@ └── body: (length: 1) └── @ InterpolatedStringNode (location: (1,0)-(1,7)) ├── opening_loc: (1,0)-(1,7) = "<<~RUBY" - ├── parts: (length: 3) + ├── parts: (length: 4) │ ├── @ StringNode (location: (2,0)-(2,0)) │ │ ├── flags: ∅ │ │ ├── opening_loc: ∅ @@ -24,10 +24,16 @@ │ │ │ ├── closing_loc: (6,0)-(6,0) = "RUBY\n" │ │ │ └── unescaped: " hello\n" │ │ └── closing_loc: (7,0)-(7,1) = "}" - │ └── @ StringNode (location: (7,1)-(8,0)) + │ ├── @ StringNode (location: (7,1)-(7,0)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: ∅ + │ │ ├── content_loc: (7,1)-(7,0) = "\n" + │ │ ├── closing_loc: ∅ + │ │ └── unescaped: "\n" + │ └── @ StringNode (location: (8,0)-(8,0)) │ ├── flags: ∅ │ ├── opening_loc: ∅ - │ ├── content_loc: (7,1)-(8,0) = "\npost\n" + │ ├── content_loc: (8,0)-(8,0) = "post\n" │ ├── closing_loc: ∅ - │ └── unescaped: "\npost\n" + │ └── unescaped: "post\n" └── closing_loc: (9,0)-(9,0) = "RUBY\n" diff --git a/test/prism/snapshots/heredocs_with_ignored_newlines.txt b/test/prism/snapshots/heredocs_with_ignored_newlines.txt index 280a01f879..361c8687aa 100644 --- a/test/prism/snapshots/heredocs_with_ignored_newlines.txt +++ b/test/prism/snapshots/heredocs_with_ignored_newlines.txt @@ -9,9 +9,55 @@ │ ├── content_loc: (2,0)-(1,0) = "" │ ├── closing_loc: (2,0)-(2,0) = "HERE\n" │ └── unescaped: "" - └── @ StringNode (location: (4,0)-(4,8)) - ├── flags: ∅ + └── @ InterpolatedStringNode (location: (4,0)-(4,8)) ├── opening_loc: (4,0)-(4,8) = "<<~THERE" - ├── content_loc: (5,0)-(13,0) = " way over\n <