diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 993c418bf..480a7df73 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -1,5 +1,57 @@ { "node_configs": { + "AspectAssocList": { + "sep": [ + "recurse", + "line" + ] + }, + "AspectSpec": { + "node": { + "kind": "group", + "document": [ + { + "kind": "group", + "document": [ + "line", + { + "kind": "text", + "text": "with" + } + ], + "id": "with_keyword" + }, + { + "kind": "ifBreak", + "breakContents": { + "kind": "align", + "width": 2, + "contents": { + "kind": "group", + "document": [ + "line", + { + "kind": "recurse_field", + "field": "f_aspect_assocs" + } + ] + } + }, + "flatContents": { + "kind": "group", + "document": [ + "line", + { + "kind": "recurse_field", + "field": "f_aspect_assocs" + } + ] + }, + "groupId": "with_keyword" + } + ] + } + }, "AssignStmt": { "node": { "kind": "align", @@ -288,6 +340,167 @@ ] } }, + "PackageBody": { + "node": [ + { + "kind": "group", + "document": [ + { + "kind": "group", + "document": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "package" + }, + "whitespace", + { + "kind": "text", + "text": "body" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_package_name" + }, + { + "kind": "align", + "width": 2, + "contents": { + "kind": "recurse_field", + "field": "f_aspects" + } + } + ] + } + }, + "line", + { + "kind": "text", + "text": "is" + } + ] + }, + { + "kind": "indent", + "contents": [ + "hardline", + { + "kind": "recurse_field", + "field": "f_decls" + } + ] + }, + "hardline", + { + "kind": "recurse_field", + "field": "f_stmts" + }, + { + "kind": "text", + "text": "end" + }, + { + "kind": "recurse_field", + "field": "f_end_name" + }, + { + "kind": "text", + "text": ";" + } + ], + "fields": { + "f_stmts": [ + { + "kind": "indent", + "contents": [ + "hardline", + "recurse" + ] + }, + "hardline" + ] + } + }, + "PackageDecl": { + "node": [ + { + "kind": "group", + "document": [ + { + "kind": "group", + "document": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "package" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_package_name" + }, + { + "kind": "align", + "width": 2, + "contents": { + "kind": "recurse_field", + "field": "f_aspects" + } + } + ] + } + }, + "line", + { + "kind": "text", + "text": "is" + } + ] + }, + { + "kind": "indent", + "contents": [ + "hardline", + { + "kind": "recurse_field", + "field": "f_public_part" + } + ] + }, + "hardline", + { + "kind": "recurse_field", + "field": "f_private_part" + }, + { + "kind": "text", + "text": "end" + }, + { + "kind": "recurse_field", + "field": "f_end_name" + }, + { + "kind": "text", + "text": ";" + } + ], + "fields": { + "f_private_part": [ + { + "kind": "indent", + "contents": [ + "hardline", + "recurse" + ] + }, + "hardline" + ] + } + }, "ParenExpr": { "node": { "kind": "align", diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/doc-baseline.json b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/doc-baseline.json new file mode 100644 index 000000000..90ecec18f --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/doc-baseline.json @@ -0,0 +1,336 @@ +{ + "id": 43, + "kind": "list", + "list": [ + { + "id": 32, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 28, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 27, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 26, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + }, + { + "id": 25, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 21, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 14, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar," + }, + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 16, + "kind": "text", + "text": "Baz," + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 18, + "kind": "text", + "text": "Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar," + }, + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 8, + "kind": "text", + "text": "Baz," + }, + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 29, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 30, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 38, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "list", + "list": [ + { + "id": 33, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 34, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 36, + "kind": "text", + "text": "type Corge;" + } + ] + } + } + }, + { + "id": 41, + "kind": "list", + "list": [ + { + "id": 39, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 42, + "kind": "text", + "text": "end Foo;" + } + ] +} diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/input.ada b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/input.ada new file mode 100644 index 000000000..6794fdca3 --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/input.ada @@ -0,0 +1,2 @@ +package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo with Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, Baz, Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux is type Corge; end Foo; + diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/test.out b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/test.out new file mode 100644 index 000000000..f751dfb41 --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/test.out @@ -0,0 +1,8 @@ +package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + with + Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, + Baz, + Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux +is + type Corge; +end Foo; diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/test.yaml b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/test.yaml new file mode 100644 index 000000000..0e22570cd --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_long_aspects/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: package_decl +descrition: | + When `f_aspect_assocs` with multiple aspects is long, test that: aspects are + indented relative to the `with` keyword with continuation line indentation; + each aspect is in its own line. diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/doc-baseline.json b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/doc-baseline.json new file mode 100644 index 000000000..49115e95b --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/doc-baseline.json @@ -0,0 +1,306 @@ +{ + "id": 39, + "kind": "list", + "list": [ + { + "id": 28, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foo" + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "text", + "text": "Bar," + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 14, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Bar," + }, + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 8, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 26, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 34, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "list", + "list": [ + { + "id": 29, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 32, + "kind": "text", + "text": "type Qux;" + } + ] + } + } + }, + { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 38, + "kind": "text", + "text": "end Foo;" + } + ] +} diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/input.ada b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/input.ada new file mode 100644 index 000000000..3f0678c43 --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/input.ada @@ -0,0 +1 @@ +package Foo with Bar, Baz is type Qux; end Foo; diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/test.out b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/test.out new file mode 100644 index 000000000..88c42d313 --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/test.out @@ -0,0 +1,3 @@ +package Foo with Bar, Baz is + type Qux; +end Foo; diff --git a/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/test.yaml b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/test.yaml new file mode 100644 index 000000000..211aa5c49 --- /dev/null +++ b/testsuite/tests/unparsing/aspect_spec/multiple_short_aspects/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: package_decl +descrition: | + Base test for an `AspectSpec` node with multiple aspects. diff --git a/testsuite/tests/unparsing/package_body/info b/testsuite/tests/unparsing/package_body/info new file mode 100644 index 000000000..9132018e0 --- /dev/null +++ b/testsuite/tests/unparsing/package_body/info @@ -0,0 +1,9 @@ +`PackageBody` and `PackageDecl` configurations are very similar. +`PackageBody` has an additional `body` keyword after the `package` keyword and +this does not affect the configuration when compared to the `PackageDecl` one. +`PackageBody` has an `F_Decls` field which can be considered as equivalent to +`PackageDecl`'s `F_Public_Part`. +`PackageBody` has an `F_Stmts` field which can be considered as equivalent to +`PackageDecl`'s `F_Private_Part`. +Therefore, two tests, one with statements and one without is enough. The rest +is covered by the `PackageDecl` tests. diff --git a/testsuite/tests/unparsing/package_body/short_names_w_stmts/doc-baseline.json b/testsuite/tests/unparsing/package_body/short_names_w_stmts/doc-baseline.json new file mode 100644 index 000000000..1570d047f --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_w_stmts/doc-baseline.json @@ -0,0 +1,345 @@ +{ + "id": 45, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package body Foo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "begin" + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 39, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 38, + "kind": "text", + "text": "null;" + } + ] + } + } + }, + { + "id": 43, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 44, + "kind": "text", + "text": "end Foo;" + } + ] +} diff --git a/testsuite/tests/unparsing/package_body/short_names_w_stmts/input.ada b/testsuite/tests/unparsing/package_body/short_names_w_stmts/input.ada new file mode 100644 index 000000000..09042f655 --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_w_stmts/input.ada @@ -0,0 +1 @@ +package body Foo with Bar is type Baz; begin null; end Foo; diff --git a/testsuite/tests/unparsing/package_body/short_names_w_stmts/test.out b/testsuite/tests/unparsing/package_body/short_names_w_stmts/test.out new file mode 100644 index 000000000..ee2e350d5 --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_w_stmts/test.out @@ -0,0 +1,5 @@ +package body Foo with Bar is + type Baz; +begin + null; +end Foo; diff --git a/testsuite/tests/unparsing/package_body/short_names_w_stmts/test.yaml b/testsuite/tests/unparsing/package_body/short_names_w_stmts/test.yaml new file mode 100644 index 000000000..b3f8c6a33 --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_w_stmts/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: package_body +descrition: | + For a short `F_Package_Name` and `F_Aspects`, test that they are in the same + line. + Test that `F_Decls` is indented. diff --git a/testsuite/tests/unparsing/package_body/short_names_wo_stmts/doc-baseline.json b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/doc-baseline.json new file mode 100644 index 000000000..1e82cd0a6 --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/doc-baseline.json @@ -0,0 +1,276 @@ +{ + "id": 35, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package body Foo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "end Foo;" + } + ] +} diff --git a/testsuite/tests/unparsing/package_body/short_names_wo_stmts/input.ada b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/input.ada new file mode 100644 index 000000000..beb00187b --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/input.ada @@ -0,0 +1 @@ +package body Foo with Bar is type Baz; end Foo; diff --git a/testsuite/tests/unparsing/package_body/short_names_wo_stmts/test.out b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/test.out new file mode 100644 index 000000000..6169299b2 --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/test.out @@ -0,0 +1,3 @@ +package body Foo with Bar is + type Baz; +end Foo; diff --git a/testsuite/tests/unparsing/package_body/short_names_wo_stmts/test.yaml b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/test.yaml new file mode 100644 index 000000000..b3f8c6a33 --- /dev/null +++ b/testsuite/tests/unparsing/package_body/short_names_wo_stmts/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: package_body +descrition: | + For a short `F_Package_Name` and `F_Aspects`, test that they are in the same + line. + Test that `F_Decls` is indented. diff --git a/testsuite/tests/unparsing/package_decl/long_aspect/doc-baseline.json b/testsuite/tests/unparsing/package_decl/long_aspect/doc-baseline.json new file mode 100644 index 000000000..8f0497d86 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_aspect/doc-baseline.json @@ -0,0 +1,345 @@ +{ + "id": 45, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "private" + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 39, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 38, + "kind": "text", + "text": "type Qux;" + } + ] + } + } + }, + { + "id": 43, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 44, + "kind": "text", + "text": "end Foo;" + } + ] +} \ No newline at end of file diff --git a/testsuite/tests/unparsing/package_decl/long_aspect/input.ada b/testsuite/tests/unparsing/package_decl/long_aspect/input.ada new file mode 100644 index 000000000..339d463a9 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_aspect/input.ada @@ -0,0 +1 @@ +package Foo with Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar is type Baz; private type Qux; end Foo; diff --git a/testsuite/tests/unparsing/package_decl/long_aspect/test.out b/testsuite/tests/unparsing/package_decl/long_aspect/test.out new file mode 100644 index 000000000..cdb565f95 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_aspect/test.out @@ -0,0 +1,7 @@ +package Foo with + Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar +is + type Baz; +private + type Qux; +end Foo; diff --git a/testsuite/tests/unparsing/package_decl/long_aspect/test.yaml b/testsuite/tests/unparsing/package_decl/long_aspect/test.yaml new file mode 100644 index 000000000..24572ccb3 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_aspect/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: package_decl +descrition: | + For a long single line `F_Aspects`, test that a line break is added + after the `with` keyword. diff --git a/testsuite/tests/unparsing/package_decl/long_name/doc-baseline.json b/testsuite/tests/unparsing/package_decl/long_name/doc-baseline.json new file mode 100644 index 000000000..563d2d1b0 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name/doc-baseline.json @@ -0,0 +1,345 @@ +{ + "id": 45, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "private" + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 39, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 38, + "kind": "text", + "text": "type Qux;" + } + ] + } + } + }, + { + "id": 43, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 44, + "kind": "text", + "text": "end Foo;" + } + ] +} \ No newline at end of file diff --git a/testsuite/tests/unparsing/package_decl/long_name/input.ada b/testsuite/tests/unparsing/package_decl/long_name/input.ada new file mode 100644 index 000000000..63b859851 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name/input.ada @@ -0,0 +1 @@ +package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo with Bar is type Baz; private type Qux; end Foo; diff --git a/testsuite/tests/unparsing/package_decl/long_name/test.out b/testsuite/tests/unparsing/package_decl/long_name/test.out new file mode 100644 index 000000000..15d1ed2de --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name/test.out @@ -0,0 +1,7 @@ +package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + with Bar +is + type Baz; +private + type Qux; +end Foo; diff --git a/testsuite/tests/unparsing/package_decl/long_name/test.yaml b/testsuite/tests/unparsing/package_decl/long_name/test.yaml new file mode 100644 index 000000000..895eb17f1 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: package_decl +descrition: | + For a long single line `F_Package_Name`, test that a line break is added + before the `with` keyword. diff --git a/testsuite/tests/unparsing/package_decl/long_name_and_aspect/doc-baseline.json b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/doc-baseline.json new file mode 100644 index 000000000..0e81116bf --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/doc-baseline.json @@ -0,0 +1,345 @@ +{ + "id": 45, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "private" + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 39, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 38, + "kind": "text", + "text": "type Qux;" + } + ] + } + } + }, + { + "id": 43, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 44, + "kind": "text", + "text": "end Foo;" + } + ] +} \ No newline at end of file diff --git a/testsuite/tests/unparsing/package_decl/long_name_and_aspect/input.ada b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/input.ada new file mode 100644 index 000000000..fcbcadc5d --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/input.ada @@ -0,0 +1 @@ +package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo with Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar is type Baz; private type Qux; end Foo; diff --git a/testsuite/tests/unparsing/package_decl/long_name_and_aspect/test.out b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/test.out new file mode 100644 index 000000000..3d6c303f7 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/test.out @@ -0,0 +1,8 @@ +package Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + with + Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar +is + type Baz; +private + type Qux; +end Foo; diff --git a/testsuite/tests/unparsing/package_decl/long_name_and_aspect/test.yaml b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/test.yaml new file mode 100644 index 000000000..94fc68048 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/long_name_and_aspect/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: package_decl +descrition: | + For a long `F_Package_Name` and long `F_Aspects`, test that a line break is + added before and after the `with` keyword. diff --git a/testsuite/tests/unparsing/package_decl/no_end_name/doc-baseline.json b/testsuite/tests/unparsing/package_decl/no_end_name/doc-baseline.json new file mode 100644 index 000000000..e08be097c --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_end_name/doc-baseline.json @@ -0,0 +1,345 @@ +{ + "id": 45, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "private" + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 39, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 38, + "kind": "text", + "text": "type Qux;" + } + ] + } + } + }, + { + "id": 43, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 44, + "kind": "text", + "text": "end;" + } + ] +} diff --git a/testsuite/tests/unparsing/package_decl/no_end_name/input.ada b/testsuite/tests/unparsing/package_decl/no_end_name/input.ada new file mode 100644 index 000000000..717f0384b --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_end_name/input.ada @@ -0,0 +1 @@ +package Foo with Bar is type Baz; private type Qux; end; diff --git a/testsuite/tests/unparsing/package_decl/no_end_name/test.out b/testsuite/tests/unparsing/package_decl/no_end_name/test.out new file mode 100644 index 000000000..1138bd6c9 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_end_name/test.out @@ -0,0 +1,5 @@ +package Foo with Bar is + type Baz; +private + type Qux; +end; diff --git a/testsuite/tests/unparsing/package_decl/no_end_name/test.yaml b/testsuite/tests/unparsing/package_decl/no_end_name/test.yaml new file mode 100644 index 000000000..a1cb069d6 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_end_name/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: package_decl +descrition: | + Test when `F_End_Name` is null. diff --git a/testsuite/tests/unparsing/package_decl/no_private_part/doc-baseline.json b/testsuite/tests/unparsing/package_decl/no_private_part/doc-baseline.json new file mode 100644 index 000000000..cbd1d0a13 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_private_part/doc-baseline.json @@ -0,0 +1,276 @@ +{ + "id": 35, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "end Foo;" + } + ] +} diff --git a/testsuite/tests/unparsing/package_decl/no_private_part/input.ada b/testsuite/tests/unparsing/package_decl/no_private_part/input.ada new file mode 100644 index 000000000..84e6e30e9 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_private_part/input.ada @@ -0,0 +1 @@ +package Foo with Bar is type Baz; end Foo; diff --git a/testsuite/tests/unparsing/package_decl/no_private_part/test.out b/testsuite/tests/unparsing/package_decl/no_private_part/test.out new file mode 100644 index 000000000..cc3314388 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_private_part/test.out @@ -0,0 +1,3 @@ +package Foo with Bar is + type Baz; +end Foo; diff --git a/testsuite/tests/unparsing/package_decl/no_private_part/test.yaml b/testsuite/tests/unparsing/package_decl/no_private_part/test.yaml new file mode 100644 index 000000000..71a42b4b8 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/no_private_part/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: package_decl +descrition: | + Test when `F_Private_Part` is null. diff --git a/testsuite/tests/unparsing/package_decl/short_names/doc-baseline.json b/testsuite/tests/unparsing/package_decl/short_names/doc-baseline.json new file mode 100644 index 000000000..a8908c44c --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/short_names/doc-baseline.json @@ -0,0 +1,345 @@ +{ + "id": 45, + "kind": "list", + "list": [ + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "package Foo" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 10, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 28, + "kind": "text", + "text": "type Baz;" + } + ] + } + } + }, + { + "id": 33, + "kind": "list", + "list": [ + { + "id": 31, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 34, + "kind": "text", + "text": "private" + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 39, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 38, + "kind": "text", + "text": "type Qux;" + } + ] + } + } + }, + { + "id": 43, + "kind": "list", + "list": [ + { + "id": 41, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 44, + "kind": "text", + "text": "end Foo;" + } + ] +} \ No newline at end of file diff --git a/testsuite/tests/unparsing/package_decl/short_names/input.ada b/testsuite/tests/unparsing/package_decl/short_names/input.ada new file mode 100644 index 000000000..27e97199d --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/short_names/input.ada @@ -0,0 +1 @@ +package Foo with Bar is type Baz; private type Qux; end Foo; diff --git a/testsuite/tests/unparsing/package_decl/short_names/test.out b/testsuite/tests/unparsing/package_decl/short_names/test.out new file mode 100644 index 000000000..7431dc912 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/short_names/test.out @@ -0,0 +1,5 @@ +package Foo with Bar is + type Baz; +private + type Qux; +end Foo; diff --git a/testsuite/tests/unparsing/package_decl/short_names/test.yaml b/testsuite/tests/unparsing/package_decl/short_names/test.yaml new file mode 100644 index 000000000..de73ccdd4 --- /dev/null +++ b/testsuite/tests/unparsing/package_decl/short_names/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: package_decl +descrition: | + For a short `F_Package_Name` and `F_Aspects`, test that they are in the same + line. + Test that `F_Public_Part` and `F_Private_Part` are indented.