From f454808b1160fca0582acba7d6436e0dffaf9e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Azevedo?= Date: Tue, 27 Feb 2024 12:58:16 +0000 Subject: [PATCH] Unparsing: add CaseStmt config --- extensions/default_unparsing_config.json | 150 +++++ .../doc-baseline.json | 620 +++++++++++++++++ .../long_alternative_choices/input.ada | 7 + .../long_alternative_choices/test.out | 13 + .../long_alternative_choices/test.yaml | 4 + .../long_alternative_stmt/doc-baseline.json | 633 ++++++++++++++++++ .../case_stmt/long_alternative_stmt/input.ada | 6 + .../case_stmt/long_alternative_stmt/test.out | 10 + .../case_stmt/long_alternative_stmt/test.yaml | 5 + .../case_stmt/long_expr/doc-baseline.json | 563 ++++++++++++++++ .../unparsing/case_stmt/long_expr/input.ada | 1 + .../unparsing/case_stmt/long_expr/test.out | 8 + .../unparsing/case_stmt/long_expr/test.yaml | 5 + .../case_stmt/short/doc-baseline.json | 563 ++++++++++++++++ .../tests/unparsing/case_stmt/short/input.ada | 1 + .../tests/unparsing/case_stmt/short/test.out | 7 + .../tests/unparsing/case_stmt/short/test.yaml | 5 + .../short_with_pragma/doc-baseline.json | 616 +++++++++++++++++ .../case_stmt/short_with_pragma/input.ada | 1 + .../case_stmt/short_with_pragma/test.out | 10 + .../case_stmt/short_with_pragma/test.yaml | 5 + 21 files changed, 3233 insertions(+) create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_choices/doc-baseline.json create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_choices/input.ada create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.out create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.yaml create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_stmt/doc-baseline.json create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_stmt/input.ada create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.out create mode 100644 testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.yaml create mode 100644 testsuite/tests/unparsing/case_stmt/long_expr/doc-baseline.json create mode 100644 testsuite/tests/unparsing/case_stmt/long_expr/input.ada create mode 100644 testsuite/tests/unparsing/case_stmt/long_expr/test.out create mode 100644 testsuite/tests/unparsing/case_stmt/long_expr/test.yaml create mode 100644 testsuite/tests/unparsing/case_stmt/short/doc-baseline.json create mode 100644 testsuite/tests/unparsing/case_stmt/short/input.ada create mode 100644 testsuite/tests/unparsing/case_stmt/short/test.out create mode 100644 testsuite/tests/unparsing/case_stmt/short/test.yaml create mode 100644 testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json create mode 100644 testsuite/tests/unparsing/case_stmt/short_with_pragma/input.ada create mode 100644 testsuite/tests/unparsing/case_stmt/short_with_pragma/test.out create mode 100644 testsuite/tests/unparsing/case_stmt/short_with_pragma/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index bf454ba9d..388dab066 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -6,6 +6,13 @@ "line" ] }, + "AlternativesList": { + "sep": [ + "line", + "recurse", + "whitespace" + ] + }, "ArrayTypeDef": { "node": { "kind": "group", @@ -194,6 +201,137 @@ ] } }, + "CaseStmt": { + "node": { + "kind": "group", + "document": [ + { + "kind": "group", + "document": [ + [ + { + "kind": "text", + "text": "case" + }, + "whitespace", + { + "kind": "align", + "width": 2, + "contents": { + "kind": "recurse_field", + "field": "f_expr" + } + } + ], + "line", + { + "kind": "text", + "text": "is" + } + ] + }, + { + "kind": "indent", + "contents": [ + "hardlineWithoutBreakParent", + { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_pragmas" + } + }, + { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_alternatives" + } + } + ] + }, + "hardline", + { + "kind": "text", + "text": "end" + }, + "whitespace", + { + "kind": "text", + "text": "case" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_pragmas": { + "kind": "ifEmpty", + "then": "recurse", + "else": [ + "recurse", + "hardlineWithoutBreakParent", + "hardlineWithoutBreakParent" + ] + } + } + }, + "CaseStmtAlternative": { + "node": { + "kind": "group", + "document": [ + { + "kind": "group", + "document": [ + { + "kind": "indent", + "contents": [ + { + "kind": "text", + "text": "when" + }, + "whitespace", + { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_choices" + } + } + ] + }, + "line", + { + "kind": "text", + "text": "=>" + } + ] + }, + { + "kind": "indent", + "contents": [ + "line", + { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_stmts" + } + } + ] + } + ] + } + }, + "CaseStmtAlternativeList": { + "sep": [ + "recurse", + "hardlineWithoutBreakParent", + "hardlineWithoutBreakParent" + ] + }, "ComponentDef": { "node": { "kind": "align", @@ -1178,6 +1316,12 @@ } } }, + "PragmaNodeList": { + "sep": [ + "recurse", + "hardline" + ] + }, "RangeSpec": { "node": { "kind": "align", @@ -1240,6 +1384,12 @@ "field": "f_range" } }, + "StmtList": { + "sep": [ + "recurse", + "hardline" + ] + }, "SubpBody": { "node": { "kind": "group", diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_choices/doc-baseline.json b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/doc-baseline.json new file mode 100644 index 000000000..e0df58cca --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/doc-baseline.json @@ -0,0 +1,620 @@ +{ + "id": 82, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 81, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "case " + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 1, + "kind": "text", + "text": "Foo" + } + } + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 4, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 76, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 75, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "list", + "list": [ + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 74, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 73, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 30, + "kind": "list", + "list": [ + { + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 19, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "text", + "text": "when " + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 16, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "text", + "text": "Barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "text", + "text": "| Quxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 15, + "kind": "text", + "text": "| Corge" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 21, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 29, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 28, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 27, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 26, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 33, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 53, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 52, + "kind": "list", + "list": [ + { + "id": 45, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 44, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 40, + "kind": "list", + "list": [ + { + "id": 34, + "kind": "text", + "text": "when " + }, + { + "id": 39, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 38, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "text", + "text": "Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 37, + "kind": "text", + "text": "| Qux" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 43, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 51, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 50, + "kind": "list", + "list": [ + { + "id": 46, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 49, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 48, + "kind": "list", + "list": [ + { + "id": 47, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 54, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 55, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 72, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 71, + "kind": "list", + "list": [ + { + "id": 64, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 60, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 59, + "kind": "list", + "list": [ + { + "id": 56, + "kind": "text", + "text": "when " + }, + { + "id": 58, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 57, + "kind": "text", + "text": "others" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 61, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 62, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 70, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 69, + "kind": "list", + "list": [ + { + "id": 65, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 68, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 67, + "kind": "list", + "list": [ + { + "id": 66, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 79, + "kind": "list", + "list": [ + { + "id": 77, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 78, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 80, + "kind": "text", + "text": "end case;" + } + ] + }, + "break": true, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_choices/input.ada b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/input.ada new file mode 100644 index 000000000..5e4a0d47a --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/input.ada @@ -0,0 +1,7 @@ +case Foo is + when Barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr | Quxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | Corge => null; + + when Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz | Qux => null; + + when others => null; +end case; diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.out b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.out new file mode 100644 index 000000000..aac81cb29 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.out @@ -0,0 +1,13 @@ +case Foo is + when Barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr + | Quxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + | Corge + => + null; + + when Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz | Qux + => + null; + + when others => null; +end case; diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.yaml b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.yaml new file mode 100644 index 000000000..0adb80e17 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_choices/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: case_stmt +description: | + Test that long alternatives are all separated by a line break and indented. diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/doc-baseline.json b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/doc-baseline.json new file mode 100644 index 000000000..ce9d60594 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/doc-baseline.json @@ -0,0 +1,633 @@ +{ + "id": 83, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 82, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "case " + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 1, + "kind": "text", + "text": "Foo" + } + } + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 4, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 77, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 76, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "list", + "list": [ + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 75, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 74, + "kind": "list", + "list": [ + { + "id": 34, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "text", + "text": "when " + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "text", + "text": "Bar" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 16, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 19, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "text", + "text": "Qux;" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 25, + "kind": "list", + "list": [ + { + "id": 23, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 26, + "kind": "text", + "text": "Qux;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": true, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": true, + "expandedStates": null + } + }, + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 54, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 53, + "kind": "list", + "list": [ + { + "id": 45, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 44, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 40, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "text", + "text": "when " + }, + { + "id": 39, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 38, + "kind": "text", + "text": "Baz" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 43, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 52, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 51, + "kind": "list", + "list": [ + { + "id": 46, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 50, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 49, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 48, + "kind": "list", + "list": [ + { + "id": 47, + "kind": "text", + "text": "Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux;" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 55, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 56, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 73, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 72, + "kind": "list", + "list": [ + { + "id": 65, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 64, + "kind": "list", + "list": [ + { + "id": 61, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 60, + "kind": "list", + "list": [ + { + "id": 57, + "kind": "text", + "text": "when " + }, + { + "id": 59, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 58, + "kind": "text", + "text": "others" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 63, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 71, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 70, + "kind": "list", + "list": [ + { + "id": 66, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 69, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 67, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": true, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 80, + "kind": "list", + "list": [ + { + "id": 78, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 79, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 81, + "kind": "text", + "text": "end case;" + } + ] + }, + "break": true, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/input.ada b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/input.ada new file mode 100644 index 000000000..a325f90f0 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/input.ada @@ -0,0 +1,6 @@ +case Foo is + when Bar => Qux; Qux; + when Baz => Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux; + when others => null; +end case; + diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.out b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.out new file mode 100644 index 000000000..013e0d199 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.out @@ -0,0 +1,10 @@ +case Foo is + when Bar => + Qux; + Qux; + + when Baz => + Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux; + + when others => null; +end case; diff --git a/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.yaml b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.yaml new file mode 100644 index 000000000..0894290a6 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_alternative_stmt/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: case_stmt +description: | + Test that a single long statement is in its own line and that multiple + statements are split in their own lines. diff --git a/testsuite/tests/unparsing/case_stmt/long_expr/doc-baseline.json b/testsuite/tests/unparsing/case_stmt/long_expr/doc-baseline.json new file mode 100644 index 000000000..09aa6e608 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_expr/doc-baseline.json @@ -0,0 +1,563 @@ +{ + "id": 74, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 73, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "case " + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 1, + "kind": "text", + "text": "Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + } + } + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 4, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 68, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 67, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "list", + "list": [ + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 65, + "kind": "list", + "list": [ + { + "id": 26, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 25, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "text", + "text": "when " + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "text", + "text": "Bar" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 16, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 19, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 27, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 45, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 44, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 36, + "kind": "list", + "list": [ + { + "id": 33, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 32, + "kind": "list", + "list": [ + { + "id": 29, + "kind": "text", + "text": "when " + }, + { + "id": 31, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 30, + "kind": "text", + "text": "Baz" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 34, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 35, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 43, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 42, + "kind": "list", + "list": [ + { + "id": 38, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 41, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 40, + "kind": "list", + "list": [ + { + "id": 39, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 46, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 47, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 64, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 56, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 55, + "kind": "list", + "list": [ + { + "id": 52, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 51, + "kind": "list", + "list": [ + { + "id": 48, + "kind": "text", + "text": "when " + }, + { + "id": 50, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 49, + "kind": "text", + "text": "others" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 53, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 54, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 61, + "kind": "list", + "list": [ + { + "id": 57, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 59, + "kind": "list", + "list": [ + { + "id": 58, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 71, + "kind": "list", + "list": [ + { + "id": 69, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 70, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 72, + "kind": "text", + "text": "end case;" + } + ] + }, + "break": true, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/case_stmt/long_expr/input.ada b/testsuite/tests/unparsing/case_stmt/long_expr/input.ada new file mode 100644 index 000000000..960489cc6 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_expr/input.ada @@ -0,0 +1 @@ +case Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo is when Bar => null; when Baz => null; when others => null; end case; diff --git a/testsuite/tests/unparsing/case_stmt/long_expr/test.out b/testsuite/tests/unparsing/case_stmt/long_expr/test.out new file mode 100644 index 000000000..e8a0d5a96 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_expr/test.out @@ -0,0 +1,8 @@ +case Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo +is + when Bar => null; + + when Baz => null; + + when others => null; +end case; diff --git a/testsuite/tests/unparsing/case_stmt/long_expr/test.yaml b/testsuite/tests/unparsing/case_stmt/long_expr/test.yaml new file mode 100644 index 000000000..04fb19b4a --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/long_expr/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: case_stmt +description: | + Test that when `f_expr` is long, a line break is added before the `is` + keyword. diff --git a/testsuite/tests/unparsing/case_stmt/short/doc-baseline.json b/testsuite/tests/unparsing/case_stmt/short/doc-baseline.json new file mode 100644 index 000000000..da655ec86 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short/doc-baseline.json @@ -0,0 +1,563 @@ +{ + "id": 74, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 73, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "case " + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 1, + "kind": "text", + "text": "Foo" + } + } + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 4, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 68, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 67, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "list", + "list": [ + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 65, + "kind": "list", + "list": [ + { + "id": 26, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 25, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "text", + "text": "when " + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "text", + "text": "Bar" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 16, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 19, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 27, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 45, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 44, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 36, + "kind": "list", + "list": [ + { + "id": 33, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 32, + "kind": "list", + "list": [ + { + "id": 29, + "kind": "text", + "text": "when " + }, + { + "id": 31, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 30, + "kind": "text", + "text": "Baz" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 34, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 35, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 43, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 42, + "kind": "list", + "list": [ + { + "id": 38, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 41, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 40, + "kind": "list", + "list": [ + { + "id": 39, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 46, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 47, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 64, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 56, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 55, + "kind": "list", + "list": [ + { + "id": 52, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 51, + "kind": "list", + "list": [ + { + "id": 48, + "kind": "text", + "text": "when " + }, + { + "id": 50, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 49, + "kind": "text", + "text": "others" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 53, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 54, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 61, + "kind": "list", + "list": [ + { + "id": 57, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 59, + "kind": "list", + "list": [ + { + "id": 58, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 71, + "kind": "list", + "list": [ + { + "id": 69, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 70, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 72, + "kind": "text", + "text": "end case;" + } + ] + }, + "break": true, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/case_stmt/short/input.ada b/testsuite/tests/unparsing/case_stmt/short/input.ada new file mode 100644 index 000000000..ac0d72a32 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short/input.ada @@ -0,0 +1 @@ +case Foo is when Bar => null; when Baz => null; when others => null; end case; diff --git a/testsuite/tests/unparsing/case_stmt/short/test.out b/testsuite/tests/unparsing/case_stmt/short/test.out new file mode 100644 index 000000000..936d96878 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short/test.out @@ -0,0 +1,7 @@ +case Foo is + when Bar => null; + + when Baz => null; + + when others => null; +end case; diff --git a/testsuite/tests/unparsing/case_stmt/short/test.yaml b/testsuite/tests/unparsing/case_stmt/short/test.yaml new file mode 100644 index 000000000..a8c3cb1bf --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: case_stmt +description: | + Base test for `CaseStmt`. Test that there's a literal line between the + alternatives. diff --git a/testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json b/testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json new file mode 100644 index 000000000..44763bc60 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json @@ -0,0 +1,616 @@ +{ + "id": 81, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 80, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "case " + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 1, + "kind": "text", + "text": "Foo" + } + } + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 4, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 75, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 74, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "text", + "text": "pragma Foo_Bar;" + }, + { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 12, + "kind": "text", + "text": "pragma Bar_Foo;" + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + } + ] + }, + "break": true, + "expandedStates": null + } + }, + { + "id": 73, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 72, + "kind": "list", + "list": [ + { + "id": 33, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 32, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 21, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": "when " + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "text", + "text": "Bar" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 23, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 31, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 30, + "kind": "list", + "list": [ + { + "id": 26, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 29, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 28, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 34, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 52, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 51, + "kind": "list", + "list": [ + { + "id": 44, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 43, + "kind": "list", + "list": [ + { + "id": 40, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 39, + "kind": "list", + "list": [ + { + "id": 36, + "kind": "text", + "text": "when " + }, + { + "id": 38, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 37, + "kind": "text", + "text": "Baz" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 41, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 42, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 50, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 49, + "kind": "list", + "list": [ + { + "id": 45, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 48, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 47, + "kind": "list", + "list": [ + { + "id": 46, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 53, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 54, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 71, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 70, + "kind": "list", + "list": [ + { + "id": 63, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 62, + "kind": "list", + "list": [ + { + "id": 59, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 58, + "kind": "list", + "list": [ + { + "id": 55, + "kind": "text", + "text": "when " + }, + { + "id": 57, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 56, + "kind": "text", + "text": "others" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 61, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 69, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 64, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 67, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 66, + "kind": "list", + "list": [ + { + "id": 65, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 78, + "kind": "list", + "list": [ + { + "id": 76, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 77, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 79, + "kind": "text", + "text": "end case;" + } + ] + }, + "break": true, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/case_stmt/short_with_pragma/input.ada b/testsuite/tests/unparsing/case_stmt/short_with_pragma/input.ada new file mode 100644 index 000000000..86ecfbdac --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short_with_pragma/input.ada @@ -0,0 +1 @@ +case Foo is pragma Foo_Bar; pragma Bar_Foo; when Bar => null; when Baz => null; when others => null; end case; diff --git a/testsuite/tests/unparsing/case_stmt/short_with_pragma/test.out b/testsuite/tests/unparsing/case_stmt/short_with_pragma/test.out new file mode 100644 index 000000000..7c09843b6 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short_with_pragma/test.out @@ -0,0 +1,10 @@ +case Foo is + pragma Foo_Bar; + pragma Bar_Foo; + + when Bar => null; + + when Baz => null; + + when others => null; +end case; diff --git a/testsuite/tests/unparsing/case_stmt/short_with_pragma/test.yaml b/testsuite/tests/unparsing/case_stmt/short_with_pragma/test.yaml new file mode 100644 index 000000000..742c24f41 --- /dev/null +++ b/testsuite/tests/unparsing/case_stmt/short_with_pragma/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: case_stmt +description: | + Test that each pragma is in it's own line and that there's a `literalline` + between the pragma list and the case alternatives list.