From fe1ef30fe64a286afeaec47dcb70493908962bf9 Mon Sep 17 00:00:00 2001 From: Monika Kurovszky Date: Thu, 18 Apr 2024 17:41:47 +0200 Subject: [PATCH] Add RaiseStmt config --- extensions/default_unparsing_config.json | 33 +++++++++++ .../doc-baseline.json | 58 +++++++++++++++++++ .../long_with_expr_and_message/input.ada | 1 + .../long_with_expr_and_message/test.out | 2 + .../long_with_expr_and_message/test.yaml | 8 +++ .../raise_stmt/simple/doc-baseline.json | 21 +++++++ .../unparsing/raise_stmt/simple/input.ada | 1 + .../unparsing/raise_stmt/simple/test.out | 1 + .../unparsing/raise_stmt/simple/test.yaml | 6 ++ .../with_expr_and_message/doc-baseline.json | 58 +++++++++++++++++++ .../with_expr_and_message/input.ada | 1 + .../raise_stmt/with_expr_and_message/test.out | 1 + .../with_expr_and_message/test.yaml | 6 ++ 13 files changed, 197 insertions(+) create mode 100644 testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json create mode 100644 testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/input.ada create mode 100644 testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out create mode 100644 testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml create mode 100644 testsuite/tests/unparsing/raise_stmt/simple/doc-baseline.json create mode 100644 testsuite/tests/unparsing/raise_stmt/simple/input.ada create mode 100644 testsuite/tests/unparsing/raise_stmt/simple/test.out create mode 100644 testsuite/tests/unparsing/raise_stmt/simple/test.yaml create mode 100644 testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json create mode 100644 testsuite/tests/unparsing/raise_stmt/with_expr_and_message/input.ada create mode 100644 testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.out create mode 100644 testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 73a4208d3..e7de6e213 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -4528,6 +4528,39 @@ ] } }, + "RaiseStmt": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "raise" + }, + { + "kind": "recurse_field", + "field": "f_exception_name" + }, + { + "kind": "recurse_field", + "field": "f_error_message" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_error_message": { + "kind": "align", + "width": 2, + "contents": [ + "line", + "recurse" + ] + } + } + }, "RangeSpec": { "node": { "kind": "align", diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json new file mode 100644 index 000000000..f888afdea --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json @@ -0,0 +1,58 @@ +{ + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "\"a looooooooooooong too bad message\"" + } + ] + } + } + }, + { + "id": 5, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/input.ada b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/input.ada new file mode 100644 index 000000000..492c80130 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/input.ada @@ -0,0 +1 @@ +raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with "a looooooooooooong too bad message"; diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out new file mode 100644 index 000000000..bd8c4fff6 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out @@ -0,0 +1,2 @@ +raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with + "a looooooooooooong too bad message"; diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml new file mode 100644 index 000000000..db7960af9 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml @@ -0,0 +1,8 @@ +description: | + This test checks the formatting of a raise statement + with the line length exceeded. + It is expected the statement breaks after `with` keyword + and the new line is indented. + +driver: unparser +rule: raise_stmt diff --git a/testsuite/tests/unparsing/raise_stmt/simple/doc-baseline.json b/testsuite/tests/unparsing/raise_stmt/simple/doc-baseline.json new file mode 100644 index 000000000..823bc2f69 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/doc-baseline.json @@ -0,0 +1,21 @@ +{ + "id": 2, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 1, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "raise;" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_stmt/simple/input.ada b/testsuite/tests/unparsing/raise_stmt/simple/input.ada new file mode 100644 index 000000000..4a0db4915 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/input.ada @@ -0,0 +1 @@ +raise; diff --git a/testsuite/tests/unparsing/raise_stmt/simple/test.out b/testsuite/tests/unparsing/raise_stmt/simple/test.out new file mode 100644 index 000000000..4a0db4915 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/test.out @@ -0,0 +1 @@ +raise; diff --git a/testsuite/tests/unparsing/raise_stmt/simple/test.yaml b/testsuite/tests/unparsing/raise_stmt/simple/test.yaml new file mode 100644 index 000000000..2831acb3e --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a raise statement. + It is expected the statement stays on a single line. + +driver: unparser +rule: raise_stmt diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json new file mode 100644 index 000000000..ec32b1540 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json @@ -0,0 +1,58 @@ +{ + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "raise NotImplementedError with" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "\"too bad\"" + } + ] + } + } + }, + { + "id": 5, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/input.ada b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/input.ada new file mode 100644 index 000000000..113445afc --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/input.ada @@ -0,0 +1 @@ +raise NotImplementedError with "too bad"; diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.out b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.out new file mode 100644 index 000000000..113445afc --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.out @@ -0,0 +1 @@ +raise NotImplementedError with "too bad"; diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.yaml b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.yaml new file mode 100644 index 000000000..2831acb3e --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a raise statement. + It is expected the statement stays on a single line. + +driver: unparser +rule: raise_stmt