Skip to content

Commit

Permalink
Add RaiseStmt config
Browse files Browse the repository at this point in the history
  • Loading branch information
CKMonika committed Apr 18, 2024
1 parent 2d6b738 commit fe1ef30
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 0 deletions.
33 changes: 33 additions & 0 deletions extensions/default_unparsing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with "a looooooooooooong too bad message";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with
"a looooooooooooong too bad message";
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/doc-baseline.json
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise;
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise;
6 changes: 6 additions & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/test.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise NotImplementedError with "too bad";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise NotImplementedError with "too bad";
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fe1ef30

Please sign in to comment.