Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 2812243006: Reland: Fix more parser bugs (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.generated.parser_test; 5 library analyzer.test.generated.parser_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 4116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 4127
4128 void test_voidVariable_parseCompilationUnitMember_noInitializer() { 4128 void test_voidVariable_parseCompilationUnitMember_noInitializer() {
4129 createParser('void a;'); 4129 createParser('void a;');
4130 CompilationUnitMember member = parseFullCompilationUnitMember(); 4130 CompilationUnitMember member = parseFullCompilationUnitMember();
4131 expectNotNullIfNoErrors(member); 4131 expectNotNullIfNoErrors(member);
4132 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]); 4132 listener.assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]);
4133 } 4133 }
4134 4134
4135 void test_voidVariable_statement_initializer() { 4135 void test_voidVariable_statement_initializer() {
4136 parseStatement("void x = 0;"); 4136 parseStatement("void x = 0;");
4137 assertErrorsWithCodes([ 4137 assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]);
4138 ParserErrorCode.VOID_VARIABLE,
4139 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
4140 ]);
4141 } 4138 }
4142 4139
4143 void test_voidVariable_statement_noInitializer() { 4140 void test_voidVariable_statement_noInitializer() {
4144 parseStatement("void x;"); 4141 parseStatement("void x;");
4145 assertErrorsWithCodes([ 4142 assertErrorsWithCodes([ParserErrorCode.VOID_VARIABLE]);
4146 ParserErrorCode.VOID_VARIABLE,
4147 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
4148 ]);
4149 } 4143 }
4150 4144
4151 void test_withBeforeExtends() { 4145 void test_withBeforeExtends() {
4152 parseCompilationUnit( 4146 parseCompilationUnit(
4153 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]); 4147 "class A with B extends C {}", [ParserErrorCode.WITH_BEFORE_EXTENDS]);
4154 } 4148 }
4155 4149
4156 void test_withWithoutExtends() { 4150 void test_withWithoutExtends() {
4157 createParser('class A with B, C {}'); 4151 createParser('class A with B, C {}');
4158 ClassDeclaration declaration = parseFullCompilationUnitMember(); 4152 ClassDeclaration declaration = parseFullCompilationUnitMember();
(...skipping 7183 matching lines...) Expand 10 before | Expand all | Expand 10 after
11342 } 11336 }
11343 11337
11344 void test_parseNonLabeledStatement_variableDeclaration_gftType() { 11338 void test_parseNonLabeledStatement_variableDeclaration_gftType() {
11345 createParser('int Function(int) v;'); 11339 createParser('int Function(int) v;');
11346 Statement statement = parser.parseNonLabeledStatement(); 11340 Statement statement = parser.parseNonLabeledStatement();
11347 expectNotNullIfNoErrors(statement); 11341 expectNotNullIfNoErrors(statement);
11348 listener.assertNoErrors(); 11342 listener.assertNoErrors();
11349 } 11343 }
11350 11344
11351 void 11345 void
11346 test_parseNonLabeledStatement_variableDeclaration_gftType_functionReturnTy pe() {
11347 createParser(
11348 'Function Function(int x1, {Function x}) Function<B extends core.int>(in t x) l771;');
11349 Statement statement = parser.parseNonLabeledStatement();
11350 expectNotNullIfNoErrors(statement);
11351 listener.assertNoErrors();
11352 }
11353
11354 void
11352 test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType() { 11355 test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType() {
11353 createParser('Function(int) Function(int) v;'); 11356 createParser('Function(int) Function(int) v;');
11354 Statement statement = parser.parseNonLabeledStatement(); 11357 Statement statement = parser.parseNonLabeledStatement();
11355 expectNotNullIfNoErrors(statement); 11358 expectNotNullIfNoErrors(statement);
11356 listener.assertNoErrors(); 11359 listener.assertNoErrors();
11357 } 11360 }
11358 11361
11359 void 11362 void
11363 test_parseNonLabeledStatement_variableDeclaration_gftType_gftReturnType2() {
11364 createParser('int Function(int) Function(int) v;');
11365 Statement statement = parser.parseNonLabeledStatement();
11366 expectNotNullIfNoErrors(statement);
11367 listener.assertNoErrors();
11368 }
11369
11370 void
11360 test_parseNonLabeledStatement_variableDeclaration_gftType_noReturnType() { 11371 test_parseNonLabeledStatement_variableDeclaration_gftType_noReturnType() {
11361 createParser('Function(int) v;'); 11372 createParser('Function(int) v;');
11362 Statement statement = parser.parseNonLabeledStatement(); 11373 Statement statement = parser.parseNonLabeledStatement();
11363 expectNotNullIfNoErrors(statement); 11374 expectNotNullIfNoErrors(statement);
11364 listener.assertNoErrors(); 11375 listener.assertNoErrors();
11365 } 11376 }
11366 11377
11367 void test_parseNonLabeledStatement_variableDeclaration_gftType_returnType() { 11378 void test_parseNonLabeledStatement_variableDeclaration_gftType_returnType() {
11368 createParser('int Function<T>() v;'); 11379 createParser('int Function<T>() v;');
11369 Statement statement = parser.parseNonLabeledStatement(); 11380 Statement statement = parser.parseNonLabeledStatement();
11370 expectNotNullIfNoErrors(statement); 11381 expectNotNullIfNoErrors(statement);
11371 listener.assertNoErrors(); 11382 listener.assertNoErrors();
11372 } 11383 }
11373 11384
11385 void
11386 test_parseNonLabeledStatement_variableDeclaration_gftType_voidReturnType() {
11387 createParser('void Function() v;');
11388 Statement statement = parser.parseNonLabeledStatement();
11389 expectNotNullIfNoErrors(statement);
11390 listener.assertNoErrors();
11391 }
11392
11374 void test_parseOptionalReturnType() { 11393 void test_parseOptionalReturnType() {
11375 // TODO(brianwilkerson) Implement tests for this method. 11394 // TODO(brianwilkerson) Implement tests for this method.
11376 } 11395 }
11377 11396
11378 void test_Parser() { 11397 void test_Parser() {
11379 expect(new Parser(null, null), isNotNull); 11398 expect(new Parser(null, null), isNotNull);
11380 } 11399 }
11381 11400
11382 void test_parseReturnStatement_noValue() { 11401 void test_parseReturnStatement_noValue() {
11383 createParser('return;'); 11402 createParser('return;');
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after
14902 expectCommentText(typeVariable.documentationComment, '/// Doc'); 14921 expectCommentText(typeVariable.documentationComment, '/// Doc');
14903 } 14922 }
14904 14923
14905 /** 14924 /**
14906 * Assert that the given [name] is in declaration context. 14925 * Assert that the given [name] is in declaration context.
14907 */ 14926 */
14908 void _assertIsDeclarationName(SimpleIdentifier name) { 14927 void _assertIsDeclarationName(SimpleIdentifier name) {
14909 expect(name.inDeclarationContext(), isTrue); 14928 expect(name.inDeclarationContext(), isTrue);
14910 } 14929 }
14911 } 14930 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698