From 00f268996116938c8fcf8232894050b4529af25a Mon Sep 17 00:00:00 2001 From: Joao Azevedo Date: Wed, 31 Jul 2024 15:59:05 +0000 Subject: [PATCH] Add QuantifiedExpr config --- extensions/default_unparsing_config.json | 33 +++++++++++++++++++ .../tests/unparsing/quantified_expr/input.ada | 7 ++++ .../tests/unparsing/quantified_expr/test.out | 7 ++++ .../tests/unparsing/quantified_expr/test.yaml | 6 ++++ 4 files changed, 53 insertions(+) create mode 100644 testsuite/tests/unparsing/quantified_expr/input.ada create mode 100644 testsuite/tests/unparsing/quantified_expr/test.out create mode 100644 testsuite/tests/unparsing/quantified_expr/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 8228d38d7..1b6a37506 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -4835,6 +4835,39 @@ ] } }, + "QuantifiedExpr": { + "node": { + "kind": "group", + "document": { + "kind": "innerRoot", + "contents": [ + { + "kind": "text", + "text": "for" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_quantifier" + }, + { + "kind": "recurse_field", + "field": "f_loop_spec" + }, + "line", + { + "kind": "text", + "text": "=>" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_expr" + } + ] + } + } + }, "QualExpr": { "node": { "kind": "group", diff --git a/testsuite/tests/unparsing/quantified_expr/input.ada b/testsuite/tests/unparsing/quantified_expr/input.ada new file mode 100644 index 000000000..317a1bd20 --- /dev/null +++ b/testsuite/tests/unparsing/quantified_expr/input.ada @@ -0,0 +1,7 @@ +if (for some Change of Value.contentChanges => Change > 80) + or else (for all Change of Value.contentChanges + => Change.text.Character_Length) +then + -- Don't dump very long changes to avoid stack overflow + Self.Output.Put ("", Ok); +end if; diff --git a/testsuite/tests/unparsing/quantified_expr/test.out b/testsuite/tests/unparsing/quantified_expr/test.out new file mode 100644 index 000000000..317a1bd20 --- /dev/null +++ b/testsuite/tests/unparsing/quantified_expr/test.out @@ -0,0 +1,7 @@ +if (for some Change of Value.contentChanges => Change > 80) + or else (for all Change of Value.contentChanges + => Change.text.Character_Length) +then + -- Don't dump very long changes to avoid stack overflow + Self.Output.Put ("", Ok); +end if; diff --git a/testsuite/tests/unparsing/quantified_expr/test.yaml b/testsuite/tests/unparsing/quantified_expr/test.yaml new file mode 100644 index 000000000..a58acfd42 --- /dev/null +++ b/testsuite/tests/unparsing/quantified_expr/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: stmt +description: | + This test checks that `QuantifiedExpr` nodes: + - do not line break is they fit in the line + - line breaks before the `=>` token if they don't fit in the line