From e15755dac9d5adad2a4998d665b282004dcc54d2 Mon Sep 17 00:00:00 2001 From: Joao Azevedo Date: Wed, 27 Mar 2024 14:26:11 +0000 Subject: [PATCH] Unparsing: add configurations for BracketAggregate, BracketDeltaAggregate and DeltaAggregate --- extensions/default_unparsing_config.json | 164 +++++++++- .../long_complete/doc-baseline.json | 279 ++++++++++++++++++ .../bracket_aggregate/long_complete/input.ada | 1 + .../bracket_aggregate/long_complete/test.out | 4 + .../bracket_aggregate/long_complete/test.yaml | 5 + .../long_no_ancestor_expr/doc-baseline.json | 247 ++++++++++++++++ .../long_no_ancestor_expr/input.ada | 1 + .../long_no_ancestor_expr/test.out | 2 + .../long_no_ancestor_expr/test.yaml | 4 + .../doc-baseline.json | 183 ++++++++++++ .../long_no_assoc_no_ancestor_expr/input.ada | 2 + .../long_no_assoc_no_ancestor_expr/test.out | 3 + .../long_no_assoc_no_ancestor_expr/test.yaml | 4 + .../doc-baseline.json | 183 ++++++++++++ .../short_no_assoc_no_ancestor_expr/input.ada | 1 + .../short_no_assoc_no_ancestor_expr/test.out | 1 + .../short_no_assoc_no_ancestor_expr/test.yaml | 4 + .../long/doc-baseline.json | 273 +++++++++++++++++ .../bracket_delta_aggregate/long/input.ada | 2 + .../bracket_delta_aggregate/long/test.out | 4 + .../bracket_delta_aggregate/long/test.yaml | 5 + .../short/doc-baseline.json | 195 ++++++++++++ .../bracket_delta_aggregate/short/input.ada | 1 + .../bracket_delta_aggregate/short/test.out | 1 + .../bracket_delta_aggregate/short/test.yaml | 4 + .../delta_aggregate/long/doc-baseline.json | 193 ++++++++++++ .../unparsing/delta_aggregate/long/input.ada | 2 + .../unparsing/delta_aggregate/long/test.out | 4 + .../unparsing/delta_aggregate/long/test.yaml | 10 + .../delta_aggregate/short/doc-baseline.json | 115 ++++++++ .../unparsing/delta_aggregate/short/input.ada | 1 + .../unparsing/delta_aggregate/short/test.out | 1 + .../unparsing/delta_aggregate/short/test.yaml | 5 + 33 files changed, 1893 insertions(+), 11 deletions(-) create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_complete/doc-baseline.json create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_complete/input.ada create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_complete/test.out create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_complete/test.yaml create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/doc-baseline.json create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/input.ada create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.out create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.yaml create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/doc-baseline.json create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/input.ada create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.out create mode 100644 testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.yaml create mode 100644 testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/doc-baseline.json create mode 100644 testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/input.ada create mode 100644 testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.out create mode 100644 testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.yaml create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/long/doc-baseline.json create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/long/input.ada create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/long/test.out create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/long/test.yaml create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/short/doc-baseline.json create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/short/input.ada create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/short/test.out create mode 100644 testsuite/tests/unparsing/bracket_delta_aggregate/short/test.yaml create mode 100644 testsuite/tests/unparsing/delta_aggregate/long/doc-baseline.json create mode 100644 testsuite/tests/unparsing/delta_aggregate/long/input.ada create mode 100644 testsuite/tests/unparsing/delta_aggregate/long/test.out create mode 100644 testsuite/tests/unparsing/delta_aggregate/long/test.yaml create mode 100644 testsuite/tests/unparsing/delta_aggregate/short/doc-baseline.json create mode 100644 testsuite/tests/unparsing/delta_aggregate/short/input.ada create mode 100644 testsuite/tests/unparsing/delta_aggregate/short/test.out create mode 100644 testsuite/tests/unparsing/delta_aggregate/short/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index b1a5cf3de..92c68b12b 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -225,6 +225,101 @@ ] } }, + "BracketAggregate": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "[" + }, + { + "kind": "align", + "width": 1, + "contents": [ + { + "kind": "recurse_field", + "field": "f_ancestor_expr" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_assocs" + } + } + ] + }, + { + "kind": "text", + "text": "]" + } + ] + }, + "fields": { + "f_ancestor_expr": { + "kind": "align", + "width": 2, + "contents": [ + "recurse", + { + "kind": "text", + "text": "with" + }, + "line" + ] + } + } + }, + "BracketDeltaAggregate": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "[" + }, + { + "kind": "align", + "width": 1, + "contents": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_ancestor_expr" + }, + "whitespace", + { + "kind": "text", + "text": "with" + }, + "whitespace", + { + "kind": "text", + "text": "delta" + }, + { + "kind": "align", + "width": 2, + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_assocs" + } + ] + } + ] + } + }, + { + "kind": "text", + "text": "]" + } + ] + } + }, "CallExpr": { "node": { "kind": "innerRoot", @@ -879,6 +974,53 @@ "line" ] }, + "DeltaAggregate": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "(" + }, + { + "kind": "align", + "width": 1, + "contents": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_ancestor_expr" + }, + "whitespace", + { + "kind": "text", + "text": "with" + }, + "whitespace", + { + "kind": "text", + "text": "delta" + }, + { + "kind": "align", + "width": 2, + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_assocs" + } + ] + } + ] + } + }, + { + "kind": "text", + "text": ")" + } + ] + }, "DerivedTypeDef": { "node": { "kind": "group", @@ -1068,7 +1210,7 @@ "kind": "text", "text": "entry" }, - "whitespace", + "whitespace", { "kind": "recurse_field", "field": "f_entry_name" @@ -1089,7 +1231,7 @@ { "kind": "text", "text": "when" - }, + }, { "kind": "recurse_field", "field": "f_barrier" @@ -3177,8 +3319,8 @@ { "kind": "recurse_field", "field": "f_public_part" - } - ] + } + ] }, "hardline", { @@ -3188,7 +3330,7 @@ { "kind": "text", "text": "end" - }, + }, "whitespace", { "kind": "recurse_field", @@ -3238,13 +3380,13 @@ "kind": "recurse_field", "field": "f_aspects" }, - "line", + "line", { "kind": "text", "text": "is" } ] - }, + }, { "kind": "group", "document": [ @@ -3422,13 +3564,13 @@ "kind": "recurse_field", "field": "f_aspects" }, - "line", + "line", { "kind": "text", "text": "is" } ] - }, + }, { "kind": "group", "document": [ @@ -3458,7 +3600,7 @@ ] } } - }, + }, "StmtList": { "sep": [ "recurse", @@ -3616,7 +3758,7 @@ "kind": "ifEmpty", "then": "recurse", "else": [ - "line", + "line", "recurse" ] } diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_complete/doc-baseline.json b/testsuite/tests/unparsing/bracket_aggregate/long_complete/doc-baseline.json new file mode 100644 index 000000000..203eff32c --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_complete/doc-baseline.json @@ -0,0 +1,279 @@ +{ + "id": 35, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 34, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 31, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 30, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "[" + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "Baaaar with" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 25, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "text", + "text": "Qux =>" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 11, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 15, + "kind": "text", + "text": "," + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": "Baaaz =>" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 21, + "kind": "text", + "text": "Bazzzzzzzz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 29, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 32, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_complete/input.ada b/testsuite/tests/unparsing/bracket_aggregate/long_complete/input.ada new file mode 100644 index 000000000..af6b3a54f --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_complete/input.ada @@ -0,0 +1 @@ +Foo := [Baaaar with Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, Baaaz => Bazzzzzzzz]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_complete/test.out b/testsuite/tests/unparsing/bracket_aggregate/long_complete/test.out new file mode 100644 index 000000000..b429cbdfd --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_complete/test.out @@ -0,0 +1,4 @@ +Foo := + [Baaaar with + Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Baaaz => Bazzzzzzzz]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_complete/test.yaml b/testsuite/tests/unparsing/bracket_aggregate/long_complete/test.yaml new file mode 100644 index 000000000..7c8e729a1 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_complete/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: stmt +description: | + Test the line break after the `with` keyword and the continuation line + indentation of `f_assocs`. diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/doc-baseline.json b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/doc-baseline.json new file mode 100644 index 000000000..fc8dd2ab3 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/doc-baseline.json @@ -0,0 +1,247 @@ +{ + "id": 31, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "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": 2, + "kind": "text", + "text": "[" + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "Baz =>" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 7, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 11, + "kind": "text", + "text": "," + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "text", + "text": "Quuuuuux =>" + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 17, + "kind": "text", + "text": "Quuuuuuuuuuuuuuuuuuuuuuuuuux" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 25, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 28, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/input.ada b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/input.ada new file mode 100644 index 000000000..53f23422a --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/input.ada @@ -0,0 +1 @@ +Foo := [Baz => Baaaaaaaaaaaaaaaaaaaz, Quuuuuux => Quuuuuuuuuuuuuuuuuuuuuuuuuux]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.out b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.out new file mode 100644 index 000000000..7b742a713 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.out @@ -0,0 +1,2 @@ +Foo := + [Baz => Baaaaaaaaaaaaaaaaaaaz, Quuuuuux => Quuuuuuuuuuuuuuuuuuuuuuuuuux]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.yaml b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.yaml new file mode 100644 index 000000000..8769a4d7b --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_ancestor_expr/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added to the `BracketAggregate` node. diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/doc-baseline.json b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/doc-baseline.json new file mode 100644 index 000000000..cd93b33e5 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/doc-baseline.json @@ -0,0 +1,183 @@ +{ + "id": 23, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "[" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 3, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 7, + "kind": "text", + "text": "," + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "Baz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 17, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 20, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/input.ada b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/input.ada new file mode 100644 index 000000000..b9cd50ccc --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/input.ada @@ -0,0 +1,2 @@ +Foo := + [Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, Baz]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.out b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.out new file mode 100644 index 000000000..5e8e94a79 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.out @@ -0,0 +1,3 @@ +Foo := + [Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, + Baz]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.yaml b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.yaml new file mode 100644 index 000000000..aa842ddd3 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/long_no_assoc_no_ancestor_expr/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test the line breaks between nodes of `f_assocs` and their indentation. diff --git a/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/doc-baseline.json b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/doc-baseline.json new file mode 100644 index 000000000..5e955e812 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/doc-baseline.json @@ -0,0 +1,183 @@ +{ + "id": 23, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "[" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 3, + "kind": "text", + "text": "Bar" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 7, + "kind": "text", + "text": "," + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "Baz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 17, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 20, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/input.ada b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/input.ada new file mode 100644 index 000000000..76ac2e2fa --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/input.ada @@ -0,0 +1 @@ +Foo:=[Bar, Baz]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.out b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.out new file mode 100644 index 000000000..af6962539 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.out @@ -0,0 +1 @@ +Foo := [Bar, Baz]; diff --git a/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.yaml b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.yaml new file mode 100644 index 000000000..b85264fde --- /dev/null +++ b/testsuite/tests/unparsing/bracket_aggregate/short_no_assoc_no_ancestor_expr/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added. diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/long/doc-baseline.json b/testsuite/tests/unparsing/bracket_delta_aggregate/long/doc-baseline.json new file mode 100644 index 000000000..a3af4357a --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/long/doc-baseline.json @@ -0,0 +1,273 @@ +{ + "id": 34, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 33, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 32, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "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": 2, + "kind": "text", + "text": "[" + }, + { + "id": 27, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 26, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 25, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar with delta" + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": "1 =>" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "2.0" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 13, + "kind": "text", + "text": "," + }, + { + "id": 14, + "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": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "text", + "text": "3 =>" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 19, + "kind": "text", + "text": "4.0" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + { + "id": 28, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 31, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/long/input.ada b/testsuite/tests/unparsing/bracket_delta_aggregate/long/input.ada new file mode 100644 index 000000000..79be195fd --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/long/input.ada @@ -0,0 +1,2 @@ +Foo := + [Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar with delta 1 => 2.0, 3 => 4.0]; diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/long/test.out b/testsuite/tests/unparsing/bracket_delta_aggregate/long/test.out new file mode 100644 index 000000000..ef364a1cf --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/long/test.out @@ -0,0 +1,4 @@ +Foo := + [Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar with delta + 1 => 2.0, + 3 => 4.0]; diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/long/test.yaml b/testsuite/tests/unparsing/bracket_delta_aggregate/long/test.yaml new file mode 100644 index 000000000..16c6fad81 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/long/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: stmt +description: | + Test that there is a line break after the `delta` keyword and the alignment + of `f_assocs`. diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/short/doc-baseline.json b/testsuite/tests/unparsing/bracket_delta_aggregate/short/doc-baseline.json new file mode 100644 index 000000000..1fc6a7ae0 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/short/doc-baseline.json @@ -0,0 +1,195 @@ +{ + "id": 24, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "[" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "Bar with delta" + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": "1 =>" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "2.0" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + { + "id": 18, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/short/input.ada b/testsuite/tests/unparsing/bracket_delta_aggregate/short/input.ada new file mode 100644 index 000000000..eb06d1621 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/short/input.ada @@ -0,0 +1 @@ +Foo := [Bar with delta 1 => 2.0]; diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/short/test.out b/testsuite/tests/unparsing/bracket_delta_aggregate/short/test.out new file mode 100644 index 000000000..dc08169e3 --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/short/test.out @@ -0,0 +1 @@ +Foo := [Bar with delta 1 => 2.0]; diff --git a/testsuite/tests/unparsing/bracket_delta_aggregate/short/test.yaml b/testsuite/tests/unparsing/bracket_delta_aggregate/short/test.yaml new file mode 100644 index 000000000..b85264fde --- /dev/null +++ b/testsuite/tests/unparsing/bracket_delta_aggregate/short/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added. diff --git a/testsuite/tests/unparsing/delta_aggregate/long/doc-baseline.json b/testsuite/tests/unparsing/delta_aggregate/long/doc-baseline.json new file mode 100644 index 000000000..15e2df9f7 --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/long/doc-baseline.json @@ -0,0 +1,193 @@ +{ + "id": 24, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "(Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar with delta" + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": " 1 =>" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 7, + "kind": "text", + "text": "2.0" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 11, + "kind": "text", + "text": "," + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "text", + "text": "3 =>" + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 17, + "kind": "text", + "text": "4.0" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "text", + "text": ");" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/delta_aggregate/long/input.ada b/testsuite/tests/unparsing/delta_aggregate/long/input.ada new file mode 100644 index 000000000..c755f337b --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/long/input.ada @@ -0,0 +1,2 @@ +Foo := + (Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar with delta 1 => 2.0, 3 => 4.0); diff --git a/testsuite/tests/unparsing/delta_aggregate/long/test.out b/testsuite/tests/unparsing/delta_aggregate/long/test.out new file mode 100644 index 000000000..b4d2367cb --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/long/test.out @@ -0,0 +1,4 @@ +Foo := + (Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar with delta + 1 => 2.0, + 3 => 4.0); diff --git a/testsuite/tests/unparsing/delta_aggregate/long/test.yaml b/testsuite/tests/unparsing/delta_aggregate/long/test.yaml new file mode 100644 index 000000000..0293f4162 --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/long/test.yaml @@ -0,0 +1,10 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added. +control: + - [ + "XFAIL", + "True", + "Unparser considers this as an aggregate and not a delta aggregate", + ] diff --git a/testsuite/tests/unparsing/delta_aggregate/short/doc-baseline.json b/testsuite/tests/unparsing/delta_aggregate/short/doc-baseline.json new file mode 100644 index 000000000..521f4cc9c --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/short/doc-baseline.json @@ -0,0 +1,115 @@ +{ + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "(Bar with delta" + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": " 1 =>" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 7, + "kind": "text", + "text": "2.0" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 11, + "kind": "text", + "text": ");" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/delta_aggregate/short/input.ada b/testsuite/tests/unparsing/delta_aggregate/short/input.ada new file mode 100644 index 000000000..0ba3c8f89 --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/short/input.ada @@ -0,0 +1 @@ +Foo := (Bar with delta 1 => 2.0); diff --git a/testsuite/tests/unparsing/delta_aggregate/short/test.out b/testsuite/tests/unparsing/delta_aggregate/short/test.out new file mode 100644 index 000000000..c0233ab6c --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/short/test.out @@ -0,0 +1 @@ +Foo := (Bar with delta 1 => 2.0); diff --git a/testsuite/tests/unparsing/delta_aggregate/short/test.yaml b/testsuite/tests/unparsing/delta_aggregate/short/test.yaml new file mode 100644 index 000000000..16c6fad81 --- /dev/null +++ b/testsuite/tests/unparsing/delta_aggregate/short/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: stmt +description: | + Test that there is a line break after the `delta` keyword and the alignment + of `f_assocs`.