Skip to content

Commit 81c13a9

Browse files
scheglovCommit Queue
authored andcommitted
DeCo. Tests for parsing factoryHead nad newHead named explicitly 'new'.
Change-Id: I59063fb6e76a14378021fcd0fb1d416596b56a42 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464780 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 08cda24 commit 81c13a9

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

pkg/analyzer/test/src/dart/parser/class_test.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,29 @@ ConstructorDeclaration
8383
''');
8484
}
8585

86+
test_constructor_factoryHead_new() {
87+
var parseResult = parseStringWithErrors(r'''
88+
class A {
89+
factory new() {}
90+
}
91+
''');
92+
parseResult.assertErrors([error(diag.factoryConstructorNewName, 20, 3)]);
93+
94+
var node = parseResult.findNode.singleConstructorDeclaration;
95+
assertParsedNodeText(node, r'''
96+
ConstructorDeclaration
97+
factoryKeyword: factory
98+
name: new
99+
parameters: FormalParameterList
100+
leftParenthesis: (
101+
rightParenthesis: )
102+
body: BlockFunctionBody
103+
block: Block
104+
leftBracket: {
105+
rightBracket: }
106+
''');
107+
}
108+
86109
test_constructor_factoryHead_unnamed() {
87110
var parseResult = parseStringWithErrors(r'''
88111
class A {
@@ -225,6 +248,27 @@ ConstructorDeclaration
225248
''');
226249
}
227250

251+
test_constructor_newHead_new() {
252+
var parseResult = parseStringWithErrors(r'''
253+
class A {
254+
new new();
255+
}
256+
''');
257+
parseResult.assertErrors([error(diag.newConstructorNewName, 16, 3)]);
258+
259+
var node = parseResult.findNode.singleConstructorDeclaration;
260+
assertParsedNodeText(node, r'''
261+
ConstructorDeclaration
262+
newKeyword: new
263+
name: new
264+
parameters: FormalParameterList
265+
leftParenthesis: (
266+
rightParenthesis: )
267+
body: EmptyFunctionBody
268+
semicolon: ;
269+
''');
270+
}
271+
228272
test_constructor_newHead_unnamed() {
229273
var parseResult = parseStringWithErrors(r'''
230274
class A {

0 commit comments

Comments
 (0)