From 21dc64534b841ed905e7ea0806e125de13e2f250 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Tue, 24 Oct 2023 12:42:16 -0400 Subject: [PATCH] [ruby/prism] Regenerate snapshots https://github.com/ruby/prism/commit/160df9a687 --- lib/prism/prism.gemspec | 1 + prism/prism.c | 12 +- prism/templates/src/prettyprint.c.erb | 12 +- test/prism/comments_test.rb | 99 ++++++--- test/prism/snapshots/blocks.txt | 2 +- test/prism/snapshots/dash_heredocs.txt | 82 ++++---- test/prism/snapshots/dos_endings.txt | 24 +-- .../snapshots/embdoc_no_newline_at_end.txt | 4 +- .../heredoc_with_escaped_newline_at_start.txt | 8 +- .../heredoc_with_trailing_newline.txt | 2 +- test/prism/snapshots/heredocs_nested.txt | 18 +- .../heredocs_with_ignored_newlines.txt | 38 ++-- ...cs_with_ignored_newlines_and_non_empty.txt | 2 +- test/prism/snapshots/methods.txt | 8 +- test/prism/snapshots/newline_terminated.txt | 70 +++---- test/prism/snapshots/regex.txt | 2 +- .../seattlerb/TestRubyParserShared.txt | 2 +- .../snapshots/seattlerb/block_arg__bare.txt | 2 +- test/prism/snapshots/seattlerb/bug236.txt | 2 +- .../seattlerb/defn_arg_asplat_arg.txt | 2 +- .../seattlerb/defn_kwarg_kwsplat_anon.txt | 2 +- .../snapshots/seattlerb/defn_splat_arg.txt | 2 +- .../prism/snapshots/seattlerb/difficult0_.txt | 8 +- .../heredoc__backslash_dos_format.txt | 4 +- .../seattlerb/heredoc_backslash_nl.txt | 6 +- .../seattlerb/heredoc_bad_hex_escape.txt | 4 +- .../seattlerb/heredoc_bad_oct_escape.txt | 4 +- .../snapshots/seattlerb/heredoc_comma_arg.txt | 6 +- .../snapshots/seattlerb/heredoc_lineno.txt | 4 +- .../snapshots/seattlerb/heredoc_nested.txt | 14 +- .../snapshots/seattlerb/heredoc_squiggly.txt | 14 +- ...squiggly_blank_line_plus_interpolation.txt | 10 +- .../heredoc_squiggly_blank_lines.txt | 14 +- .../seattlerb/heredoc_squiggly_empty.txt | 4 +- .../seattlerb/heredoc_squiggly_interp.txt | 14 +- .../seattlerb/heredoc_squiggly_no_indent.txt | 4 +- .../seattlerb/heredoc_squiggly_tabs.txt | 10 +- .../seattlerb/heredoc_squiggly_tabs_extra.txt | 10 +- .../heredoc_squiggly_visually_blank_lines.txt | 14 +- .../heredoc_trailing_slash_continued_call.txt | 4 +- .../snapshots/seattlerb/heredoc_unicode.txt | 4 +- .../heredoc_with_carriage_return_escapes.txt | 4 +- ...c_with_carriage_return_escapes_windows.txt | 4 +- ...redoc_with_extra_carriage_horrible_mix.txt | 4 +- .../heredoc_with_extra_carriage_returns.txt | 4 +- ...oc_with_extra_carriage_returns_windows.txt | 4 +- ...erpolation_and_carriage_return_escapes.txt | 6 +- ...on_and_carriage_return_escapes_windows.txt | 6 +- .../heredoc_with_not_global_interpolation.txt | 4 +- .../heredoc_with_only_carriage_returns.txt | 4 +- ...doc_with_only_carriage_returns_windows.txt | 4 +- .../snapshots/seattlerb/label_vs_string.txt | 2 +- .../parse_line_dstr_soft_newline.txt | 4 +- .../seattlerb/parse_line_heredoc.txt | 4 +- .../seattlerb/parse_line_heredoc_evstr.txt | 10 +- .../parse_line_heredoc_hardnewline.txt | 4 +- .../parse_line_heredoc_regexp_chars.txt | 4 +- .../seattlerb/pct_Q_backslash_nl.txt | 2 +- test/prism/snapshots/seattlerb/pct_nl.txt | 14 +- .../seattlerb/pct_w_heredoc_interp_nested.txt | 4 +- .../seattlerb/str_double_newline.txt | 2 +- .../seattlerb/str_heredoc_interp.txt | 6 +- .../seattlerb/str_single_newline.txt | 2 +- .../prism/snapshots/single_quote_heredocs.txt | 4 +- test/prism/snapshots/spanning_heredoc.txt | 32 +-- test/prism/snapshots/tilde_heredocs.txt | 198 +++++++++--------- test/prism/snapshots/unescaping.txt | 4 +- .../unparser/corpus/literal/assignment.txt | 30 +-- .../unparser/corpus/literal/block.txt | 8 +- .../snapshots/unparser/corpus/literal/def.txt | 8 +- .../unparser/corpus/literal/dstr.txt | 52 ++--- .../unparser/corpus/literal/empty.txt | 4 +- .../unparser/corpus/literal/literal.txt | 32 +-- .../unparser/corpus/literal/since/31.txt | 4 +- .../unparser/corpus/literal/since/32.txt | 4 +- .../unparser/corpus/semantic/block.txt | 8 +- .../unparser/corpus/semantic/dstr.txt | 130 ++++++------ .../unparser/corpus/semantic/while.txt | 4 +- .../whitequark/anonymous_blockarg.txt | 2 +- test/prism/snapshots/whitequark/args.txt | 4 +- test/prism/snapshots/whitequark/blockargs.txt | 12 +- .../snapshots/whitequark/bug_heredoc_do.txt | 4 +- .../whitequark/dedenting_heredoc.txt | 144 ++++++------- ...olating_heredoc_fake_line_continuation.txt | 10 +- ...nterpolating_heredoc_line_continuation.txt | 10 +- .../prism/snapshots/whitequark/empty_stmt.txt | 4 +- .../forwarded_argument_with_kwrestarg.txt | 2 +- .../forwarded_argument_with_restarg.txt | 2 +- .../whitequark/forwarded_kwrestarg.txt | 2 +- ...warded_kwrestarg_with_additional_kwarg.txt | 2 +- .../whitequark/forwarded_restarg.txt | 2 +- test/prism/snapshots/whitequark/heredoc.txt | 12 +- .../snapshots/whitequark/interp_digit_var.txt | 24 +-- ...targ_with_kwrestarg_and_forwarded_args.txt | 2 +- .../whitequark/kwrestarg_unnamed.txt | 2 +- .../snapshots/whitequark/parser_bug_640.txt | 4 +- ...ps_truncated_parts_of_squiggly_heredoc.txt | 6 +- ...ser_slash_slash_n_escaping_in_literals.txt | 12 +- .../snapshots/whitequark/restarg_unnamed.txt | 2 +- .../snapshots/whitequark/ruby_bug_11989.txt | 4 +- .../snapshots/whitequark/ruby_bug_11990.txt | 4 +- .../snapshots/whitequark/send_lambda.txt | 2 +- .../whitequark/slash_newline_in_heredocs.txt | 14 +- 103 files changed, 746 insertions(+), 714 deletions(-) diff --git a/lib/prism/prism.gemspec b/lib/prism/prism.gemspec index 63c6702561..faabc22de9 100644 --- a/lib/prism/prism.gemspec +++ b/lib/prism/prism.gemspec @@ -47,6 +47,7 @@ Gem::Specification.new do |spec| "include/prism/node.h", "include/prism/pack.h", "include/prism/parser.h", + "include/prism/prettyprint.h", "include/prism/regexp.h", "include/prism/util/pm_buffer.h", "include/prism/util/pm_char.h", diff --git a/prism/prism.c b/prism/prism.c index 34f3cc50c5..7513f2cb8e 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -81,14 +81,12 @@ debug_contexts(pm_parser_t *parser) { } PRISM_ATTRIBUTE_UNUSED static void -debug_node(const char *message, pm_parser_t *parser, pm_node_t *node) { - pm_buffer_t buffer; - if (!pm_buffer_init(&buffer)) return; +debug_node(const pm_parser_t *parser, const pm_node_t *node) { + pm_buffer_t output_buffer = { 0 }; + pm_prettyprint(&output_buffer, parser, node); - pm_prettyprint(parser, node, &buffer); - - fprintf(stderr, "%s\n%.*s\n", message, (int) buffer.length, buffer.value); - pm_buffer_free(&buffer); + fprintf(stderr, "%.*s", (int) output_buffer.length, output_buffer.value); + pm_buffer_free(&output_buffer); } PRISM_ATTRIBUTE_UNUSED static void diff --git a/prism/templates/src/prettyprint.c.erb b/prism/templates/src/prettyprint.c.erb index 43d7c57190..ecd2c227df 100644 --- a/prism/templates/src/prettyprint.c.erb +++ b/prism/templates/src/prettyprint.c.erb @@ -1,10 +1,4 @@ -#include "prism/defines.h" - -#include - -#include "prism/ast.h" -#include "prism/parser.h" -#include "prism/util/pm_buffer.h" +#include "prism/prettyprint.h" static void prettyprint_source(pm_buffer_t *output_buffer, const uint8_t *source, size_t length) { @@ -55,7 +49,7 @@ prettyprint_constant(pm_buffer_t *output_buffer, const pm_parser_t *parser, cons } static void -prettyprint_node(pm_buffer_t *output_buffer, pm_parser_t *parser, const pm_node_t *node, pm_buffer_t *prefix_buffer) { +prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node, pm_buffer_t *prefix_buffer) { switch (PM_NODE_TYPE(node)) { case PM_SCOPE_NODE: // We do not need to print a ScopeNode as it's not part of the AST. @@ -185,7 +179,7 @@ prettyprint_node(pm_buffer_t *output_buffer, pm_parser_t *parser, const pm_node_ // Pretty-prints the AST represented by the given node to the given buffer. PRISM_EXPORTED_FUNCTION void -pm_prettyprint(pm_buffer_t *output_buffer, pm_parser_t *parser, const pm_node_t *node) { +pm_prettyprint(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node) { pm_buffer_t prefix_buffer = { 0 }; prettyprint_node(output_buffer, parser, node, &prefix_buffer); pm_buffer_free(&prefix_buffer); diff --git a/test/prism/comments_test.rb b/test/prism/comments_test.rb index 0748beb391..dc43fb6a36 100644 --- a/test/prism/comments_test.rb +++ b/test/prism/comments_test.rb @@ -6,9 +6,18 @@ module Prism class CommentsTest < TestCase def test_comment_inline source = "# comment" - - assert_comment source, :inline, [0, 9, 1, 1, 0, 9] assert_equal [0], Debug.newlines(source) + + assert_comment( + source, + :inline, + start_offset: 0, + end_offset: 9, + start_line: 1, + end_line: 1, + start_column: 0, + end_column: 9 + ) end def test_comment_inline_def @@ -18,7 +27,16 @@ module Prism end RUBY - assert_comment source, :inline, [10, 21, 2, 2, 2, 13] + assert_comment( + source, + :inline, + start_offset: 10, + end_offset: 21, + start_line: 2, + end_line: 2, + start_column: 2, + end_column: 13 + ) end def test_comment___END__ @@ -27,13 +45,31 @@ module Prism comment RUBY - assert_comment source, :__END__, [0, 16, 1, 2, 0, 0] + assert_comment( + source, + :__END__, + start_offset: 0, + end_offset: 16, + start_line: 1, + end_line: 3, + start_column: 0, + end_column: 0 + ) end def test_comment___END__crlf source = "__END__\r\ncomment\r\n" - assert_comment source, :__END__, [0, 18, 1, 2, 0, 0] + assert_comment( + source, + :__END__, + start_offset: 0, + end_offset: 18, + start_line: 1, + end_line: 3, + start_column: 0, + end_column: 0 + ) end def test_comment_embedded_document @@ -43,7 +79,16 @@ module Prism =end RUBY - assert_comment source, :embdoc, [0, 20, 1, 3, 0, 0] + assert_comment( + source, + :embdoc, + start_offset: 0, + end_offset: 20, + start_line: 1, + end_line: 4, + start_column: 0, + end_column: 0 + ) end def test_comment_embedded_document_with_content_on_same_line @@ -52,7 +97,16 @@ module Prism =end RUBY - assert_comment source, :embdoc, [0, 24, 1, 2, 0, 0] + assert_comment( + source, + :embdoc, + start_offset: 0, + end_offset: 24, + start_line: 1, + end_line: 3, + start_column: 0, + end_column: 0 + ) end def test_attaching_comments @@ -81,33 +135,18 @@ module Prism private - def assert_comment(source, type, locations) - start_offset, end_offset, start_line, end_line, start_column, end_column = locations - expected = { - start_offset: start_offset, - end_offset: end_offset, - start_line: start_line, - end_line: end_line, - start_column: start_column, - end_column: end_column - } - + def assert_comment(source, type, start_offset:, end_offset:, start_line:, end_line:, start_column:, end_column:) result = Prism.parse(source) assert result.errors.empty?, result.errors.map(&:message).join("\n") assert_equal type, result.comments.first.type - first_comment_location = result.comments.first.location - - actual = { - start_offset: first_comment_location.start_offset, - end_offset: first_comment_location.end_offset, - start_line: first_comment_location.start_line, - end_line: first_comment_location.end_line, - start_column: first_comment_location.start_column, - end_column: first_comment_location.end_column - } - - assert_equal expected, actual + location = result.comments.first.location + assert_equal start_offset, location.start_offset, -> { "Expected start_offset to be #{start_offset}" } + assert_equal end_offset, location.end_offset, -> { "Expected end_offset to be #{end_offset}" } + assert_equal start_line, location.start_line, -> { "Expected start_line to be #{start_line}" } + assert_equal end_line, location.end_line, -> { "Expected end_line to be #{end_line}" } + assert_equal start_column, location.start_column, -> { "Expected start_column to be #{start_column}" } + assert_equal end_column, location.end_column, -> { "Expected end_column to be #{end_column}" } end end end diff --git a/test/prism/snapshots/blocks.txt b/test/prism/snapshots/blocks.txt index 7b3164c3f1..91a0735960 100644 --- a/test/prism/snapshots/blocks.txt +++ b/test/prism/snapshots/blocks.txt @@ -743,7 +743,7 @@ │ │ │ ├── optionals: (length: 0) │ │ │ ├── rest: │ │ │ │ @ RestParameterNode (location: (54,11)-(54,12)) - │ │ │ │ ├── name: nil + │ │ │ │ ├── name: ∅ │ │ │ │ ├── name_loc: ∅ │ │ │ │ └── operator_loc: (54,11)-(54,12) = "," │ │ │ ├── posts: (length: 0) diff --git a/test/prism/snapshots/dash_heredocs.txt b/test/prism/snapshots/dash_heredocs.txt index 6a0fe432fb..4c76b61d5c 100644 --- a/test/prism/snapshots/dash_heredocs.txt +++ b/test/prism/snapshots/dash_heredocs.txt @@ -6,16 +6,16 @@ ├── @ StringNode (location: (1,0)-(1,6)) │ ├── flags: ∅ │ ├── opening_loc: (1,0)-(1,6) = "<<-EOF" - │ ├── content_loc: (2,0)-(2,0) = " a\n" - │ ├── closing_loc: (3,0)-(3,0) = "EOF\n" + │ ├── content_loc: (2,0)-(3,0) = " a\n" + │ ├── closing_loc: (3,0)-(4,0) = "EOF\n" │ └── unescaped: " a\n" ├── @ CallNode (location: (5,0)-(5,20)) │ ├── receiver: │ │ @ StringNode (location: (5,0)-(5,8)) │ │ ├── flags: ∅ │ │ ├── opening_loc: (5,0)-(5,8) = "<<-FIRST" - │ │ ├── content_loc: (6,0)-(6,0) = " a\n" - │ │ ├── closing_loc: (7,0)-(7,0) = "FIRST\n" + │ │ ├── content_loc: (6,0)-(7,0) = " a\n" + │ │ ├── closing_loc: (7,0)-(8,0) = "FIRST\n" │ │ └── unescaped: " a\n" │ ├── call_operator_loc: ∅ │ ├── message_loc: (5,9)-(5,10) = "+" @@ -26,8 +26,8 @@ │ │ │ └── @ StringNode (location: (5,11)-(5,20)) │ │ │ ├── flags: ∅ │ │ │ ├── opening_loc: (5,11)-(5,20) = "<<-SECOND" - │ │ │ ├── content_loc: (8,0)-(8,0) = " b\n" - │ │ │ ├── closing_loc: (9,0)-(9,0) = "SECOND\n" + │ │ │ ├── content_loc: (8,0)-(9,0) = " b\n" + │ │ │ ├── closing_loc: (9,0)-(10,0) = "SECOND\n" │ │ │ └── unescaped: " b\n" │ │ └── flags: ∅ │ ├── closing_loc: ∅ @@ -37,10 +37,10 @@ ├── @ InterpolatedXStringNode (location: (11,0)-(11,8)) │ ├── opening_loc: (11,0)-(11,8) = "<<-`EOF`" │ ├── parts: (length: 3) - │ │ ├── @ StringNode (location: (12,0)-(12,0)) + │ │ ├── @ StringNode (location: (12,0)-(13,0)) │ │ │ ├── flags: ∅ │ │ │ ├── opening_loc: ∅ - │ │ │ ├── content_loc: (12,0)-(12,0) = " a\n" + │ │ │ ├── content_loc: (12,0)-(13,0) = " a\n" │ │ │ ├── closing_loc: ∅ │ │ │ └── unescaped: " a\n" │ │ ├── @ EmbeddedStatementsNode (location: (13,0)-(13,4)) @@ -59,32 +59,32 @@ │ │ │ │ ├── flags: variable_call │ │ │ │ └── name: :b │ │ │ └── closing_loc: (13,3)-(13,4) = "}" - │ │ └── @ StringNode (location: (13,4)-(13,0)) + │ │ └── @ StringNode (location: (13,4)-(14,0)) │ │ ├── flags: ∅ │ │ ├── opening_loc: ∅ - │ │ ├── content_loc: (13,4)-(13,0) = "\n" + │ │ ├── content_loc: (13,4)-(14,0) = "\n" │ │ ├── closing_loc: ∅ │ │ └── unescaped: "\n" - │ └── closing_loc: (14,0)-(14,0) = "EOF\n" + │ └── closing_loc: (14,0)-(15,0) = "EOF\n" ├── @ StringNode (location: (16,0)-(16,6)) │ ├── flags: ∅ │ ├── opening_loc: (16,0)-(16,6) = "<<-EOF" - │ ├── content_loc: (17,0)-(17,0) = " a\n" - │ ├── closing_loc: (18,0)-(18,0) = "EOF\n" + │ ├── content_loc: (17,0)-(18,0) = " a\n" + │ ├── closing_loc: (18,0)-(19,0) = "EOF\n" │ └── unescaped: " a\n" ├── @ StringNode (location: (20,0)-(20,6)) │ ├── flags: ∅ │ ├── opening_loc: (20,0)-(20,6) = "<<-EOF" - │ ├── content_loc: (21,0)-(22,0) = " a\n b\n" - │ ├── closing_loc: (23,0)-(23,0) = " EOF\n" + │ ├── content_loc: (21,0)-(23,0) = " a\n b\n" + │ ├── closing_loc: (23,0)-(24,0) = " EOF\n" │ └── unescaped: " a\n b\n" ├── @ InterpolatedStringNode (location: (25,0)-(25,8)) │ ├── opening_loc: (25,0)-(25,8) = "<<-\"EOF\"" │ ├── parts: (length: 3) - │ │ ├── @ StringNode (location: (26,0)-(26,0)) + │ │ ├── @ StringNode (location: (26,0)-(27,0)) │ │ │ ├── flags: ∅ │ │ │ ├── opening_loc: ∅ - │ │ │ ├── content_loc: (26,0)-(26,0) = " a\n" + │ │ │ ├── content_loc: (26,0)-(27,0) = " a\n" │ │ │ ├── closing_loc: ∅ │ │ │ └── unescaped: " a\n" │ │ ├── @ EmbeddedStatementsNode (location: (27,0)-(27,4)) @@ -103,20 +103,20 @@ │ │ │ │ ├── flags: variable_call │ │ │ │ └── name: :b │ │ │ └── closing_loc: (27,3)-(27,4) = "}" - │ │ └── @ StringNode (location: (27,4)-(27,0)) + │ │ └── @ StringNode (location: (27,4)-(28,0)) │ │ ├── flags: ∅ │ │ ├── opening_loc: ∅ - │ │ ├── content_loc: (27,4)-(27,0) = "\n" + │ │ ├── content_loc: (27,4)-(28,0) = "\n" │ │ ├── closing_loc: ∅ │ │ └── unescaped: "\n" - │ └── closing_loc: (28,0)-(28,0) = "EOF\n" + │ └── closing_loc: (28,0)-(29,0) = "EOF\n" ├── @ InterpolatedStringNode (location: (30,0)-(30,6)) │ ├── opening_loc: (30,0)-(30,6) = "<<-EOF" │ ├── parts: (length: 3) - │ │ ├── @ StringNode (location: (31,0)-(31,0)) + │ │ ├── @ StringNode (location: (31,0)-(32,0)) │ │ │ ├── flags: ∅ │ │ │ ├── opening_loc: ∅ - │ │ │ ├── content_loc: (31,0)-(31,0) = " a\n" + │ │ │ ├── content_loc: (31,0)-(32,0) = " a\n" │ │ │ ├── closing_loc: ∅ │ │ │ └── unescaped: " a\n" │ │ ├── @ EmbeddedStatementsNode (location: (32,0)-(32,4)) @@ -135,13 +135,13 @@ │ │ │ │ ├── flags: variable_call │ │ │ │ └── name: :b │ │ │ └── closing_loc: (32,3)-(32,4) = "}" - │ │ └── @ StringNode (location: (32,4)-(32,0)) + │ │ └── @ StringNode (location: (32,4)-(33,0)) │ │ ├── flags: ∅ │ │ ├── opening_loc: ∅ - │ │ ├── content_loc: (32,4)-(32,0) = "\n" + │ │ ├── content_loc: (32,4)-(33,0) = "\n" │ │ ├── closing_loc: ∅ │ │ └── unescaped: "\n" - │ └── closing_loc: (33,0)-(33,0) = "EOF\n" + │ └── closing_loc: (33,0)-(34,0) = "EOF\n" ├── @ StringNode (location: (35,0)-(35,6)) │ ├── flags: ∅ │ ├── opening_loc: (35,0)-(35,2) = "%#" @@ -151,28 +151,28 @@ ├── @ StringNode (location: (37,0)-(37,6)) │ ├── flags: ∅ │ ├── opening_loc: (37,0)-(37,6) = "<<-EOF" - │ ├── content_loc: (38,0)-(39,0) = " a\n b\n" - │ ├── closing_loc: (40,0)-(40,0) = "EOF\n" + │ ├── content_loc: (38,0)-(40,0) = " a\n b\n" + │ ├── closing_loc: (40,0)-(41,0) = "EOF\n" │ └── unescaped: " a\n b\n" ├── @ StringNode (location: (42,0)-(42,5)) │ ├── flags: ∅ │ ├── opening_loc: (42,0)-(42,5) = "<<-''" - │ ├── content_loc: (43,0)-(42,0) = "" - │ ├── closing_loc: (43,0)-(43,0) = "\n" + │ ├── content_loc: (43,0)-(43,0) = "" + │ ├── closing_loc: (43,0)-(44,0) = "\n" │ └── unescaped: "" ├── @ StringNode (location: (45,0)-(45,8)) │ ├── flags: ∅ │ ├── opening_loc: (45,0)-(45,8) = "<<-'EOF'" - │ ├── content_loc: (46,0)-(46,0) = " a \#{1}\n" - │ ├── closing_loc: (47,0)-(47,0) = "EOF\n" + │ ├── content_loc: (46,0)-(47,0) = " a \#{1}\n" + │ ├── closing_loc: (47,0)-(48,0) = "EOF\n" │ └── unescaped: " a \#{1}\n" ├── @ CallNode (location: (49,0)-(49,11)) │ ├── receiver: │ │ @ StringNode (location: (49,0)-(49,4)) │ │ ├── flags: ∅ │ │ ├── opening_loc: (49,0)-(49,4) = "<<-A" - │ │ ├── content_loc: (50,0)-(50,0) = " a\n" - │ │ ├── closing_loc: (51,0)-(51,0) = "A\n" + │ │ ├── content_loc: (50,0)-(51,0) = " a\n" + │ │ ├── closing_loc: (51,0)-(52,0) = "A\n" │ │ └── unescaped: " a\n" │ ├── call_operator_loc: ∅ │ ├── message_loc: (49,5)-(49,6) = "+" @@ -197,13 +197,13 @@ │ │ │ │ │ │ └── @ IntegerNode (location: (53,4)-(53,5)) │ │ │ │ │ │ └── flags: decimal │ │ │ │ │ └── closing_loc: (54,2)-(54,3) = "}" - │ │ │ │ └── @ StringNode (location: (54,3)-(54,0)) + │ │ │ │ └── @ StringNode (location: (54,3)-(55,0)) │ │ │ │ ├── flags: ∅ │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ ├── content_loc: (54,3)-(54,0) = "\n" + │ │ │ │ ├── content_loc: (54,3)-(55,0) = "\n" │ │ │ │ ├── closing_loc: ∅ │ │ │ │ └── unescaped: "\n" - │ │ │ └── closing_loc: (55,0)-(55,0) = "B\n" + │ │ │ └── closing_loc: (55,0)-(56,0) = "B\n" │ │ └── flags: ∅ │ ├── closing_loc: ∅ │ ├── block: ∅ @@ -214,8 +214,8 @@ │ @ StringNode (location: (57,0)-(57,4)) │ ├── flags: ∅ │ ├── opening_loc: (57,0)-(57,4) = "<<-A" - │ ├── content_loc: (58,0)-(58,0) = " a\n" - │ ├── closing_loc: (59,0)-(59,0) = "A\n" + │ ├── content_loc: (58,0)-(59,0) = " a\n" + │ ├── closing_loc: (59,0)-(60,0) = "A\n" │ └── unescaped: " a\n" ├── call_operator_loc: ∅ ├── message_loc: (57,5)-(57,6) = "+" @@ -240,13 +240,13 @@ │ │ │ │ │ └── @ IntegerNode (location: (62,2)-(62,3)) │ │ │ │ │ └── flags: decimal │ │ │ │ └── closing_loc: (62,3)-(62,4) = "}" - │ │ │ └── @ StringNode (location: (62,4)-(62,0)) + │ │ │ └── @ StringNode (location: (62,4)-(63,0)) │ │ │ ├── flags: ∅ │ │ │ ├── opening_loc: ∅ - │ │ │ ├── content_loc: (62,4)-(62,0) = "\n" + │ │ │ ├── content_loc: (62,4)-(63,0) = "\n" │ │ │ ├── closing_loc: ∅ │ │ │ └── unescaped: "\n" - │ │ └── closing_loc: (63,0)-(63,0) = "B\n" + │ │ └── closing_loc: (63,0)-(64,0) = "B\n" │ └── flags: ∅ ├── closing_loc: ∅ ├── block: ∅ diff --git a/test/prism/snapshots/dos_endings.txt b/test/prism/snapshots/dos_endings.txt index da4c8b5ebe..758334138c 100644 --- a/test/prism/snapshots/dos_endings.txt +++ b/test/prism/snapshots/dos_endings.txt @@ -43,19 +43,19 @@ ├── @ StringNode (location: (7,0)-(7,4)) │ ├── flags: ∅ │ ├── opening_loc: (7,0)-(7,4) = "<<-E" - │ ├── content_loc: (8,0)-(10,0) = " 1 \\\r\n 2\r\n 3\r\n" - │ ├── closing_loc: (11,0)-(11,0) = "E\r\n" + │ ├── content_loc: (8,0)-(11,0) = " 1 \\\r\n 2\r\n 3\r\n" + │ ├── closing_loc: (11,0)-(12,0) = "E\r\n" │ └── unescaped: " 1 2\r\n 3\r\n" - ├── @ LocalVariableWriteNode (location: (13,0)-(14,0)) + ├── @ LocalVariableWriteNode (location: (13,0)-(15,0)) │ ├── name: :x │ ├── depth: 0 │ ├── name_loc: (13,0)-(13,1) = "x" │ ├── value: - │ │ @ StringNode (location: (13,4)-(14,0)) + │ │ @ StringNode (location: (13,4)-(15,0)) │ │ ├── flags: ∅ - │ │ ├── opening_loc: (13,4)-(13,0) = "%\r\n" - │ │ ├── content_loc: (14,0)-(13,0) = "" - │ │ ├── closing_loc: (14,0)-(14,0) = "\r\n" + │ │ ├── opening_loc: (13,4)-(14,0) = "%\r\n" + │ │ ├── content_loc: (14,0)-(14,0) = "" + │ │ ├── closing_loc: (14,0)-(15,0) = "\r\n" │ │ └── unescaped: "" │ └── operator_loc: (13,2)-(13,3) = "=" └── @ LocalVariableWriteNode (location: (17,0)-(17,20)) @@ -76,19 +76,19 @@ │ │ │ │ @ InterpolatedStringNode (location: (17,8)-(17,14)) │ │ │ │ ├── opening_loc: (17,8)-(17,14) = "<<~EOF" │ │ │ │ ├── parts: (length: 2) - │ │ │ │ │ ├── @ StringNode (location: (18,0)-(18,0)) + │ │ │ │ │ ├── @ StringNode (location: (18,0)-(19,0)) │ │ │ │ │ │ ├── flags: ∅ │ │ │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ │ │ ├── content_loc: (18,0)-(18,0) = "\r\n" + │ │ │ │ │ │ ├── content_loc: (18,0)-(19,0) = "\r\n" │ │ │ │ │ │ ├── closing_loc: ∅ │ │ │ │ │ │ └── unescaped: "\n" - │ │ │ │ │ └── @ StringNode (location: (19,0)-(19,0)) + │ │ │ │ │ └── @ StringNode (location: (19,0)-(20,0)) │ │ │ │ │ ├── flags: ∅ │ │ │ │ │ ├── opening_loc: ∅ - │ │ │ │ │ ├── content_loc: (19,0)-(19,0) = " baz\r\n" + │ │ │ │ │ ├── content_loc: (19,0)-(20,0) = " baz\r\n" │ │ │ │ │ ├── closing_loc: ∅ │ │ │ │ │ └── unescaped: "baz\r\n" - │ │ │ │ └── closing_loc: (20,0)-(20,0) = " EOF\r\n" + │ │ │ │ └── closing_loc: (20,0)-(21,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/embdoc_no_newline_at_end.txt b/test/prism/snapshots/embdoc_no_newline_at_end.txt index 870bdb6ad5..3a21ce5559 100644 --- a/test/prism/snapshots/embdoc_no_newline_at_end.txt +++ b/test/prism/snapshots/embdoc_no_newline_at_end.txt @@ -1,5 +1,5 @@ -@ ProgramNode (location: (1,0)-(0,0)) +@ ProgramNode (location: (1,0)-(1,0)) ├── locals: [] └── statements: - @ StatementsNode (location: (1,0)-(0,0)) + @ StatementsNode (location: (1,0)-(1,0)) └── body: (length: 0) diff --git a/test/prism/snapshots/heredoc_with_escaped_newline_at_start.txt b/test/prism/snapshots/heredoc_with_escaped_newline_at_start.txt index e7b45833cf..b403d618fc 100644 --- a/test/prism/snapshots/heredoc_with_escaped_newline_at_start.txt +++ b/test/prism/snapshots/heredoc_with_escaped_newline_at_start.txt @@ -8,8 +8,8 @@ │ │ @ StringNode (location: (1,0)-(1,9)) │ │ ├── flags: ∅ │ │ ├── opening_loc: (1,0)-(1,9) = "<<-TARGET" - │ │ ├── content_loc: (2,0)-(1,0) = "" - │ │ ├── closing_loc: (2,0)-(2,0) = "TARGET\n" + │ │ ├── content_loc: (2,0)-(2,0) = "" + │ │ ├── closing_loc: (2,0)-(3,0) = "TARGET\n" │ │ └── unescaped: "" │ ├── call_operator_loc: (1,9)-(1,10) = "." │ ├── message_loc: (1,10)-(1,14) = "gsub" @@ -39,8 +39,8 @@ │ @ StringNode (location: (5,0)-(5,9)) │ ├── flags: ∅ │ ├── opening_loc: (5,0)-(5,9) = "<<-TARGET" - │ ├── content_loc: (6,0)-(5,0) = "" - │ ├── closing_loc: (6,0)-(6,0) = "TARGET\r\n" + │ ├── content_loc: (6,0)-(6,0) = "" + │ ├── closing_loc: (6,0)-(7,0) = "TARGET\r\n" │ └── unescaped: "" ├── call_operator_loc: (5,9)-(5,10) = "." ├── message_loc: (5,10)-(5,14) = "gsub" diff --git a/test/prism/snapshots/heredoc_with_trailing_newline.txt b/test/prism/snapshots/heredoc_with_trailing_newline.txt index 01178042d6..b064931aa8 100644 --- a/test/prism/snapshots/heredoc_with_trailing_newline.txt +++ b/test/prism/snapshots/heredoc_with_trailing_newline.txt @@ -6,6 +6,6 @@ └── @ StringNode (location: (1,0)-(1,6)) ├── flags: ∅ ├── opening_loc: (1,0)-(1,6) = "<<-END" - ├── content_loc: (2,0)-(1,0) = "" + ├── content_loc: (2,0)-(2,0) = "" ├── closing_loc: (2,0)-(2,3) = "END" └── unescaped: "" diff --git a/test/prism/snapshots/heredocs_nested.txt b/test/prism/snapshots/heredocs_nested.txt index 0e76652072..f03aabc63a 100644 --- a/test/prism/snapshots/heredocs_nested.txt +++ b/test/prism/snapshots/heredocs_nested.txt @@ -6,10 +6,10 @@ └── @ InterpolatedStringNode (location: (1,0)-(1,7)) ├── opening_loc: (1,0)-(1,7) = "<<~RUBY" ├── parts: (length: 4) - │ ├── @ StringNode (location: (2,0)-(2,0)) + │ ├── @ StringNode (location: (2,0)-(3,0)) │ │ ├── flags: ∅ │ │ ├── opening_loc: ∅ - │ │ ├── content_loc: (2,0)-(2,0) = "pre\n" + │ │ ├── content_loc: (2,0)-(3,0) = "pre\n" │ │ ├── closing_loc: ∅ │ │ └── unescaped: "pre\n" │ ├── @ EmbeddedStatementsNode (location: (3,0)-(7,1)) @@ -20,20 +20,20 @@ │ │ │ └── @ StringNode (location: (4,0)-(4,6)) │ │ │ ├── flags: ∅ │ │ │ ├── opening_loc: (4,0)-(4,6) = "<