diff --git a/src/analyze.c b/src/analyze.c index 348242453..61cf86463 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -515,21 +515,7 @@ static size_t process_control_structure( index++; - while (index < hb_array_size(array)) { - AST_NODE_T* child = hb_array_get(array, index); - - if (!child) { break; } - - if (child->type == AST_ERB_CONTENT_NODE) { - AST_ERB_CONTENT_NODE_T* child_erb = (AST_ERB_CONTENT_NODE_T*) child; - control_type_t child_type = detect_control_type(child_erb); - - if (child_type == CONTROL_TYPE_END) { break; } - } - - hb_array_append(else_children, child); - index++; - } + index = process_block_children(node, array, index, else_children, context, initial_type); hb_array_T* else_errors = next_erb->base.errors; next_erb->base.errors = NULL; @@ -677,21 +663,7 @@ static size_t process_control_structure( index++; - while (index < hb_array_size(array)) { - AST_NODE_T* child = hb_array_get(array, index); - - if (!child) { break; } - - if (child->type == AST_ERB_CONTENT_NODE) { - AST_ERB_CONTENT_NODE_T* child_erb = (AST_ERB_CONTENT_NODE_T*) child; - control_type_t child_type = detect_control_type(child_erb); - - if (child_type == CONTROL_TYPE_ENSURE || child_type == CONTROL_TYPE_END) { break; } - } - - hb_array_append(else_children, child); - index++; - } + index = process_block_children(node, array, index, else_children, context, initial_type); hb_array_T* else_errors = next_erb->base.errors; next_erb->base.errors = NULL; diff --git a/test/parser/case_match_test.rb b/test/parser/case_match_test.rb index f074851c7..3c167f7ee 100644 --- a/test/parser/case_match_test.rb +++ b/test/parser/case_match_test.rb @@ -17,5 +17,50 @@ class CaseMatchTest < Minitest::Spec <% end %> HTML end + + test "case/in with if inside else branch" do + assert_parsed_snapshot(<<~HTML) + <% case value %> + <% in Integer %> +
Integer
+ <% else %> + <% if unknown? %> +Unknown type
+ <% end %> + <% end %> + HTML + end + + test "case/in with nested case/in inside else branch" do + assert_parsed_snapshot(<<~HTML) + <% case data %> + <% in { type: "primary" } %> +Primary
+ <% else %> + <% case fallback %> + <% in { status: "ok" } %> +OK
+ <% in { status: "error" } %> +Error
+ <% end %> + <% end %> + HTML + end + + test "case/in with multiple nested structures in else branch" do + assert_parsed_snapshot(<<~HTML) + <% case result %> + <% in { success: true } %> +Success
+ <% else %> + <% if retry? %> +Retrying
+ <% end %> + <% unless failed? %> +Still processing
+ <% end %> + <% end %> + HTML + end end end diff --git a/test/parser/case_when_test.rb b/test/parser/case_when_test.rb index fe279ba8b..d54a38780 100644 --- a/test/parser/case_when_test.rb +++ b/test/parser/case_when_test.rb @@ -19,5 +19,95 @@ class CaseWhenTest < Minitest::Spec <% end %> HTML end + + test "case/when with if inside else branch (issue 860)" do + assert_parsed_snapshot(<<~HTML) + <% case %> + <% when true %> + 1 + <% else %> + <% if true %> + 2 + <% end %> + <% end %> + HTML + end + + test "case/when with if/elsif/else inside else branch" do + assert_parsed_snapshot(<<~HTML) + <% case status %> + <% when :active %> +Active
+ <% else %> + <% if admin? %> +Admin view
+ <% elsif moderator? %> +Moderator view
+ <% else %> +User view
+ <% end %> + <% end %> + HTML + end + + test "case/when with unless inside else branch" do + assert_parsed_snapshot(<<~HTML) + <% case role %> + <% when :admin %> +Admin
+ <% else %> + <% unless guest? %> +Authenticated
+ <% end %> + <% end %> + HTML + end + + test "case/when with nested case inside else branch" do + assert_parsed_snapshot(<<~HTML) + <% case type %> + <% when :primary %> +Primary
+ <% else %> + <% case subtype %> + <% when :secondary %> +Secondary
+ <% when :tertiary %> +Tertiary
+ <% end %> + <% end %> + HTML + end + + test "case/when with multiple nested control structures in else branch" do + assert_parsed_snapshot(<<~HTML) + <% case status %> + <% when :ok %> +OK
+ <% else %> + <% if error? %> +Error
+ <% end %> + <% unless success? %> +Not successful
+ <% end %> + <% end %> + HTML + end + + test "case/when with begin/rescue inside else branch" do + assert_parsed_snapshot(<<~HTML) + <% case result %> + <% when :success %> +Success
+ <% else %> + <% begin %> +Attempting fallback
+ <% rescue %> +Fallback failed
+ <% end %> + <% end %> + HTML + end end end diff --git a/test/snapshots/parser/case_match_test/test_0002_case_in_with_if_inside_else_branch_144505ff9e38742a1a905efebc9a92cc.txt b/test/snapshots/parser/case_match_test/test_0002_case_in_with_if_inside_else_branch_144505ff9e38742a1a905efebc9a92cc.txt new file mode 100644 index 000000000..9be1d15f7 --- /dev/null +++ b/test/snapshots/parser/case_match_test/test_0002_case_in_with_if_inside_else_branch_144505ff9e38742a1a905efebc9a92cc.txt @@ -0,0 +1,124 @@ +--- +source: "Parser::CaseMatchTest#test_0002_case/in with if inside else branch" +input: |2- +<% case value %> +<% in Integer %> +Integer
+<% else %> + <% if unknown? %> +Unknown type
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(9:0)) +└── children: (2 items) + ├── @ ERBCaseMatchNode (location: (1:0)-(8:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case value " (location: (1:2)-(1:14)) + │ ├── tag_closing: "%>" (location: (1:14)-(1:16)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:16)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBInNode (location: (2:0)-(2:16)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " in Integer " (location: (2:2)-(2:14)) + │ │ ├── tag_closing: "%>" (location: (2:14)-(2:16)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:16)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:16)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:12)) + │ │ │ │ └── content: "Integer" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:12)-(3:16)) + │ │ │ │ ├── tag_opening: "" (location: (3:12)-(3:14)) + │ │ │ │ ├── tag_name: "p" (location: (3:14)-(3:15)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:15)-(3:16)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:16)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBIfNode (location: (5:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " if unknown? " (location: (5:4)-(5:17)) + │ │ │ ├── tag_closing: "%>" (location: (5:17)-(5:19)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (5:19)-(6:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (6:4)-(6:23)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (6:4)-(6:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (6:4)-(6:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (6:6)-(6:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (6:7)-(6:19)) + │ │ │ │ │ │ └── content: "Unknown type" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (6:19)-(6:23)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (6:19)-(6:21)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:21)-(6:22)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (6:22)-(6:23)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (6:23)-(7:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── subsequent: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (7:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (7:2)-(7:4)) + │ │ │ ├── content: " end " (location: (7:4)-(7:9)) + │ │ │ └── tag_closing: "%>" (location: (7:9)-(7:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (7:11)-(8:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (8:0)-(8:9)) + │ ├── tag_opening: "<%" (location: (8:0)-(8:2)) + │ ├── content: " end " (location: (8:2)-(8:7)) + │ └── tag_closing: "%>" (location: (8:7)-(8:9)) + │ + │ + └── @ HTMLTextNode (location: (8:9)-(9:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_match_test/test_0003_case_in_with_nested_case_in_inside_else_branch_155bfe881962a6030a91815dc33f9694.txt b/test/snapshots/parser/case_match_test/test_0003_case_in_with_nested_case_in_inside_else_branch_155bfe881962a6030a91815dc33f9694.txt new file mode 100644 index 000000000..e5a91be5e --- /dev/null +++ b/test/snapshots/parser/case_match_test/test_0003_case_in_with_nested_case_in_inside_else_branch_155bfe881962a6030a91815dc33f9694.txt @@ -0,0 +1,173 @@ +--- +source: "Parser::CaseMatchTest#test_0003_case/in with nested case/in inside else branch" +input: |2- +<% case data %> +<% in { type: "primary" } %> +Primary
+<% else %> + <% case fallback %> + <% in { status: "ok" } %> +OK
+ <% in { status: "error" } %> +Error
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(12:0)) +└── children: (2 items) + ├── @ ERBCaseMatchNode (location: (1:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case data " (location: (1:2)-(1:13)) + │ ├── tag_closing: "%>" (location: (1:13)-(1:15)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:15)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBInNode (location: (2:0)-(2:28)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " in { type: "primary" } " (location: (2:2)-(2:26)) + │ │ ├── tag_closing: "%>" (location: (2:26)-(2:28)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:28)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:16)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:12)) + │ │ │ │ └── content: "Primary" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:12)-(3:16)) + │ │ │ │ ├── tag_opening: "" (location: (3:12)-(3:14)) + │ │ │ │ ├── tag_name: "p" (location: (3:14)-(3:15)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:15)-(3:16)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:16)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBCaseMatchNode (location: (5:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " case fallback " (location: (5:4)-(5:19)) + │ │ │ ├── tag_closing: "%>" (location: (5:19)-(5:21)) + │ │ │ ├── children: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (5:21)-(6:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── conditions: (2 items) + │ │ │ │ ├── @ ERBInNode (location: (6:2)-(6:27)) + │ │ │ │ │ ├── tag_opening: "<%" (location: (6:2)-(6:4)) + │ │ │ │ │ ├── content: " in { status: "ok" } " (location: (6:4)-(6:25)) + │ │ │ │ │ ├── tag_closing: "%>" (location: (6:25)-(6:27)) + │ │ │ │ │ └── statements: (3 items) + │ │ │ │ │ ├── @ HTMLTextNode (location: (6:27)-(7:4)) + │ │ │ │ │ │ └── content: "\n " + │ │ │ │ │ │ + │ │ │ │ │ ├── @ HTMLElementNode (location: (7:4)-(7:13)) + │ │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (7:4)-(7:7)) + │ │ │ │ │ │ │ ├── tag_opening: "<" (location: (7:4)-(7:5)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (7:5)-(7:6)) + │ │ │ │ │ │ │ ├── tag_closing: ">" (location: (7:6)-(7:7)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── tag_name: "p" (location: (7:5)-(7:6)) + │ │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ │ └── @ HTMLTextNode (location: (7:7)-(7:9)) + │ │ │ │ │ │ │ └── content: "OK" + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (7:9)-(7:13)) + │ │ │ │ │ │ │ ├── tag_opening: "" (location: (7:9)-(7:11)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (7:11)-(7:12)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── tag_closing: ">" (location: (7:12)-(7:13)) + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── is_void: false + │ │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ │ + │ │ │ │ │ └── @ HTMLTextNode (location: (7:13)-(8:2)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ │ + │ │ │ │ └── @ ERBInNode (location: (8:2)-(8:30)) + │ │ │ │ ├── tag_opening: "<%" (location: (8:2)-(8:4)) + │ │ │ │ ├── content: " in { status: "error" } " (location: (8:4)-(8:28)) + │ │ │ │ ├── tag_closing: "%>" (location: (8:28)-(8:30)) + │ │ │ │ └── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (8:30)-(9:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (9:4)-(9:16)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (9:4)-(9:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (9:4)-(9:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (9:6)-(9:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (9:7)-(9:12)) + │ │ │ │ │ │ └── content: "Error" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (9:12)-(9:16)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (9:12)-(9:14)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:14)-(9:15)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (9:15)-(9:16)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (9:16)-(10:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ │ + │ │ │ ├── else_clause: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (10:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (10:2)-(10:4)) + │ │ │ ├── content: " end " (location: (10:4)-(10:9)) + │ │ │ └── tag_closing: "%>" (location: (10:9)-(10:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (10:11)-(11:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (11:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (11:0)-(11:2)) + │ ├── content: " end " (location: (11:2)-(11:7)) + │ └── tag_closing: "%>" (location: (11:7)-(11:9)) + │ + │ + └── @ HTMLTextNode (location: (11:9)-(12:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_match_test/test_0004_case_in_with_multiple_nested_structures_in_else_branch_f60c2a24b2c2b42b801e6dd736940e3e.txt b/test/snapshots/parser/case_match_test/test_0004_case_in_with_multiple_nested_structures_in_else_branch_f60c2a24b2c2b42b801e6dd736940e3e.txt new file mode 100644 index 000000000..5ed4fbf47 --- /dev/null +++ b/test/snapshots/parser/case_match_test/test_0004_case_in_with_multiple_nested_structures_in_else_branch_f60c2a24b2c2b42b801e6dd736940e3e.txt @@ -0,0 +1,173 @@ +--- +source: "Parser::CaseMatchTest#test_0004_case/in with multiple nested structures in else branch" +input: |2- +<% case result %> +<% in { success: true } %> +Success
+<% else %> + <% if retry? %> +Retrying
+ <% end %> + <% unless failed? %> +Still processing
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(12:0)) +└── children: (2 items) + ├── @ ERBCaseMatchNode (location: (1:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case result " (location: (1:2)-(1:15)) + │ ├── tag_closing: "%>" (location: (1:15)-(1:17)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:17)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBInNode (location: (2:0)-(2:26)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " in { success: true } " (location: (2:2)-(2:24)) + │ │ ├── tag_closing: "%>" (location: (2:24)-(2:26)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:26)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:16)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:12)) + │ │ │ │ └── content: "Success" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:12)-(3:16)) + │ │ │ │ ├── tag_opening: "" (location: (3:12)-(3:14)) + │ │ │ │ ├── tag_name: "p" (location: (3:14)-(3:15)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:15)-(3:16)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:16)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (5 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBIfNode (location: (5:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " if retry? " (location: (5:4)-(5:15)) + │ │ │ ├── tag_closing: "%>" (location: (5:15)-(5:17)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (5:17)-(6:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (6:4)-(6:19)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (6:4)-(6:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (6:4)-(6:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (6:6)-(6:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (6:7)-(6:15)) + │ │ │ │ │ │ └── content: "Retrying" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (6:15)-(6:19)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (6:15)-(6:17)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:17)-(6:18)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (6:18)-(6:19)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (6:19)-(7:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── subsequent: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (7:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (7:2)-(7:4)) + │ │ │ ├── content: " end " (location: (7:4)-(7:9)) + │ │ │ └── tag_closing: "%>" (location: (7:9)-(7:11)) + │ │ │ + │ │ │ + │ │ ├── @ HTMLTextNode (location: (7:11)-(8:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBUnlessNode (location: (8:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (8:2)-(8:4)) + │ │ │ ├── content: " unless failed? " (location: (8:4)-(8:20)) + │ │ │ ├── tag_closing: "%>" (location: (8:20)-(8:22)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (8:22)-(9:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (9:4)-(9:27)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (9:4)-(9:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (9:4)-(9:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (9:6)-(9:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (9:7)-(9:23)) + │ │ │ │ │ │ └── content: "Still processing" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (9:23)-(9:27)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (9:23)-(9:25)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:25)-(9:26)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (9:26)-(9:27)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (9:27)-(10:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── else_clause: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (10:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (10:2)-(10:4)) + │ │ │ ├── content: " end " (location: (10:4)-(10:9)) + │ │ │ └── tag_closing: "%>" (location: (10:9)-(10:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (10:11)-(11:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (11:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (11:0)-(11:2)) + │ ├── content: " end " (location: (11:2)-(11:7)) + │ └── tag_closing: "%>" (location: (11:7)-(11:9)) + │ + │ + └── @ HTMLTextNode (location: (11:9)-(12:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_when_test/test_0002_case_when_with_if_inside_else_branch_(issue_860)_34a45948c31ab5973e0d05f3f4c7a9a2.txt b/test/snapshots/parser/case_when_test/test_0002_case_when_with_if_inside_else_branch_(issue_860)_34a45948c31ab5973e0d05f3f4c7a9a2.txt new file mode 100644 index 000000000..aeb89af28 --- /dev/null +++ b/test/snapshots/parser/case_when_test/test_0002_case_when_with_if_inside_else_branch_(issue_860)_34a45948c31ab5973e0d05f3f4c7a9a2.txt @@ -0,0 +1,70 @@ +--- +source: "Parser::CaseWhenTest#test_0002_case/when with if inside else branch (issue 860)" +input: |2- +<% case %> +<% when true %> + 1 +<% else %> + <% if true %> + 2 + <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(9:0)) +└── children: (2 items) + ├── @ ERBCaseNode (location: (1:0)-(8:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case " (location: (1:2)-(1:8)) + │ ├── tag_closing: "%>" (location: (1:8)-(1:10)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:10)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBWhenNode (location: (2:0)-(2:15)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " when true " (location: (2:2)-(2:13)) + │ │ ├── tag_closing: "%>" (location: (2:13)-(2:15)) + │ │ └── statements: (1 item) + │ │ └── @ HTMLTextNode (location: (2:15)-(4:0)) + │ │ └── content: "\n 1\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBIfNode (location: (5:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " if true " (location: (5:4)-(5:13)) + │ │ │ ├── tag_closing: "%>" (location: (5:13)-(5:15)) + │ │ │ ├── statements: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (5:15)-(7:2)) + │ │ │ │ └── content: "\n 2\n " + │ │ │ │ + │ │ │ ├── subsequent: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (7:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (7:2)-(7:4)) + │ │ │ ├── content: " end " (location: (7:4)-(7:9)) + │ │ │ └── tag_closing: "%>" (location: (7:9)-(7:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (7:11)-(8:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (8:0)-(8:9)) + │ ├── tag_opening: "<%" (location: (8:0)-(8:2)) + │ ├── content: " end " (location: (8:2)-(8:7)) + │ └── tag_closing: "%>" (location: (8:7)-(8:9)) + │ + │ + └── @ HTMLTextNode (location: (8:9)-(9:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_when_test/test_0003_case_when_with_if_elsif_else_inside_else_branch_ad48672c28b85022b600280a2f864a4e.txt b/test/snapshots/parser/case_when_test/test_0003_case_when_with_if_elsif_else_inside_else_branch_ad48672c28b85022b600280a2f864a4e.txt new file mode 100644 index 000000000..c1b5628bb --- /dev/null +++ b/test/snapshots/parser/case_when_test/test_0003_case_when_with_if_elsif_else_inside_else_branch_ad48672c28b85022b600280a2f864a4e.txt @@ -0,0 +1,202 @@ +--- +source: "Parser::CaseWhenTest#test_0003_case/when with if/elsif/else inside else branch" +input: |2- +<% case status %> +<% when :active %> +Active
+<% else %> + <% if admin? %> +Admin view
+ <% elsif moderator? %> +Moderator view
+ <% else %> +User view
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(13:0)) +└── children: (2 items) + ├── @ ERBCaseNode (location: (1:0)-(12:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case status " (location: (1:2)-(1:15)) + │ ├── tag_closing: "%>" (location: (1:15)-(1:17)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:17)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBWhenNode (location: (2:0)-(2:18)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " when :active " (location: (2:2)-(2:16)) + │ │ ├── tag_closing: "%>" (location: (2:16)-(2:18)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:18)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:15)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:11)) + │ │ │ │ └── content: "Active" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:11)-(3:15)) + │ │ │ │ ├── tag_opening: "" (location: (3:11)-(3:13)) + │ │ │ │ ├── tag_name: "p" (location: (3:13)-(3:14)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:14)-(3:15)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:15)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBIfNode (location: (5:2)-(11:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " if admin? " (location: (5:4)-(5:15)) + │ │ │ ├── tag_closing: "%>" (location: (5:15)-(5:17)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (5:17)-(6:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (6:4)-(6:21)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (6:4)-(6:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (6:4)-(6:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (6:6)-(6:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (6:7)-(6:17)) + │ │ │ │ │ │ └── content: "Admin view" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (6:17)-(6:21)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (6:17)-(6:19)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:19)-(6:20)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (6:20)-(6:21)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (6:21)-(7:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── subsequent: + │ │ │ │ └── @ ERBIfNode (location: (7:2)-(9:2)) + │ │ │ │ ├── tag_opening: "<%" (location: (7:2)-(7:4)) + │ │ │ │ ├── content: " elsif moderator? " (location: (7:4)-(7:22)) + │ │ │ │ ├── tag_closing: "%>" (location: (7:22)-(7:24)) + │ │ │ │ ├── statements: (3 items) + │ │ │ │ │ ├── @ HTMLTextNode (location: (7:24)-(8:4)) + │ │ │ │ │ │ └── content: "\n " + │ │ │ │ │ │ + │ │ │ │ │ ├── @ HTMLElementNode (location: (8:4)-(8:25)) + │ │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (8:4)-(8:7)) + │ │ │ │ │ │ │ ├── tag_opening: "<" (location: (8:4)-(8:5)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (8:5)-(8:6)) + │ │ │ │ │ │ │ ├── tag_closing: ">" (location: (8:6)-(8:7)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── tag_name: "p" (location: (8:5)-(8:6)) + │ │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ │ └── @ HTMLTextNode (location: (8:7)-(8:21)) + │ │ │ │ │ │ │ └── content: "Moderator view" + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (8:21)-(8:25)) + │ │ │ │ │ │ │ ├── tag_opening: "" (location: (8:21)-(8:23)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (8:23)-(8:24)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── tag_closing: ">" (location: (8:24)-(8:25)) + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── is_void: false + │ │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ │ + │ │ │ │ │ └── @ HTMLTextNode (location: (8:25)-(9:2)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── subsequent: + │ │ │ │ │ └── @ ERBElseNode (location: (9:2)-(11:2)) + │ │ │ │ │ ├── tag_opening: "<%" (location: (9:2)-(9:4)) + │ │ │ │ │ ├── content: " else " (location: (9:4)-(9:10)) + │ │ │ │ │ ├── tag_closing: "%>" (location: (9:10)-(9:12)) + │ │ │ │ │ └── statements: (3 items) + │ │ │ │ │ ├── @ HTMLTextNode (location: (9:12)-(10:4)) + │ │ │ │ │ │ └── content: "\n " + │ │ │ │ │ │ + │ │ │ │ │ ├── @ HTMLElementNode (location: (10:4)-(10:20)) + │ │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (10:4)-(10:7)) + │ │ │ │ │ │ │ ├── tag_opening: "<" (location: (10:4)-(10:5)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (10:5)-(10:6)) + │ │ │ │ │ │ │ ├── tag_closing: ">" (location: (10:6)-(10:7)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── tag_name: "p" (location: (10:5)-(10:6)) + │ │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ │ └── @ HTMLTextNode (location: (10:7)-(10:16)) + │ │ │ │ │ │ │ └── content: "User view" + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (10:16)-(10:20)) + │ │ │ │ │ │ │ ├── tag_opening: "" (location: (10:16)-(10:18)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (10:18)-(10:19)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── tag_closing: ">" (location: (10:19)-(10:20)) + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── is_void: false + │ │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ │ + │ │ │ │ │ └── @ HTMLTextNode (location: (10:20)-(11:2)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ │ + │ │ │ │ └── end_node: ∅ + │ │ │ │ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (11:2)-(11:11)) + │ │ │ ├── tag_opening: "<%" (location: (11:2)-(11:4)) + │ │ │ ├── content: " end " (location: (11:4)-(11:9)) + │ │ │ └── tag_closing: "%>" (location: (11:9)-(11:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (11:11)-(12:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (12:0)-(12:9)) + │ ├── tag_opening: "<%" (location: (12:0)-(12:2)) + │ ├── content: " end " (location: (12:2)-(12:7)) + │ └── tag_closing: "%>" (location: (12:7)-(12:9)) + │ + │ + └── @ HTMLTextNode (location: (12:9)-(13:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_when_test/test_0004_case_when_with_unless_inside_else_branch_e23ae6861d44f2fc4549bf6281bc50df.txt b/test/snapshots/parser/case_when_test/test_0004_case_when_with_unless_inside_else_branch_e23ae6861d44f2fc4549bf6281bc50df.txt new file mode 100644 index 000000000..66a0a796c --- /dev/null +++ b/test/snapshots/parser/case_when_test/test_0004_case_when_with_unless_inside_else_branch_e23ae6861d44f2fc4549bf6281bc50df.txt @@ -0,0 +1,124 @@ +--- +source: "Parser::CaseWhenTest#test_0004_case/when with unless inside else branch" +input: |2- +<% case role %> +<% when :admin %> +Admin
+<% else %> + <% unless guest? %> +Authenticated
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(9:0)) +└── children: (2 items) + ├── @ ERBCaseNode (location: (1:0)-(8:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case role " (location: (1:2)-(1:13)) + │ ├── tag_closing: "%>" (location: (1:13)-(1:15)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:15)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBWhenNode (location: (2:0)-(2:17)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " when :admin " (location: (2:2)-(2:15)) + │ │ ├── tag_closing: "%>" (location: (2:15)-(2:17)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:17)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:14)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:10)) + │ │ │ │ └── content: "Admin" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:10)-(3:14)) + │ │ │ │ ├── tag_opening: "" (location: (3:10)-(3:12)) + │ │ │ │ ├── tag_name: "p" (location: (3:12)-(3:13)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:13)-(3:14)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:14)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBUnlessNode (location: (5:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " unless guest? " (location: (5:4)-(5:19)) + │ │ │ ├── tag_closing: "%>" (location: (5:19)-(5:21)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (5:21)-(6:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (6:4)-(6:24)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (6:4)-(6:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (6:4)-(6:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (6:6)-(6:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (6:7)-(6:20)) + │ │ │ │ │ │ └── content: "Authenticated" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (6:20)-(6:24)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (6:20)-(6:22)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:22)-(6:23)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (6:23)-(6:24)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (6:24)-(7:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── else_clause: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (7:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (7:2)-(7:4)) + │ │ │ ├── content: " end " (location: (7:4)-(7:9)) + │ │ │ └── tag_closing: "%>" (location: (7:9)-(7:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (7:11)-(8:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (8:0)-(8:9)) + │ ├── tag_opening: "<%" (location: (8:0)-(8:2)) + │ ├── content: " end " (location: (8:2)-(8:7)) + │ └── tag_closing: "%>" (location: (8:7)-(8:9)) + │ + │ + └── @ HTMLTextNode (location: (8:9)-(9:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_when_test/test_0005_case_when_with_nested_case_inside_else_branch_d66fdcc5657378cb14c128615c5a974b.txt b/test/snapshots/parser/case_when_test/test_0005_case_when_with_nested_case_inside_else_branch_d66fdcc5657378cb14c128615c5a974b.txt new file mode 100644 index 000000000..f19bddb70 --- /dev/null +++ b/test/snapshots/parser/case_when_test/test_0005_case_when_with_nested_case_inside_else_branch_d66fdcc5657378cb14c128615c5a974b.txt @@ -0,0 +1,173 @@ +--- +source: "Parser::CaseWhenTest#test_0005_case/when with nested case inside else branch" +input: |2- +<% case type %> +<% when :primary %> +Primary
+<% else %> + <% case subtype %> + <% when :secondary %> +Secondary
+ <% when :tertiary %> +Tertiary
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(12:0)) +└── children: (2 items) + ├── @ ERBCaseNode (location: (1:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case type " (location: (1:2)-(1:13)) + │ ├── tag_closing: "%>" (location: (1:13)-(1:15)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:15)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBWhenNode (location: (2:0)-(2:19)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " when :primary " (location: (2:2)-(2:17)) + │ │ ├── tag_closing: "%>" (location: (2:17)-(2:19)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:19)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:16)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:12)) + │ │ │ │ └── content: "Primary" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:12)-(3:16)) + │ │ │ │ ├── tag_opening: "" (location: (3:12)-(3:14)) + │ │ │ │ ├── tag_name: "p" (location: (3:14)-(3:15)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:15)-(3:16)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:16)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBCaseNode (location: (5:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " case subtype " (location: (5:4)-(5:18)) + │ │ │ ├── tag_closing: "%>" (location: (5:18)-(5:20)) + │ │ │ ├── children: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (5:20)-(6:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── conditions: (2 items) + │ │ │ │ ├── @ ERBWhenNode (location: (6:2)-(6:23)) + │ │ │ │ │ ├── tag_opening: "<%" (location: (6:2)-(6:4)) + │ │ │ │ │ ├── content: " when :secondary " (location: (6:4)-(6:21)) + │ │ │ │ │ ├── tag_closing: "%>" (location: (6:21)-(6:23)) + │ │ │ │ │ └── statements: (3 items) + │ │ │ │ │ ├── @ HTMLTextNode (location: (6:23)-(7:4)) + │ │ │ │ │ │ └── content: "\n " + │ │ │ │ │ │ + │ │ │ │ │ ├── @ HTMLElementNode (location: (7:4)-(7:20)) + │ │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (7:4)-(7:7)) + │ │ │ │ │ │ │ ├── tag_opening: "<" (location: (7:4)-(7:5)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (7:5)-(7:6)) + │ │ │ │ │ │ │ ├── tag_closing: ">" (location: (7:6)-(7:7)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── tag_name: "p" (location: (7:5)-(7:6)) + │ │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ │ └── @ HTMLTextNode (location: (7:7)-(7:16)) + │ │ │ │ │ │ │ └── content: "Secondary" + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (7:16)-(7:20)) + │ │ │ │ │ │ │ ├── tag_opening: "" (location: (7:16)-(7:18)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (7:18)-(7:19)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── tag_closing: ">" (location: (7:19)-(7:20)) + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── is_void: false + │ │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ │ + │ │ │ │ │ └── @ HTMLTextNode (location: (7:20)-(8:2)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ │ + │ │ │ │ └── @ ERBWhenNode (location: (8:2)-(8:22)) + │ │ │ │ ├── tag_opening: "<%" (location: (8:2)-(8:4)) + │ │ │ │ ├── content: " when :tertiary " (location: (8:4)-(8:20)) + │ │ │ │ ├── tag_closing: "%>" (location: (8:20)-(8:22)) + │ │ │ │ └── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (8:22)-(9:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (9:4)-(9:19)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (9:4)-(9:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (9:4)-(9:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (9:6)-(9:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (9:7)-(9:15)) + │ │ │ │ │ │ └── content: "Tertiary" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (9:15)-(9:19)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (9:15)-(9:17)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:17)-(9:18)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (9:18)-(9:19)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (9:19)-(10:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ │ + │ │ │ ├── else_clause: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (10:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (10:2)-(10:4)) + │ │ │ ├── content: " end " (location: (10:4)-(10:9)) + │ │ │ └── tag_closing: "%>" (location: (10:9)-(10:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (10:11)-(11:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (11:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (11:0)-(11:2)) + │ ├── content: " end " (location: (11:2)-(11:7)) + │ └── tag_closing: "%>" (location: (11:7)-(11:9)) + │ + │ + └── @ HTMLTextNode (location: (11:9)-(12:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_when_test/test_0006_case_when_with_multiple_nested_control_structures_in_else_branch_0d1686b27fec04730415e5ebee1d78d1.txt b/test/snapshots/parser/case_when_test/test_0006_case_when_with_multiple_nested_control_structures_in_else_branch_0d1686b27fec04730415e5ebee1d78d1.txt new file mode 100644 index 000000000..64852dfb8 --- /dev/null +++ b/test/snapshots/parser/case_when_test/test_0006_case_when_with_multiple_nested_control_structures_in_else_branch_0d1686b27fec04730415e5ebee1d78d1.txt @@ -0,0 +1,173 @@ +--- +source: "Parser::CaseWhenTest#test_0006_case/when with multiple nested control structures in else branch" +input: |2- +<% case status %> +<% when :ok %> +OK
+<% else %> + <% if error? %> +Error
+ <% end %> + <% unless success? %> +Not successful
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(12:0)) +└── children: (2 items) + ├── @ ERBCaseNode (location: (1:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case status " (location: (1:2)-(1:15)) + │ ├── tag_closing: "%>" (location: (1:15)-(1:17)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:17)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBWhenNode (location: (2:0)-(2:14)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " when :ok " (location: (2:2)-(2:12)) + │ │ ├── tag_closing: "%>" (location: (2:12)-(2:14)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:14)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:11)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:7)) + │ │ │ │ └── content: "OK" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:7)-(3:11)) + │ │ │ │ ├── tag_opening: "" (location: (3:7)-(3:9)) + │ │ │ │ ├── tag_name: "p" (location: (3:9)-(3:10)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:10)-(3:11)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:11)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (5 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBIfNode (location: (5:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " if error? " (location: (5:4)-(5:15)) + │ │ │ ├── tag_closing: "%>" (location: (5:15)-(5:17)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (5:17)-(6:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (6:4)-(6:16)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (6:4)-(6:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (6:4)-(6:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (6:6)-(6:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (6:7)-(6:12)) + │ │ │ │ │ │ └── content: "Error" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (6:12)-(6:16)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (6:12)-(6:14)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:14)-(6:15)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (6:15)-(6:16)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (6:16)-(7:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── subsequent: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (7:2)-(7:11)) + │ │ │ ├── tag_opening: "<%" (location: (7:2)-(7:4)) + │ │ │ ├── content: " end " (location: (7:4)-(7:9)) + │ │ │ └── tag_closing: "%>" (location: (7:9)-(7:11)) + │ │ │ + │ │ │ + │ │ ├── @ HTMLTextNode (location: (7:11)-(8:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBUnlessNode (location: (8:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (8:2)-(8:4)) + │ │ │ ├── content: " unless success? " (location: (8:4)-(8:21)) + │ │ │ ├── tag_closing: "%>" (location: (8:21)-(8:23)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (8:23)-(9:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (9:4)-(9:25)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (9:4)-(9:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (9:4)-(9:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (9:6)-(9:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (9:5)-(9:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (9:7)-(9:21)) + │ │ │ │ │ │ └── content: "Not successful" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (9:21)-(9:25)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (9:21)-(9:23)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (9:23)-(9:24)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (9:24)-(9:25)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (9:25)-(10:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── else_clause: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (10:2)-(10:11)) + │ │ │ ├── tag_opening: "<%" (location: (10:2)-(10:4)) + │ │ │ ├── content: " end " (location: (10:4)-(10:9)) + │ │ │ └── tag_closing: "%>" (location: (10:9)-(10:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (10:11)-(11:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (11:0)-(11:9)) + │ ├── tag_opening: "<%" (location: (11:0)-(11:2)) + │ ├── content: " end " (location: (11:2)-(11:7)) + │ └── tag_closing: "%>" (location: (11:7)-(11:9)) + │ + │ + └── @ HTMLTextNode (location: (11:9)-(12:0)) + └── content: "\n" \ No newline at end of file diff --git a/test/snapshots/parser/case_when_test/test_0007_case_when_with_begin_rescue_inside_else_branch_fde835439a16c76c30c27db0d1ef4f8a.txt b/test/snapshots/parser/case_when_test/test_0007_case_when_with_begin_rescue_inside_else_branch_fde835439a16c76c30c27db0d1ef4f8a.txt new file mode 100644 index 000000000..df5622c4a --- /dev/null +++ b/test/snapshots/parser/case_when_test/test_0007_case_when_with_begin_rescue_inside_else_branch_fde835439a16c76c30c27db0d1ef4f8a.txt @@ -0,0 +1,165 @@ +--- +source: "Parser::CaseWhenTest#test_0007_case/when with begin/rescue inside else branch" +input: |2- +<% case result %> +<% when :success %> +Success
+<% else %> + <% begin %> +Attempting fallback
+ <% rescue %> +Fallback failed
+ <% end %> +<% end %> +--- +@ DocumentNode (location: (1:0)-(11:0)) +└── children: (2 items) + ├── @ ERBCaseNode (location: (1:0)-(10:9)) + │ ├── tag_opening: "<%" (location: (1:0)-(1:2)) + │ ├── content: " case result " (location: (1:2)-(1:15)) + │ ├── tag_closing: "%>" (location: (1:15)-(1:17)) + │ ├── children: (1 item) + │ │ └── @ HTMLTextNode (location: (1:17)-(2:0)) + │ │ └── content: "\n" + │ │ + │ ├── conditions: (1 item) + │ │ └── @ ERBWhenNode (location: (2:0)-(2:19)) + │ │ ├── tag_opening: "<%" (location: (2:0)-(2:2)) + │ │ ├── content: " when :success " (location: (2:2)-(2:17)) + │ │ ├── tag_closing: "%>" (location: (2:17)-(2:19)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (2:19)-(3:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ HTMLElementNode (location: (3:2)-(3:16)) + │ │ │ ├── open_tag: + │ │ │ │ └── @ HTMLOpenTagNode (location: (3:2)-(3:5)) + │ │ │ │ ├── tag_opening: "<" (location: (3:2)-(3:3)) + │ │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ │ ├── tag_closing: ">" (location: (3:4)-(3:5)) + │ │ │ │ ├── children: [] + │ │ │ │ └── is_void: false + │ │ │ │ + │ │ │ ├── tag_name: "p" (location: (3:3)-(3:4)) + │ │ │ ├── body: (1 item) + │ │ │ │ └── @ HTMLTextNode (location: (3:5)-(3:12)) + │ │ │ │ └── content: "Success" + │ │ │ │ + │ │ │ ├── close_tag: + │ │ │ │ └── @ HTMLCloseTagNode (location: (3:12)-(3:16)) + │ │ │ │ ├── tag_opening: "" (location: (3:12)-(3:14)) + │ │ │ │ ├── tag_name: "p" (location: (3:14)-(3:15)) + │ │ │ │ ├── children: [] + │ │ │ │ └── tag_closing: ">" (location: (3:15)-(3:16)) + │ │ │ │ + │ │ │ ├── is_void: false + │ │ │ └── source: "HTML" + │ │ │ + │ │ └── @ HTMLTextNode (location: (3:16)-(4:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ ├── else_clause: + │ │ └── @ ERBElseNode (location: (4:0)-(4:10)) + │ │ ├── tag_opening: "<%" (location: (4:0)-(4:2)) + │ │ ├── content: " else " (location: (4:2)-(4:8)) + │ │ ├── tag_closing: "%>" (location: (4:8)-(4:10)) + │ │ └── statements: (3 items) + │ │ ├── @ HTMLTextNode (location: (4:10)-(5:2)) + │ │ │ └── content: "\n " + │ │ │ + │ │ ├── @ ERBBeginNode (location: (5:2)-(9:11)) + │ │ │ ├── tag_opening: "<%" (location: (5:2)-(5:4)) + │ │ │ ├── content: " begin " (location: (5:4)-(5:11)) + │ │ │ ├── tag_closing: "%>" (location: (5:11)-(5:13)) + │ │ │ ├── statements: (3 items) + │ │ │ │ ├── @ HTMLTextNode (location: (5:13)-(6:4)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ ├── @ HTMLElementNode (location: (6:4)-(6:30)) + │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (6:4)-(6:7)) + │ │ │ │ │ │ ├── tag_opening: "<" (location: (6:4)-(6:5)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ │ ├── tag_closing: ">" (location: (6:6)-(6:7)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ + │ │ │ │ │ ├── tag_name: "p" (location: (6:5)-(6:6)) + │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ └── @ HTMLTextNode (location: (6:7)-(6:26)) + │ │ │ │ │ │ └── content: "Attempting fallback" + │ │ │ │ │ │ + │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (6:26)-(6:30)) + │ │ │ │ │ │ ├── tag_opening: "" (location: (6:26)-(6:28)) + │ │ │ │ │ │ ├── tag_name: "p" (location: (6:28)-(6:29)) + │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ └── tag_closing: ">" (location: (6:29)-(6:30)) + │ │ │ │ │ │ + │ │ │ │ │ ├── is_void: false + │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ + │ │ │ │ └── @ HTMLTextNode (location: (6:30)-(7:2)) + │ │ │ │ └── content: "\n " + │ │ │ │ + │ │ │ ├── rescue_clause: + │ │ │ │ └── @ ERBRescueNode (location: (7:2)-(9:2)) + │ │ │ │ ├── tag_opening: "<%" (location: (7:2)-(7:4)) + │ │ │ │ ├── content: " rescue " (location: (7:4)-(7:12)) + │ │ │ │ ├── tag_closing: "%>" (location: (7:12)-(7:14)) + │ │ │ │ ├── statements: (3 items) + │ │ │ │ │ ├── @ HTMLTextNode (location: (7:14)-(8:4)) + │ │ │ │ │ │ └── content: "\n " + │ │ │ │ │ │ + │ │ │ │ │ ├── @ HTMLElementNode (location: (8:4)-(8:26)) + │ │ │ │ │ │ ├── open_tag: + │ │ │ │ │ │ │ └── @ HTMLOpenTagNode (location: (8:4)-(8:7)) + │ │ │ │ │ │ │ ├── tag_opening: "<" (location: (8:4)-(8:5)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (8:5)-(8:6)) + │ │ │ │ │ │ │ ├── tag_closing: ">" (location: (8:6)-(8:7)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── is_void: false + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── tag_name: "p" (location: (8:5)-(8:6)) + │ │ │ │ │ │ ├── body: (1 item) + │ │ │ │ │ │ │ └── @ HTMLTextNode (location: (8:7)-(8:22)) + │ │ │ │ │ │ │ └── content: "Fallback failed" + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── close_tag: + │ │ │ │ │ │ │ └── @ HTMLCloseTagNode (location: (8:22)-(8:26)) + │ │ │ │ │ │ │ ├── tag_opening: "" (location: (8:22)-(8:24)) + │ │ │ │ │ │ │ ├── tag_name: "p" (location: (8:24)-(8:25)) + │ │ │ │ │ │ │ ├── children: [] + │ │ │ │ │ │ │ └── tag_closing: ">" (location: (8:25)-(8:26)) + │ │ │ │ │ │ │ + │ │ │ │ │ │ ├── is_void: false + │ │ │ │ │ │ └── source: "HTML" + │ │ │ │ │ │ + │ │ │ │ │ └── @ HTMLTextNode (location: (8:26)-(9:2)) + │ │ │ │ │ └── content: "\n " + │ │ │ │ │ + │ │ │ │ └── subsequent: ∅ + │ │ │ │ + │ │ │ ├── else_clause: ∅ + │ │ │ ├── ensure_clause: ∅ + │ │ │ └── end_node: + │ │ │ └── @ ERBEndNode (location: (9:2)-(9:11)) + │ │ │ ├── tag_opening: "<%" (location: (9:2)-(9:4)) + │ │ │ ├── content: " end " (location: (9:4)-(9:9)) + │ │ │ └── tag_closing: "%>" (location: (9:9)-(9:11)) + │ │ │ + │ │ │ + │ │ └── @ HTMLTextNode (location: (9:11)-(10:0)) + │ │ └── content: "\n" + │ │ + │ │ + │ └── end_node: + │ └── @ ERBEndNode (location: (10:0)-(10:9)) + │ ├── tag_opening: "<%" (location: (10:0)-(10:2)) + │ ├── content: " end " (location: (10:2)-(10:7)) + │ └── tag_closing: "%>" (location: (10:7)-(10:9)) + │ + │ + └── @ HTMLTextNode (location: (10:9)-(11:0)) + └── content: "\n" \ No newline at end of file