diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-01-09 10:01:20 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-01-09 15:15:52 +0000 |
| commit | 88d7838445ec84b1cc630ce3bd97bb71cd0aefd4 (patch) | |
| tree | 250dce4cad8ecfde3bc8a18b6f1128796be67c87 /test | |
| parent | 02d8bad6e12b8614f007c8c30eb50aff4bddcfb4 (diff) | |
[ruby/prism] Fix assertion on spanning heredocs
https://github.com/ruby/prism/commit/e190308845
Diffstat (limited to 'test')
| -rw-r--r-- | test/prism/fixtures/spanning_heredoc_newlines.txt | 23 | ||||
| -rw-r--r-- | test/prism/parse_test.rb | 2 | ||||
| -rw-r--r-- | test/prism/snapshots/spanning_heredoc_newlines.txt | 155 |
3 files changed, 179 insertions, 1 deletions
diff --git a/test/prism/fixtures/spanning_heredoc_newlines.txt b/test/prism/fixtures/spanning_heredoc_newlines.txt new file mode 100644 index 0000000000..32c9943aeb --- /dev/null +++ b/test/prism/fixtures/spanning_heredoc_newlines.txt @@ -0,0 +1,23 @@ +<<A+% +A + + +<<A+%r +A + + +<<A+%q +A + + +<<A+%Q +A + + +<<A+%s +A + + +<<A+%x +A + diff --git a/test/prism/parse_test.rb b/test/prism/parse_test.rb index e2de55463c..6c5d125c3d 100644 --- a/test/prism/parse_test.rb +++ b/test/prism/parse_test.rb @@ -211,7 +211,7 @@ module Prism end Dir["*.txt", base: base].each do |relative| - next if relative == "newline_terminated.txt" + next if relative == "newline_terminated.txt" || relative == "spanning_heredoc_newlines.txt" # We test every snippet (separated by \n\n) in isolation # to ensure the parser does not try to read bytes further than the end of each snippet diff --git a/test/prism/snapshots/spanning_heredoc_newlines.txt b/test/prism/snapshots/spanning_heredoc_newlines.txt new file mode 100644 index 0000000000..0753089082 --- /dev/null +++ b/test/prism/snapshots/spanning_heredoc_newlines.txt @@ -0,0 +1,155 @@ +@ ProgramNode (location: (1,0)-(24,0)) +├── locals: [] +└── statements: + @ StatementsNode (location: (1,0)-(24,0)) + └── body: (length: 6) + ├── @ CallNode (location: (1,0)-(4,0)) + │ ├── flags: ∅ + │ ├── receiver: + │ │ @ StringNode (location: (1,0)-(1,3)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (1,0)-(1,3) = "<<A" + │ │ ├── content_loc: (2,0)-(2,0) = "" + │ │ ├── closing_loc: (2,0)-(3,0) = "A\n" + │ │ └── unescaped: "" + │ ├── call_operator_loc: ∅ + │ ├── name: :+ + │ ├── message_loc: (1,3)-(1,4) = "+" + │ ├── opening_loc: ∅ + │ ├── arguments: + │ │ @ ArgumentsNode (location: (1,4)-(4,0)) + │ │ ├── flags: ∅ + │ │ └── arguments: (length: 1) + │ │ └── @ StringNode (location: (1,4)-(4,0)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (1,4)-(2,0) = "%\n" + │ │ ├── content_loc: (3,0)-(3,0) = "" + │ │ ├── closing_loc: (3,0)-(4,0) = "\n" + │ │ └── unescaped: "" + │ ├── closing_loc: ∅ + │ └── block: ∅ + ├── @ CallNode (location: (5,0)-(8,0)) + │ ├── flags: ∅ + │ ├── receiver: + │ │ @ StringNode (location: (5,0)-(5,3)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (5,0)-(5,3) = "<<A" + │ │ ├── content_loc: (6,0)-(6,0) = "" + │ │ ├── closing_loc: (6,0)-(7,0) = "A\n" + │ │ └── unescaped: "" + │ ├── call_operator_loc: ∅ + │ ├── name: :+ + │ ├── message_loc: (5,3)-(5,4) = "+" + │ ├── opening_loc: ∅ + │ ├── arguments: + │ │ @ ArgumentsNode (location: (5,4)-(8,0)) + │ │ ├── flags: ∅ + │ │ └── arguments: (length: 1) + │ │ └── @ RegularExpressionNode (location: (5,4)-(8,0)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (5,4)-(6,0) = "%r\n" + │ │ ├── content_loc: (6,0)-(6,0) = "" + │ │ ├── closing_loc: (7,0)-(8,0) = "\n" + │ │ └── unescaped: "" + │ ├── closing_loc: ∅ + │ └── block: ∅ + ├── @ CallNode (location: (9,0)-(12,0)) + │ ├── flags: ∅ + │ ├── receiver: + │ │ @ StringNode (location: (9,0)-(9,3)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (9,0)-(9,3) = "<<A" + │ │ ├── content_loc: (10,0)-(10,0) = "" + │ │ ├── closing_loc: (10,0)-(11,0) = "A\n" + │ │ └── unescaped: "" + │ ├── call_operator_loc: ∅ + │ ├── name: :+ + │ ├── message_loc: (9,3)-(9,4) = "+" + │ ├── opening_loc: ∅ + │ ├── arguments: + │ │ @ ArgumentsNode (location: (9,4)-(12,0)) + │ │ ├── flags: ∅ + │ │ └── arguments: (length: 1) + │ │ └── @ StringNode (location: (9,4)-(12,0)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (9,4)-(10,0) = "%q\n" + │ │ ├── content_loc: (11,0)-(11,0) = "" + │ │ ├── closing_loc: (11,0)-(12,0) = "\n" + │ │ └── unescaped: "" + │ ├── closing_loc: ∅ + │ └── block: ∅ + ├── @ CallNode (location: (13,0)-(16,0)) + │ ├── flags: ∅ + │ ├── receiver: + │ │ @ StringNode (location: (13,0)-(13,3)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (13,0)-(13,3) = "<<A" + │ │ ├── content_loc: (14,0)-(14,0) = "" + │ │ ├── closing_loc: (14,0)-(15,0) = "A\n" + │ │ └── unescaped: "" + │ ├── call_operator_loc: ∅ + │ ├── name: :+ + │ ├── message_loc: (13,3)-(13,4) = "+" + │ ├── opening_loc: ∅ + │ ├── arguments: + │ │ @ ArgumentsNode (location: (13,4)-(16,0)) + │ │ ├── flags: ∅ + │ │ └── arguments: (length: 1) + │ │ └── @ StringNode (location: (13,4)-(16,0)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (13,4)-(14,0) = "%Q\n" + │ │ ├── content_loc: (15,0)-(15,0) = "" + │ │ ├── closing_loc: (15,0)-(16,0) = "\n" + │ │ └── unescaped: "" + │ ├── closing_loc: ∅ + │ └── block: ∅ + ├── @ CallNode (location: (17,0)-(20,0)) + │ ├── flags: ∅ + │ ├── receiver: + │ │ @ StringNode (location: (17,0)-(17,3)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (17,0)-(17,3) = "<<A" + │ │ ├── content_loc: (18,0)-(18,0) = "" + │ │ ├── closing_loc: (18,0)-(19,0) = "A\n" + │ │ └── unescaped: "" + │ ├── call_operator_loc: ∅ + │ ├── name: :+ + │ ├── message_loc: (17,3)-(17,4) = "+" + │ ├── opening_loc: ∅ + │ ├── arguments: + │ │ @ ArgumentsNode (location: (17,4)-(20,0)) + │ │ ├── flags: ∅ + │ │ └── arguments: (length: 1) + │ │ └── @ SymbolNode (location: (17,4)-(20,0)) + │ │ ├── flags: ∅ + │ │ ├── opening_loc: (17,4)-(18,0) = "%s\n" + │ │ ├── value_loc: (18,0)-(18,0) = "" + │ │ ├── closing_loc: (19,0)-(20,0) = "\n" + │ │ └── unescaped: "" + │ ├── closing_loc: ∅ + │ └── block: ∅ + └── @ CallNode (location: (21,0)-(24,0)) + ├── flags: ∅ + ├── receiver: + │ @ StringNode (location: (21,0)-(21,3)) + │ ├── flags: ∅ + │ ├── opening_loc: (21,0)-(21,3) = "<<A" + │ ├── content_loc: (22,0)-(22,0) = "" + │ ├── closing_loc: (22,0)-(23,0) = "A\n" + │ └── unescaped: "" + ├── call_operator_loc: ∅ + ├── name: :+ + ├── message_loc: (21,3)-(21,4) = "+" + ├── opening_loc: ∅ + ├── arguments: + │ @ ArgumentsNode (location: (21,4)-(24,0)) + │ ├── flags: ∅ + │ └── arguments: (length: 1) + │ └── @ XStringNode (location: (21,4)-(24,0)) + │ ├── flags: ∅ + │ ├── opening_loc: (21,4)-(22,0) = "%x\n" + │ ├── content_loc: (22,0)-(22,0) = "" + │ ├── closing_loc: (23,0)-(24,0) = "\n" + │ └── unescaped: "" + ├── closing_loc: ∅ + └── block: ∅ |
