File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
pkg/analyzer/test/src/dart/parser Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff 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'''
88111class 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'''
230274class A {
You can’t perform that action at this time.
0 commit comments