diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 0a0f79067..7ed5c2968 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -429,10 +429,13 @@ { "kind": "align", "width": 2, - "contents": { - "kind": "recurse_field", - "field": "f_expr" - } + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_expr" + } + ] }, { "kind": "text", @@ -1106,6 +1109,65 @@ "line" ] }, + "ContractCases": { + "node": { + "kind": "group", + "document": { + "kind": "align", + "width": 1, + "contents": [ + { + "kind": "text", + "text": "(" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_contract_cases" + } + }, + { + "kind": "text", + "text": ")" + } + ] + } + } + }, + "ContractCaseAssoc": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_guard" + }, + "whitespace", + { + "kind": "text", + "text": "=>" + }, + { + "kind": "align", + "width": 2, + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_consequence" + } + ] + } + ] + } + }, + "ContractCaseAssocList": { + "sep": [ + "recurse", + "line" + ] + }, "ConcreteFormalSubpDecl": { "node": { "kind": "align", diff --git a/testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json b/testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json index 013181523..b06573e11 100644 --- a/testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json +++ b/testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json @@ -1,11 +1,11 @@ { - "id": 10, + "id": 11, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 9, + "id": 10, "kind": "list", "list": [ { @@ -40,7 +40,7 @@ "text": " use" }, { - "id": 7, + "id": 8, "kind": "command", "command": { "command": "align", @@ -49,20 +49,30 @@ "n": 2 }, "alignContents": { - "id": 6, + "id": 7, "kind": "list", "list": [ { "id": 5, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, "kind": "text", - "text": " 16" + "text": "16" } ] } } }, { - "id": 8, + "id": 9, "kind": "text", "text": ";" } diff --git a/testsuite/tests/unparsing/contract_cases/long/doc-baseline.json b/testsuite/tests/unparsing/contract_cases/long/doc-baseline.json new file mode 100644 index 000000000..103204454 --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long/doc-baseline.json @@ -0,0 +1,538 @@ +{ + "id": 70, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 69, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "(" + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 65, + "kind": "list", + "list": [ + { + "id": 34, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "X" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": "* " + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 4, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 9, + "kind": "text", + "text": "< " + }, + { + "id": 11, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 10, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "text", + "text": " =>" + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 16, + "kind": "text", + "text": "Mult'Result" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 20, + "kind": "text", + "text": "= " + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 27, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 26, + "kind": "list", + "list": [ + { + "id": 21, + "kind": "text", + "text": "X" + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 23, + "kind": "text", + "text": "* " + }, + { + "id": 25, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 24, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 35, + "kind": "text", + "text": "," + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 64, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 49, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 48, + "kind": "list", + "list": [ + { + "id": 43, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 42, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "text", + "text": "X" + }, + { + "id": 38, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 39, + "kind": "text", + "text": "* " + }, + { + "id": 41, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 40, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 44, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 45, + "kind": "text", + "text": ">= " + }, + { + "id": 47, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 46, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 50, + "kind": "text", + "text": " =>" + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 61, + "kind": "list", + "list": [ + { + "id": 51, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 59, + "kind": "list", + "list": [ + { + "id": 54, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 53, + "kind": "list", + "list": [ + { + "id": 52, + "kind": "text", + "text": "Mult'Result" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 55, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 56, + "kind": "text", + "text": "= " + }, + { + "id": 58, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 57, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 67, + "kind": "text", + "text": ")" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/contract_cases/long/input.ada b/testsuite/tests/unparsing/contract_cases/long/input.ada new file mode 100644 index 000000000..af9f0dd21 --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long/input.ada @@ -0,0 +1,2 @@ +(X * Y < 10_000 => Mult'Result = X * Y, + X * Y >= 10_000 => Mult'Result = 10_000) diff --git a/testsuite/tests/unparsing/contract_cases/long/test.out b/testsuite/tests/unparsing/contract_cases/long/test.out new file mode 100644 index 000000000..715e70443 --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long/test.out @@ -0,0 +1,2 @@ +(X * Y < 10_000 => Mult'Result = X * Y, + X * Y >= 10_000 => Mult'Result = 10_000) diff --git a/testsuite/tests/unparsing/contract_cases/long/test.yaml b/testsuite/tests/unparsing/contract_cases/long/test.yaml new file mode 100644 index 000000000..db9941701 --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long/test.yaml @@ -0,0 +1,8 @@ +description: | + This test checks the formatting of contract cases expression. + It is expected the declaration breaks at the end of the first + contract case association and the new line is aligned relative + to the first association. + +driver: unparser +rule: contract_cases_expr diff --git a/testsuite/tests/unparsing/contract_cases/long_f_consequence/doc-baseline.json b/testsuite/tests/unparsing/contract_cases/long_f_consequence/doc-baseline.json new file mode 100644 index 000000000..3a71bba2e --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long_f_consequence/doc-baseline.json @@ -0,0 +1,538 @@ +{ + "id": 70, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 69, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "(" + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 65, + "kind": "list", + "list": [ + { + "id": 34, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "X" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": "* " + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 4, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 9, + "kind": "text", + "text": "< " + }, + { + "id": 11, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 10, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "text", + "text": " =>" + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 16, + "kind": "text", + "text": "Muuuuuuuuuuuuuuuuuuult'Resuuuuuuuuuuuuuuuuuuuuuuuult" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 20, + "kind": "text", + "text": "= " + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 27, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 26, + "kind": "list", + "list": [ + { + "id": 21, + "kind": "text", + "text": "X" + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 23, + "kind": "text", + "text": "* " + }, + { + "id": 25, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 24, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 35, + "kind": "text", + "text": "," + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 64, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 49, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 48, + "kind": "list", + "list": [ + { + "id": 43, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 42, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "text", + "text": "X" + }, + { + "id": 38, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 39, + "kind": "text", + "text": "* " + }, + { + "id": 41, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 40, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 44, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 45, + "kind": "text", + "text": ">= " + }, + { + "id": 47, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 46, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 50, + "kind": "text", + "text": " =>" + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 61, + "kind": "list", + "list": [ + { + "id": 51, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 59, + "kind": "list", + "list": [ + { + "id": 54, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 53, + "kind": "list", + "list": [ + { + "id": 52, + "kind": "text", + "text": "Mult'Result" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 55, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 56, + "kind": "text", + "text": "= " + }, + { + "id": 58, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 57, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 67, + "kind": "text", + "text": ")" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/contract_cases/long_f_consequence/input.ada b/testsuite/tests/unparsing/contract_cases/long_f_consequence/input.ada new file mode 100644 index 000000000..0ff60023c --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long_f_consequence/input.ada @@ -0,0 +1,2 @@ +(X * Y < 10_000 => Muuuuuuuuuuuuuuuuuuult'Resuuuuuuuuuuuuuuuuuuuuuuuult = X * Y, + X * Y >= 10_000 => Mult'Result = 10_000) diff --git a/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.out b/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.out new file mode 100644 index 000000000..4b004b870 --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.out @@ -0,0 +1,3 @@ +(X * Y < 10_000 => + Muuuuuuuuuuuuuuuuuuult'Resuuuuuuuuuuuuuuuuuuuuuuuult = X * Y, + X * Y >= 10_000 => Mult'Result = 10_000) diff --git a/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.yaml b/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.yaml new file mode 100644 index 000000000..702a989ff --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.yaml @@ -0,0 +1,7 @@ +description: | + This test checks the formatting of contract cases expression. + Test that when `f_consequences` is long, a line break and + continuation-line indentation is added after `=>`. + +driver: unparser +rule: contract_cases_expr diff --git a/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.yaml~ b/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.yaml~ new file mode 100644 index 000000000..5207437ab --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/long_f_consequence/test.yaml~ @@ -0,0 +1,9 @@ +description: | + This test checks the formatting of contract cases expression. + It is expected the declaration breaks after `=>` and at the + end of the first contract case association; first the new + be indented and the next one be aligned relative to the first + association. + +driver: unparser +rule: contract_cases_expr diff --git a/testsuite/tests/unparsing/contract_cases/short/doc-baseline.json b/testsuite/tests/unparsing/contract_cases/short/doc-baseline.json new file mode 100644 index 000000000..c613361de --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/short/doc-baseline.json @@ -0,0 +1,538 @@ +{ + "id": 70, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 69, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "(" + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 65, + "kind": "list", + "list": [ + { + "id": 34, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "X" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": "+ " + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 4, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 9, + "kind": "text", + "text": "< " + }, + { + "id": 11, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 10, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 14, + "kind": "text", + "text": " =>" + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 16, + "kind": "text", + "text": "Add'Result" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 20, + "kind": "text", + "text": "= " + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 27, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 26, + "kind": "list", + "list": [ + { + "id": 21, + "kind": "text", + "text": "X" + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 23, + "kind": "text", + "text": "+ " + }, + { + "id": 25, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 24, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 35, + "kind": "text", + "text": "," + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 64, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 49, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 48, + "kind": "list", + "list": [ + { + "id": 43, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 42, + "kind": "list", + "list": [ + { + "id": 37, + "kind": "text", + "text": "X" + }, + { + "id": 38, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 39, + "kind": "text", + "text": "+ " + }, + { + "id": 41, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 40, + "kind": "text", + "text": "Y" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 44, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 45, + "kind": "text", + "text": ">= " + }, + { + "id": 47, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 46, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 50, + "kind": "text", + "text": " =>" + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 61, + "kind": "list", + "list": [ + { + "id": 51, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 59, + "kind": "list", + "list": [ + { + "id": 54, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 53, + "kind": "list", + "list": [ + { + "id": 52, + "kind": "text", + "text": "Add'Result" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 55, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 56, + "kind": "text", + "text": "= " + }, + { + "id": 58, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 57, + "kind": "text", + "text": "10_000" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + }, + { + "id": 67, + "kind": "text", + "text": ")" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/contract_cases/short/input.ada b/testsuite/tests/unparsing/contract_cases/short/input.ada new file mode 100644 index 000000000..253e951ce --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/short/input.ada @@ -0,0 +1 @@ + (X + Y < 10_000 => Add'Result = X + Y, X + Y >= 10_000 => Add'Result = 10_000) diff --git a/testsuite/tests/unparsing/contract_cases/short/test.out b/testsuite/tests/unparsing/contract_cases/short/test.out new file mode 100644 index 000000000..1e68046d3 --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/short/test.out @@ -0,0 +1 @@ +(X + Y < 10_000 => Add'Result = X + Y, X + Y >= 10_000 => Add'Result = 10_000) diff --git a/testsuite/tests/unparsing/contract_cases/short/test.yaml b/testsuite/tests/unparsing/contract_cases/short/test.yaml new file mode 100644 index 000000000..e60e402ae --- /dev/null +++ b/testsuite/tests/unparsing/contract_cases/short/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of contract cases expression. + It is expected the declaration stays on a single line. + +driver: unparser +rule: contract_cases_expr