From 0b0c9ba181943a8a1e8894b4d5b8ef960894229d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Azevedo?= Date: Wed, 28 Feb 2024 17:15:10 +0000 Subject: [PATCH] Unparsing: add config for PragmaNode and PragmaNodeList --- extensions/default_unparsing_config.json | 96 ++ .../short_with_pragma/doc-baseline.json | 304 ++++-- .../pragma_node/long/doc-baseline.json | 79 ++ .../unparsing/pragma_node/long/input.ada | 1 + .../tests/unparsing/pragma_node/long/test.out | 2 + .../unparsing/pragma_node/long/test.yaml | 5 + .../doc-baseline.json | 241 +++++ .../long_with_long_arguments/input.ada | 1 + .../long_with_long_arguments/test.out | 5 + .../long_with_long_arguments/test.yaml | 6 + .../pragma_node/short/doc-baseline.json | 79 ++ .../unparsing/pragma_node/short/input.ada | 1 + .../unparsing/pragma_node/short/test.out | 1 + .../unparsing/pragma_node/short/test.yaml | 4 + .../pragma_node_list/doc-baseline.json | 982 ++++++++++++++++++ .../unparsing/pragma_node_list/input.ada | 11 + .../tests/unparsing/pragma_node_list/test.out | 13 + .../unparsing/pragma_node_list/test.yaml | 4 + 18 files changed, 1757 insertions(+), 78 deletions(-) create mode 100644 testsuite/tests/unparsing/pragma_node/long/doc-baseline.json create mode 100644 testsuite/tests/unparsing/pragma_node/long/input.ada create mode 100644 testsuite/tests/unparsing/pragma_node/long/test.out create mode 100644 testsuite/tests/unparsing/pragma_node/long/test.yaml create mode 100644 testsuite/tests/unparsing/pragma_node/long_with_long_arguments/doc-baseline.json create mode 100644 testsuite/tests/unparsing/pragma_node/long_with_long_arguments/input.ada create mode 100644 testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.out create mode 100644 testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.yaml create mode 100644 testsuite/tests/unparsing/pragma_node/short/doc-baseline.json create mode 100644 testsuite/tests/unparsing/pragma_node/short/input.ada create mode 100644 testsuite/tests/unparsing/pragma_node/short/test.out create mode 100644 testsuite/tests/unparsing/pragma_node/short/test.yaml create mode 100644 testsuite/tests/unparsing/pragma_node_list/doc-baseline.json create mode 100644 testsuite/tests/unparsing/pragma_node_list/input.ada create mode 100644 testsuite/tests/unparsing/pragma_node_list/test.out create mode 100644 testsuite/tests/unparsing/pragma_node_list/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index ee01e6405..b407162c3 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -131,6 +131,12 @@ } } }, + "BaseAssocList": { + "sep": [ + "recurse", + "line" + ] + }, "BinOp": { "node": { "kind": "group", @@ -1418,6 +1424,96 @@ } } }, + "PragmaArgumentAssoc": { + "node": { + "kind": "group", + "document": { + "kind": "align", + "width": 2, + "contents": [ + { + "kind": "recurse_field", + "field": "f_name" + }, + { + "kind": "recurse_field", + "field": "f_expr" + } + ] + } + }, + "fields": { + "f_name": [ + "recurse", + "whitespace", + { + "kind": "text", + "text": "=>" + }, + "line" + ] + } + }, + "PragmaNode": { + "node": { + "kind": "group", + "document": { + "kind": "align", + "width": 2, + "contents": [ + { + "kind": "text", + "text": "pragma" + }, + "line", + { + "kind": "group", + "document": { + "kind": "align", + "width": 2, + "contents": [ + { + "kind": "recurse_field", + "field": "f_id" + }, + { + "kind": "recurse_field", + "field": "f_args" + } + ] + } + }, + { + "kind": "text", + "text": ";" + } + ] + } + }, + "fields": { + "f_args": [ + "line", + { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "(" + }, + { + "kind": "align", + "width": 1, + "contents": "recurse" + }, + { + "kind": "text", + "text": ")" + } + ] + } + ] + } + }, "PragmaNodeList": { "sep": [ "recurse", diff --git a/testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json b/testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json index 44763bc60..53ed35cae 100644 --- a/testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json +++ b/testsuite/tests/unparsing/case_stmt/short_with_pragma/doc-baseline.json @@ -1,11 +1,11 @@ { - "id": 81, + "id": 99, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 80, + "id": 98, "kind": "list", "list": [ { @@ -61,12 +61,12 @@ } }, { - "id": 75, + "id": 93, "kind": "command", "command": { "command": "indent", "indentContents": { - "id": 74, + "id": 92, "kind": "list", "list": [ { @@ -80,26 +80,100 @@ } }, { - "id": 16, + "id": 34, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 15, + "id": 33, "kind": "list", "list": [ { - "id": 8, - "kind": "text", - "text": "pragma Foo_Bar;" + "id": 17, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "text", + "text": "pragma" + }, + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "text", + "text": "Foo_Bar" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } }, { - "id": 11, + "id": 20, "kind": "list", "list": [ { - "id": 9, + "id": 18, "kind": "command", "command": { "command": "line", @@ -109,7 +183,7 @@ } }, { - "id": 10, + "id": 19, "kind": "command", "command": { "command": "breakParent" @@ -118,12 +192,86 @@ ] }, { - "id": 12, - "kind": "text", - "text": "pragma Bar_Foo;" + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 28, + "kind": "list", + "list": [ + { + "id": 21, + "kind": "text", + "text": "pragma" + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 25, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 23, + "kind": "text", + "text": "Bar_Foo" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 27, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } }, { - "id": 13, + "id": 31, "kind": "command", "command": { "command": "line", @@ -133,7 +281,7 @@ } }, { - "id": 14, + "id": 32, "kind": "command", "command": { "command": "line", @@ -149,57 +297,57 @@ } }, { - "id": 73, + "id": 91, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 72, + "id": 90, "kind": "list", "list": [ { - "id": 33, + "id": 51, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 32, + "id": 50, "kind": "list", "list": [ { - "id": 25, + "id": 43, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 24, + "id": 42, "kind": "list", "list": [ { - "id": 21, + "id": 39, "kind": "command", "command": { "command": "indent", "indentContents": { - "id": 20, + "id": 38, "kind": "list", "list": [ { - "id": 17, + "id": 35, "kind": "text", "text": "when " }, { - "id": 19, + "id": 37, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 18, + "id": 36, "kind": "text", "text": "Bar" }, @@ -212,7 +360,7 @@ } }, { - "id": 22, + "id": 40, "kind": "command", "command": { "command": "line", @@ -222,7 +370,7 @@ } }, { - "id": 23, + "id": 41, "kind": "text", "text": "=>" } @@ -233,16 +381,16 @@ } }, { - "id": 31, + "id": 49, "kind": "command", "command": { "command": "indent", "indentContents": { - "id": 30, + "id": 48, "kind": "list", "list": [ { - "id": 26, + "id": 44, "kind": "command", "command": { "command": "line", @@ -252,17 +400,17 @@ } }, { - "id": 29, + "id": 47, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 28, + "id": 46, "kind": "list", "list": [ { - "id": 27, + "id": 45, "kind": "text", "text": "null;" } @@ -283,7 +431,7 @@ } }, { - "id": 34, + "id": 52, "kind": "command", "command": { "command": "line", @@ -293,7 +441,7 @@ } }, { - "id": 35, + "id": 53, "kind": "command", "command": { "command": "line", @@ -303,47 +451,47 @@ } }, { - "id": 52, + "id": 70, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 51, + "id": 69, "kind": "list", "list": [ { - "id": 44, + "id": 62, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 43, + "id": 61, "kind": "list", "list": [ { - "id": 40, + "id": 58, "kind": "command", "command": { "command": "indent", "indentContents": { - "id": 39, + "id": 57, "kind": "list", "list": [ { - "id": 36, + "id": 54, "kind": "text", "text": "when " }, { - "id": 38, + "id": 56, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 37, + "id": 55, "kind": "text", "text": "Baz" }, @@ -356,7 +504,7 @@ } }, { - "id": 41, + "id": 59, "kind": "command", "command": { "command": "line", @@ -366,7 +514,7 @@ } }, { - "id": 42, + "id": 60, "kind": "text", "text": "=>" } @@ -377,16 +525,16 @@ } }, { - "id": 50, + "id": 68, "kind": "command", "command": { "command": "indent", "indentContents": { - "id": 49, + "id": 67, "kind": "list", "list": [ { - "id": 45, + "id": 63, "kind": "command", "command": { "command": "line", @@ -396,17 +544,17 @@ } }, { - "id": 48, + "id": 66, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 47, + "id": 65, "kind": "list", "list": [ { - "id": 46, + "id": 64, "kind": "text", "text": "null;" } @@ -427,7 +575,7 @@ } }, { - "id": 53, + "id": 71, "kind": "command", "command": { "command": "line", @@ -437,7 +585,7 @@ } }, { - "id": 54, + "id": 72, "kind": "command", "command": { "command": "line", @@ -447,47 +595,47 @@ } }, { - "id": 71, + "id": 89, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 70, + "id": 88, "kind": "list", "list": [ { - "id": 63, + "id": 81, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 62, + "id": 80, "kind": "list", "list": [ { - "id": 59, + "id": 77, "kind": "command", "command": { "command": "indent", "indentContents": { - "id": 58, + "id": 76, "kind": "list", "list": [ { - "id": 55, + "id": 73, "kind": "text", "text": "when " }, { - "id": 57, + "id": 75, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 56, + "id": 74, "kind": "text", "text": "others" }, @@ -500,7 +648,7 @@ } }, { - "id": 60, + "id": 78, "kind": "command", "command": { "command": "line", @@ -510,7 +658,7 @@ } }, { - "id": 61, + "id": 79, "kind": "text", "text": "=>" } @@ -521,16 +669,16 @@ } }, { - "id": 69, + "id": 87, "kind": "command", "command": { "command": "indent", "indentContents": { - "id": 68, + "id": 86, "kind": "list", "list": [ { - "id": 64, + "id": 82, "kind": "command", "command": { "command": "line", @@ -540,17 +688,17 @@ } }, { - "id": 67, + "id": 85, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 66, + "id": 84, "kind": "list", "list": [ { - "id": 65, + "id": 83, "kind": "text", "text": "null;" } @@ -581,11 +729,11 @@ } }, { - "id": 78, + "id": 96, "kind": "list", "list": [ { - "id": 76, + "id": 94, "kind": "command", "command": { "command": "line", @@ -595,7 +743,7 @@ } }, { - "id": 77, + "id": 95, "kind": "command", "command": { "command": "breakParent" @@ -604,7 +752,7 @@ ] }, { - "id": 79, + "id": 97, "kind": "text", "text": "end case;" } diff --git a/testsuite/tests/unparsing/pragma_node/long/doc-baseline.json b/testsuite/tests/unparsing/pragma_node/long/doc-baseline.json new file mode 100644 index 000000000..b891bfbbc --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long/doc-baseline.json @@ -0,0 +1,79 @@ +{ + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "pragma" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 6, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/pragma_node/long/input.ada b/testsuite/tests/unparsing/pragma_node/long/input.ada new file mode 100644 index 000000000..01fab9095 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long/input.ada @@ -0,0 +1 @@ +pragma Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; diff --git a/testsuite/tests/unparsing/pragma_node/long/test.out b/testsuite/tests/unparsing/pragma_node/long/test.out new file mode 100644 index 000000000..e7bc31166 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long/test.out @@ -0,0 +1,2 @@ +pragma + Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; diff --git a/testsuite/tests/unparsing/pragma_node/long/test.yaml b/testsuite/tests/unparsing/pragma_node/long/test.yaml new file mode 100644 index 000000000..bf7c18023 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: pragma +description: | + Test that when the pragma is long, a line break is added after the `pragma` + keyword. diff --git a/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/doc-baseline.json b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/doc-baseline.json new file mode 100644 index 000000000..93185b3e2 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/doc-baseline.json @@ -0,0 +1,241 @@ +{ + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 28, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "pragma" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 25, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "Quxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "(" + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 8, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": "Garplyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy =>" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 7, + "kind": "text", + "text": "\"Corge\"" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 11, + "kind": "text", + "text": "," + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 16, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "text", + "text": "Foo =>" + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 15, + "kind": "text", + "text": "Bar" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 21, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 27, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/input.ada b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/input.ada new file mode 100644 index 000000000..74e8fc7bd --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/input.ada @@ -0,0 +1 @@ +pragma Quxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (Garplyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy => "Corge", Foo => Bar); diff --git a/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.out b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.out new file mode 100644 index 000000000..f27f95ccb --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.out @@ -0,0 +1,5 @@ +pragma + Quxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + (Garplyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy => + "Corge", + Foo => Bar); diff --git a/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.yaml b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.yaml new file mode 100644 index 000000000..44acbf296 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/long_with_long_arguments/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: pragma +description: | + Test that when the pragma and its arguments are long, a like break is added + after the `pragma` keyword as well as after `f_id`. Also test the + continuation line indentation for `f_id` and `f_args` diff --git a/testsuite/tests/unparsing/pragma_node/short/doc-baseline.json b/testsuite/tests/unparsing/pragma_node/short/doc-baseline.json new file mode 100644 index 000000000..301c6d084 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/short/doc-baseline.json @@ -0,0 +1,79 @@ +{ + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "pragma" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "Foo" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 6, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/pragma_node/short/input.ada b/testsuite/tests/unparsing/pragma_node/short/input.ada new file mode 100644 index 000000000..9899b0213 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/short/input.ada @@ -0,0 +1 @@ +pragma Foo; diff --git a/testsuite/tests/unparsing/pragma_node/short/test.out b/testsuite/tests/unparsing/pragma_node/short/test.out new file mode 100644 index 000000000..9899b0213 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/short/test.out @@ -0,0 +1 @@ +pragma Foo; diff --git a/testsuite/tests/unparsing/pragma_node/short/test.yaml b/testsuite/tests/unparsing/pragma_node/short/test.yaml new file mode 100644 index 000000000..27025470d --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node/short/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: pragma +description: | + Base test for a short pragma. Test that no line breaks are added. diff --git a/testsuite/tests/unparsing/pragma_node_list/doc-baseline.json b/testsuite/tests/unparsing/pragma_node_list/doc-baseline.json new file mode 100644 index 000000000..1df257c6d --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node_list/doc-baseline.json @@ -0,0 +1,982 @@ +{ + "id": 126, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 125, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "case " + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 1, + "kind": "text", + "text": "Fox" + } + } + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 4, + "kind": "text", + "text": "is" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 120, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 119, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 80, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 79, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "text", + "text": "pragma" + }, + { + "id": 9, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "text", + "text": "Foo" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 20, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 39, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 38, + "kind": "list", + "list": [ + { + "id": 21, + "kind": "text", + "text": "pragma" + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 35, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 34, + "kind": "list", + "list": [ + { + "id": 23, + "kind": "text", + "text": "Bar" + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 33, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 32, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "text", + "text": "(" + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 29, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 26, + "kind": "text", + "text": "Baz" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + } + } + }, + { + "id": 31, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 37, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": 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": 53, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 52, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 51, + "kind": "list", + "list": [ + { + "id": 44, + "kind": "text", + "text": "pragma" + }, + { + "id": 45, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 49, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 48, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 47, + "kind": "list", + "list": [ + { + "id": 46, + "kind": "text", + "text": "Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 50, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 56, + "kind": "list", + "list": [ + { + "id": 54, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 55, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 76, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 75, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 74, + "kind": "list", + "list": [ + { + "id": 57, + "kind": "text", + "text": "pragma" + }, + { + "id": 58, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 72, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 71, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 70, + "kind": "list", + "list": [ + { + "id": 59, + "kind": "text", + "text": "Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux" + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 69, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 61, + "kind": "text", + "text": "(" + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 65, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 64, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 62, + "kind": "text", + "text": "\"Corge\"" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + } + } + }, + { + "id": 67, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 73, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 77, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 78, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + } + ] + }, + "break": true, + "expandedStates": null + } + }, + { + "id": 118, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 117, + "kind": "list", + "list": [ + { + "id": 97, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 96, + "kind": "list", + "list": [ + { + "id": 89, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 88, + "kind": "list", + "list": [ + { + "id": 85, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 84, + "kind": "list", + "list": [ + { + "id": 81, + "kind": "text", + "text": "when " + }, + { + "id": 83, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 82, + "kind": "text", + "text": "A" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 86, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 87, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 95, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 94, + "kind": "list", + "list": [ + { + "id": 90, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 93, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 92, + "kind": "list", + "list": [ + { + "id": 91, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 98, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 99, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 116, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 115, + "kind": "list", + "list": [ + { + "id": 108, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 107, + "kind": "list", + "list": [ + { + "id": 104, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 103, + "kind": "list", + "list": [ + { + "id": 100, + "kind": "text", + "text": "when " + }, + { + "id": 102, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 101, + "kind": "text", + "text": "B" + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 105, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 106, + "kind": "text", + "text": "=>" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 114, + "kind": "command", + "command": { + "command": "indent", + "indentContents": { + "id": 113, + "kind": "list", + "list": [ + { + "id": 109, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 112, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 111, + "kind": "list", + "list": [ + { + "id": 110, + "kind": "text", + "text": "null;" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 123, + "kind": "list", + "list": [ + { + "id": 121, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": true + } + }, + { + "id": 122, + "kind": "command", + "command": { + "command": "breakParent" + } + } + ] + }, + { + "id": 124, + "kind": "text", + "text": "end case;" + } + ] + }, + "break": true, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/pragma_node_list/input.ada b/testsuite/tests/unparsing/pragma_node_list/input.ada new file mode 100644 index 000000000..3ba0bd334 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node_list/input.ada @@ -0,0 +1,11 @@ +case Fox is + pragma Foo; + pragma Bar (Baz); + pragma Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; + pragma Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux ("Corge"); + + when A => null; + + when B => null; +end case; + diff --git a/testsuite/tests/unparsing/pragma_node_list/test.out b/testsuite/tests/unparsing/pragma_node_list/test.out new file mode 100644 index 000000000..bb2186b38 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node_list/test.out @@ -0,0 +1,13 @@ +case Fox is + pragma Foo; + pragma Bar (Baz); + pragma + Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo; + pragma + Quuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuux + ("Corge"); + + when A => null; + + when B => null; +end case; diff --git a/testsuite/tests/unparsing/pragma_node_list/test.yaml b/testsuite/tests/unparsing/pragma_node_list/test.yaml new file mode 100644 index 000000000..e3750d033 --- /dev/null +++ b/testsuite/tests/unparsing/pragma_node_list/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: case_stmt +description: | + Test that each `PragmaNode` is separated by a line break.