Skip to content

Commit

Permalink
Add a parser test for invalid usage of client decl as stmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MaryamZi committed Nov 2, 2022
1 parent 266c6e9 commit 687a5aa
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,9 @@ public void testInvalidQualifiers() {
public void testInvalidDocumentation() {
testFile("client-decl/client_decl_source_14.bal", "client-decl/client_decl_assert_14.json");
}

@Test
public void testInvalidUsageOfClientDeclAsStmt() {
testFile("client-decl/client_decl_source_15.bal", "client-decl/client_decl_assert_15.json");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
{
"kind": "MODULE_PART",
"hasDiagnostics": true,
"children": [
{
"kind": "LIST",
"children": []
},
{
"kind": "LIST",
"hasDiagnostics": true,
"children": [
{
"kind": "FUNCTION_DEFINITION",
"hasDiagnostics": true,
"children": [
{
"kind": "LIST",
"children": []
},
{
"kind": "FUNCTION_KEYWORD",
"trailingMinutiae": [
{
"kind": "WHITESPACE_MINUTIAE",
"value": " "
}
]
},
{
"kind": "IDENTIFIER_TOKEN",
"value": "fn"
},
{
"kind": "LIST",
"children": []
},
{
"kind": "FUNCTION_SIGNATURE",
"children": [
{
"kind": "OPEN_PAREN_TOKEN"
},
{
"kind": "LIST",
"children": []
},
{
"kind": "CLOSE_PAREN_TOKEN",
"trailingMinutiae": [
{
"kind": "WHITESPACE_MINUTIAE",
"value": " "
}
]
}
]
},
{
"kind": "FUNCTION_BODY_BLOCK",
"hasDiagnostics": true,
"children": [
{
"kind": "OPEN_BRACE_TOKEN",
"trailingMinutiae": [
{
"kind": "END_OF_LINE_MINUTIAE",
"value": "\n"
}
]
},
{
"kind": "LIST",
"hasDiagnostics": true,
"children": [
{
"kind": "LOCAL_VAR_DECL",
"hasDiagnostics": true,
"children": [
{
"kind": "LIST",
"children": []
},
{
"kind": "TYPED_BINDING_PATTERN",
"hasDiagnostics": true,
"children": [
{
"kind": "SINGLETON_TYPE_DESC",
"hasDiagnostics": true,
"children": [
{
"kind": "STRING_LITERAL",
"hasDiagnostics": true,
"children": [
{
"kind": "STRING_LITERAL_TOKEN",
"hasDiagnostics": true,
"value": "http://www.example.com/apis/one.yaml",
"leadingMinutiae": [
{
"kind": "WHITESPACE_MINUTIAE",
"value": " "
},
{
"kind": "INVALID_NODE_MINUTIAE",
"invalidNode": {
"kind": "INVALID_TOKEN_MINUTIAE_NODE",
"hasDiagnostics": true,
"children": [
{
"kind": "CLIENT_KEYWORD",
"hasDiagnostics": true,
"diagnostics": [
"ERROR_QUALIFIER_NOT_ALLOWED"
]
}
]
}
},
{
"kind": "WHITESPACE_MINUTIAE",
"value": " "
}
],
"trailingMinutiae": [
{
"kind": "WHITESPACE_MINUTIAE",
"value": " "
}
]
}
]
}
]
},
{
"kind": "CAPTURE_BINDING_PATTERN",
"hasDiagnostics": true,
"children": [
{
"kind": "IDENTIFIER_TOKEN",
"hasDiagnostics": true,
"value": "foo",
"leadingMinutiae": [
{
"kind": "INVALID_NODE_MINUTIAE",
"invalidNode": {
"kind": "INVALID_TOKEN_MINUTIAE_NODE",
"hasDiagnostics": true,
"children": [
{
"kind": "AS_KEYWORD",
"hasDiagnostics": true,
"diagnostics": [
"ERROR_INVALID_TOKEN"
]
}
]
}
},
{
"kind": "WHITESPACE_MINUTIAE",
"value": " "
}
]
}
]
}
]
},
{
"kind": "SEMICOLON_TOKEN",
"trailingMinutiae": [
{
"kind": "END_OF_LINE_MINUTIAE",
"value": "\n"
}
]
}
]
}
]
},
{
"kind": "CLOSE_BRACE_TOKEN",
"trailingMinutiae": [
{
"kind": "END_OF_LINE_MINUTIAE",
"value": "\n"
}
]
}
]
}
]
}
]
},
{
"kind": "EOF_TOKEN"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function fn() {
client "http://www.example.com/apis/one.yaml" as foo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ public List<String> skipList() {
"member_access_expr_source_11.bal", "float_literal_source_08.bal", "object_type_def_source_47.bal",
"client_resource_access_action_source_05.bal", "client_resource_access_action_source_06.bal",
"client_decl_source_08.bal", "client_decl_source_09.bal", "client_decl_source_13.bal",
"client_decl_source_14.bal", "invalid_usage_of_client_keyword_as_identifier_source.bal",
"client_decl_source_14.bal", "client_decl_source_15.bal",
"invalid_usage_of_client_keyword_as_identifier_source.bal",
"resiliency_source_05.bal", "regexp_constructor_source_26.bal", "regexp_constructor_source_28.bal");
}

Expand Down

0 comments on commit 687a5aa

Please sign in to comment.