diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 417a7f57f..2299c69c5 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -2817,6 +2817,72 @@ } } }, + "NumberDecl": { + "node": { + "kind": "group", + "document": [ + { + "kind": "group", + "document": { + "kind": "align", + "width": 2, + "contents": [ + { + "kind": "recurse_field", + "field": "f_ids" + }, + "whitespace", + { + "kind": "text", + "text": ":" + }, + "line", + { + "kind": "text", + "text": "constant" + }, + "whitespace", + { + "kind": "text", + "text": ":=" + } + ] + }, + "id": "constant_ids" + }, + { + "kind": "ifBreak", + "breakContents": { + "kind": "align", + "width": 4, + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_expr" + } + ] + }, + "flatContents": { + "kind": "align", + "width": 2, + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_expr" + } + ] + }, + "groupId": "constant_ids" + }, + { + "kind": "text", + "text": ";" + } + ] + } + }, "ObjectDecl": { "node": { "kind": "group", diff --git a/testsuite/tests/unparsing/number_decl/long/doc-baseline.json b/testsuite/tests/unparsing/number_decl/long/doc-baseline.json new file mode 100644 index 000000000..7a5646460 --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/long/doc-baseline.json @@ -0,0 +1,140 @@ +{ + "id": 17, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 16, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo :" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "constant :=" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 9, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 8, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 7, + "kind": "text", + "text": "12222222222222222222222222222222222222222222222222222222222222222" + } + ] + } + } + }, + "flatContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 11, + "kind": "text", + "text": "12222222222222222222222222222222222222222222222222222222222222222" + } + ] + } + } + } + } + }, + { + "id": 15, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/number_decl/long/input.ada b/testsuite/tests/unparsing/number_decl/long/input.ada new file mode 100644 index 000000000..3a7ec885c --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/long/input.ada @@ -0,0 +1 @@ +Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo : constant := 12222222222222222222222222222222222222222222222222222222222222222; diff --git a/testsuite/tests/unparsing/number_decl/long/test.out b/testsuite/tests/unparsing/number_decl/long/test.out new file mode 100644 index 000000000..0a4865da4 --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/long/test.out @@ -0,0 +1,3 @@ +Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo : + constant := + 12222222222222222222222222222222222222222222222222222222222222222; diff --git a/testsuite/tests/unparsing/number_decl/long/test.yaml b/testsuite/tests/unparsing/number_decl/long/test.yaml new file mode 100644 index 000000000..005beef55 --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/long/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: number_decl +description: | + Test the line breaks and indentation after the `:` and `:=` tokens. diff --git a/testsuite/tests/unparsing/number_decl/short/doc-baseline.json b/testsuite/tests/unparsing/number_decl/short/doc-baseline.json new file mode 100644 index 000000000..04a6749c7 --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/short/doc-baseline.json @@ -0,0 +1,140 @@ +{ + "id": 17, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 16, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "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": "constant :=" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 9, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 8, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 7, + "kind": "text", + "text": "12" + } + ] + } + } + }, + "flatContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 11, + "kind": "text", + "text": "12" + } + ] + } + } + } + } + }, + { + "id": 15, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/number_decl/short/input.ada b/testsuite/tests/unparsing/number_decl/short/input.ada new file mode 100644 index 000000000..28ee3c8a5 --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/short/input.ada @@ -0,0 +1 @@ +Foo : constant := 12; diff --git a/testsuite/tests/unparsing/number_decl/short/test.out b/testsuite/tests/unparsing/number_decl/short/test.out new file mode 100644 index 000000000..28ee3c8a5 --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/short/test.out @@ -0,0 +1 @@ +Foo : constant := 12; diff --git a/testsuite/tests/unparsing/number_decl/short/test.yaml b/testsuite/tests/unparsing/number_decl/short/test.yaml new file mode 100644 index 000000000..af4c94e2c --- /dev/null +++ b/testsuite/tests/unparsing/number_decl/short/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: number_decl +description: | + Test that no line break are added.