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

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

Issue 2342383002: Initial support for the NNBD proposal (Closed)
Patch Set: Created 4 years, 3 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
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/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, 339 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
340 BinaryExpression, expression.condition); 340 BinaryExpression, expression.condition);
341 } 341 }
342 342
343 void test_conditionalExpression_precedence_logicalOrExpression() { 343 void test_conditionalExpression_precedence_logicalOrExpression() {
344 ConditionalExpression expression = parseExpression("a | b ? y : z"); 344 ConditionalExpression expression = parseExpression("a | b ? y : z");
345 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, 345 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
346 BinaryExpression, expression.condition); 346 BinaryExpression, expression.condition);
347 } 347 }
348 348
349 void test_conditionalExpression_precedence_nullableType() {
350 enableNnbd = true;
351 Expression expression = parseExpression('x is String ? (x + y) : z');
352 expect(expression, isNotNull);
353 expect(expression, new isInstanceOf<ConditionalExpression>());
354 ConditionalExpression conditional = expression;
355 Expression condition = conditional.condition;
356 expect(condition, new isInstanceOf<IsExpression>());
357 Expression thenExpression = conditional.thenExpression;
358 expect(thenExpression, new isInstanceOf<ParenthesizedExpression>());
359 Expression elseExpression = conditional.elseExpression;
360 expect(elseExpression, new isInstanceOf<SimpleIdentifier>());
361 }
362
349 void test_constructor_initializer_withParenthesizedExpression() { 363 void test_constructor_initializer_withParenthesizedExpression() {
350 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 364 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
351 class C { 365 class C {
352 C() : 366 C() :
353 this.a = (b == null ? c : d) { 367 this.a = (b == null ? c : d) {
354 } 368 }
355 }'''); 369 }''');
356 NodeList<CompilationUnitMember> declarations = unit.declarations; 370 NodeList<CompilationUnitMember> declarations = unit.declarations;
357 expect(declarations, hasLength(1)); 371 expect(declarations, hasLength(1));
358 } 372 }
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 */ 2425 */
2412 bool enableGenericMethodComments = false; 2426 bool enableGenericMethodComments = false;
2413 2427
2414 /** 2428 /**
2415 * A flag indicating whether lazy assignment operators should be enabled for 2429 * A flag indicating whether lazy assignment operators should be enabled for
2416 * the test. 2430 * the test.
2417 */ 2431 */
2418 bool enableLazyAssignmentOperators = false; 2432 bool enableLazyAssignmentOperators = false;
2419 2433
2420 /** 2434 /**
2435 * A flag indicating whether the parser is to parse the non-nullable modifier
2436 * in type names.
2437 */
2438 bool enableNnbd = false;
2439
2440 /**
2421 * Return a CommentAndMetadata object with the given values that can be used f or testing. 2441 * Return a CommentAndMetadata object with the given values that can be used f or testing.
2422 * 2442 *
2423 * @param comment the comment to be wrapped in the object 2443 * @param comment the comment to be wrapped in the object
2424 * @param annotations the annotations to be wrapped in the object 2444 * @param annotations the annotations to be wrapped in the object
2425 * @return a CommentAndMetadata object that can be used for testing 2445 * @return a CommentAndMetadata object that can be used for testing
2426 */ 2446 */
2427 CommentAndMetadata commentAndMetadata(Comment comment, 2447 CommentAndMetadata commentAndMetadata(Comment comment,
2428 [List<Annotation> annotations]) { 2448 [List<Annotation> annotations]) {
2429 return new CommentAndMetadata(comment, annotations); 2449 return new CommentAndMetadata(comment, annotations);
2430 } 2450 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2486 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2467 // 2487 //
2468 // Parse the source. 2488 // Parse the source.
2469 // 2489 //
2470 Parser parser = createParser(listener); 2490 Parser parser = createParser(listener);
2471 parser.enableAssertInitializer = enableAssertInitializer; 2491 parser.enableAssertInitializer = enableAssertInitializer;
2472 parser.parseAsync = parseAsync; 2492 parser.parseAsync = parseAsync;
2473 parser.parseGenericMethods = enableGenericMethods; 2493 parser.parseGenericMethods = enableGenericMethods;
2474 parser.parseGenericMethodComments = enableGenericMethodComments; 2494 parser.parseGenericMethodComments = enableGenericMethodComments;
2475 parser.parseFunctionBodies = parseFunctionBodies; 2495 parser.parseFunctionBodies = parseFunctionBodies;
2496 parser.enableNnbd = enableNnbd;
2476 Object result = 2497 Object result =
2477 invokeParserMethodImpl(parser, methodName, objects, tokenStream); 2498 invokeParserMethodImpl(parser, methodName, objects, tokenStream);
2478 // 2499 //
2479 // Partially test the results. 2500 // Partially test the results.
2480 // 2501 //
2481 if (!listener.hasErrors) { 2502 if (!listener.hasErrors) {
2482 expect(result, isNotNull); 2503 expect(result, isNotNull);
2483 } 2504 }
2484 return result; 2505 return result;
2485 } 2506 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 Scanner scanner = 2617 Scanner scanner =
2597 new Scanner(null, new CharSequenceReader(source), listener); 2618 new Scanner(null, new CharSequenceReader(source), listener);
2598 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2619 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2599 Token token = scanner.tokenize(); 2620 Token token = scanner.tokenize();
2600 Parser parser = createParser(listener); 2621 Parser parser = createParser(listener);
2601 parser.enableAssertInitializer = enableAssertInitializer; 2622 parser.enableAssertInitializer = enableAssertInitializer;
2602 parser.parseAsync = parseAsync; 2623 parser.parseAsync = parseAsync;
2603 parser.parseFunctionBodies = parseFunctionBodies; 2624 parser.parseFunctionBodies = parseFunctionBodies;
2604 parser.parseGenericMethods = enableGenericMethods; 2625 parser.parseGenericMethods = enableGenericMethods;
2605 parser.parseGenericMethodComments = enableGenericMethodComments; 2626 parser.parseGenericMethodComments = enableGenericMethodComments;
2627 parser.enableNnbd = enableNnbd;
2606 CompilationUnit unit = parser.parseCompilationUnit(token); 2628 CompilationUnit unit = parser.parseCompilationUnit(token);
2607 expect(unit, isNotNull); 2629 expect(unit, isNotNull);
2608 listener.assertErrorsWithCodes(errorCodes); 2630 listener.assertErrorsWithCodes(errorCodes);
2609 return unit; 2631 return unit;
2610 } 2632 }
2611 2633
2612 /** 2634 /**
2613 * Parse the given source as an expression. 2635 * Parse the given source as an expression.
2614 * 2636 *
2615 * @param source the source to be parsed 2637 * @param source the source to be parsed
2616 * @param errorCodes the error codes of the errors that are expected to be fou nd 2638 * @param errorCodes the error codes of the errors that are expected to be fou nd
2617 * @return the expression that was parsed 2639 * @return the expression that was parsed
2618 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do 2640 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
2619 * not match those that are expected, or if the result would have be en `null` 2641 * not match those that are expected, or if the result would have be en `null`
2620 */ 2642 */
2621 Expression parseExpression(String source, 2643 Expression parseExpression(String source,
2622 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { 2644 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) {
2623 GatheringErrorListener listener = new GatheringErrorListener(); 2645 GatheringErrorListener listener = new GatheringErrorListener();
2624 Scanner scanner = 2646 Scanner scanner =
2625 new Scanner(null, new CharSequenceReader(source), listener); 2647 new Scanner(null, new CharSequenceReader(source), listener);
2626 scanner.scanGenericMethodComments = enableGenericMethodComments; 2648 scanner.scanGenericMethodComments = enableGenericMethodComments;
2627 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2649 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2628 Token token = scanner.tokenize(); 2650 Token token = scanner.tokenize();
2629 Parser parser = createParser(listener); 2651 Parser parser = createParser(listener);
2630 parser.parseGenericMethods = enableGenericMethods; 2652 parser.parseGenericMethods = enableGenericMethods;
2631 parser.parseGenericMethodComments = enableGenericMethodComments; 2653 parser.parseGenericMethodComments = enableGenericMethodComments;
2654 parser.enableNnbd = enableNnbd;
2632 Expression expression = parser.parseExpression(token); 2655 Expression expression = parser.parseExpression(token);
2633 expect(expression, isNotNull); 2656 expect(expression, isNotNull);
2634 listener.assertErrorsWithCodes(errorCodes); 2657 listener.assertErrorsWithCodes(errorCodes);
2635 return expression; 2658 return expression;
2636 } 2659 }
2637 2660
2638 @override 2661 @override
2639 void setUp() { 2662 void setUp() {
2640 super.setUp(); 2663 super.setUp();
2641 parseFunctionBodies = true; 2664 parseFunctionBodies = true;
(...skipping 6447 matching lines...) Expand 10 before | Expand all | Expand 10 after
9089 9112
9090 void test_parseNormalFormalParameter_function_noType() { 9113 void test_parseNormalFormalParameter_function_noType() {
9091 FunctionTypedFormalParameter parameter = 9114 FunctionTypedFormalParameter parameter =
9092 parse4("parseNormalFormalParameter", "a())"); 9115 parse4("parseNormalFormalParameter", "a())");
9093 expect(parameter.returnType, isNull); 9116 expect(parameter.returnType, isNull);
9094 expect(parameter.identifier, isNotNull); 9117 expect(parameter.identifier, isNotNull);
9095 expect(parameter.typeParameters, isNull); 9118 expect(parameter.typeParameters, isNull);
9096 expect(parameter.parameters, isNotNull); 9119 expect(parameter.parameters, isNotNull);
9097 } 9120 }
9098 9121
9122 void test_parseNormalFormalParameter_function_noType_nullable() {
9123 enableNnbd = true;
9124 FunctionTypedFormalParameter parameter =
9125 parse4("parseNormalFormalParameter", "a()?)");
9126 expect(parameter.returnType, isNull);
9127 expect(parameter.identifier, isNotNull);
9128 expect(parameter.typeParameters, isNull);
9129 expect(parameter.parameters, isNotNull);
9130 expect(parameter.question, isNotNull);
9131 }
9132
9099 void test_parseNormalFormalParameter_function_noType_typeParameterComments() { 9133 void test_parseNormalFormalParameter_function_noType_typeParameterComments() {
9100 enableGenericMethodComments = true; 9134 enableGenericMethodComments = true;
9101 FunctionTypedFormalParameter parameter = 9135 FunctionTypedFormalParameter parameter =
9102 parse4("parseNormalFormalParameter", "a/*<E>*/())"); 9136 parse4("parseNormalFormalParameter", "a/*<E>*/())");
9103 expect(parameter.returnType, isNull); 9137 expect(parameter.returnType, isNull);
9104 expect(parameter.identifier, isNotNull); 9138 expect(parameter.identifier, isNotNull);
9105 expect(parameter.typeParameters, isNotNull); 9139 expect(parameter.typeParameters, isNotNull);
9106 expect(parameter.parameters, isNotNull); 9140 expect(parameter.parameters, isNotNull);
9107 } 9141 }
9108 9142
9109 void test_parseNormalFormalParameter_function_noType_typeParameters() { 9143 void test_parseNormalFormalParameter_function_noType_typeParameters() {
9110 enableGenericMethods = true; 9144 enableGenericMethods = true;
9111 FunctionTypedFormalParameter parameter = 9145 FunctionTypedFormalParameter parameter =
9112 parse4("parseNormalFormalParameter", "a<E>())"); 9146 parse4("parseNormalFormalParameter", "a<E>())");
9113 expect(parameter.returnType, isNull); 9147 expect(parameter.returnType, isNull);
9114 expect(parameter.identifier, isNotNull); 9148 expect(parameter.identifier, isNotNull);
9115 expect(parameter.typeParameters, isNotNull); 9149 expect(parameter.typeParameters, isNotNull);
9116 expect(parameter.parameters, isNotNull); 9150 expect(parameter.parameters, isNotNull);
9151 expect(parameter.question, isNull);
9152 expect(parameter.question, isNull);
9153 }
9154
9155 void
9156 test_parseNormalFormalParameter_function_noType_typeParameters_nullable() {
9157 enableGenericMethods = true;
9158 enableNnbd = true;
9159 FunctionTypedFormalParameter parameter =
9160 parse4("parseNormalFormalParameter", "a<E>()?)");
9161 expect(parameter.returnType, isNull);
9162 expect(parameter.identifier, isNotNull);
9163 expect(parameter.typeParameters, isNotNull);
9164 expect(parameter.parameters, isNotNull);
9165 expect(parameter.question, isNotNull);
9117 } 9166 }
9118 9167
9119 void test_parseNormalFormalParameter_function_type() { 9168 void test_parseNormalFormalParameter_function_type() {
9120 FunctionTypedFormalParameter parameter = 9169 FunctionTypedFormalParameter parameter =
9121 parse4("parseNormalFormalParameter", "A a())"); 9170 parse4("parseNormalFormalParameter", "A a())");
9122 expect(parameter.returnType, isNotNull); 9171 expect(parameter.returnType, isNotNull);
9123 expect(parameter.identifier, isNotNull); 9172 expect(parameter.identifier, isNotNull);
9124 expect(parameter.typeParameters, isNull); 9173 expect(parameter.typeParameters, isNull);
9125 expect(parameter.parameters, isNotNull); 9174 expect(parameter.parameters, isNotNull);
9175 expect(parameter.question, isNull);
9176 }
9177
9178 void test_parseNormalFormalParameter_function_type_nullable() {
9179 enableNnbd = true;
9180 FunctionTypedFormalParameter parameter =
9181 parse4("parseNormalFormalParameter", "A a()?)");
9182 expect(parameter.returnType, isNotNull);
9183 expect(parameter.identifier, isNotNull);
9184 expect(parameter.typeParameters, isNull);
9185 expect(parameter.parameters, isNotNull);
9186 expect(parameter.question, isNotNull);
9126 } 9187 }
9127 9188
9128 void test_parseNormalFormalParameter_function_type_typeParameterComments() { 9189 void test_parseNormalFormalParameter_function_type_typeParameterComments() {
9129 enableGenericMethodComments = true; 9190 enableGenericMethodComments = true;
9130 FunctionTypedFormalParameter parameter = 9191 FunctionTypedFormalParameter parameter =
9131 parse4("parseNormalFormalParameter", "A a/*<E>*/())"); 9192 parse4("parseNormalFormalParameter", "A a/*<E>*/())");
9132 expect(parameter.returnType, isNotNull); 9193 expect(parameter.returnType, isNotNull);
9133 expect(parameter.identifier, isNotNull); 9194 expect(parameter.identifier, isNotNull);
9134 expect(parameter.typeParameters, isNotNull); 9195 expect(parameter.typeParameters, isNotNull);
9135 expect(parameter.parameters, isNotNull); 9196 expect(parameter.parameters, isNotNull);
9197 expect(parameter.question, isNull);
9136 } 9198 }
9137 9199
9138 void test_parseNormalFormalParameter_function_type_typeParameters() { 9200 void test_parseNormalFormalParameter_function_type_typeParameters() {
9139 enableGenericMethods = true; 9201 enableGenericMethods = true;
9140 FunctionTypedFormalParameter parameter = 9202 FunctionTypedFormalParameter parameter =
9141 parse4("parseNormalFormalParameter", "A a<E>())"); 9203 parse4("parseNormalFormalParameter", "A a<E>())");
9142 expect(parameter.returnType, isNotNull); 9204 expect(parameter.returnType, isNotNull);
9143 expect(parameter.identifier, isNotNull); 9205 expect(parameter.identifier, isNotNull);
9144 expect(parameter.typeParameters, isNotNull); 9206 expect(parameter.typeParameters, isNotNull);
9145 expect(parameter.parameters, isNotNull); 9207 expect(parameter.parameters, isNotNull);
9208 expect(parameter.question, isNull);
9209 }
9210
9211 void test_parseNormalFormalParameter_function_type_typeParameters_nullable() {
9212 enableGenericMethods = true;
9213 enableNnbd = true;
9214 FunctionTypedFormalParameter parameter =
9215 parse4("parseNormalFormalParameter", "A a<E>()?)");
9216 expect(parameter.returnType, isNotNull);
9217 expect(parameter.identifier, isNotNull);
9218 expect(parameter.typeParameters, isNotNull);
9219 expect(parameter.parameters, isNotNull);
9220 expect(parameter.question, isNotNull);
9146 } 9221 }
9147 9222
9148 void test_parseNormalFormalParameter_function_void() { 9223 void test_parseNormalFormalParameter_function_void() {
9149 FunctionTypedFormalParameter parameter = 9224 FunctionTypedFormalParameter parameter =
9150 parse4("parseNormalFormalParameter", "void a())"); 9225 parse4("parseNormalFormalParameter", "void a())");
9151 expect(parameter.returnType, isNotNull); 9226 expect(parameter.returnType, isNotNull);
9152 expect(parameter.identifier, isNotNull); 9227 expect(parameter.identifier, isNotNull);
9153 expect(parameter.typeParameters, isNull); 9228 expect(parameter.typeParameters, isNull);
9154 expect(parameter.parameters, isNotNull); 9229 expect(parameter.parameters, isNotNull);
9230 expect(parameter.question, isNull);
9231 }
9232
9233 void test_parseNormalFormalParameter_function_void_nullable() {
9234 enableNnbd = true;
9235 FunctionTypedFormalParameter parameter =
9236 parse4("parseNormalFormalParameter", "void a()?)");
9237 expect(parameter.returnType, isNotNull);
9238 expect(parameter.identifier, isNotNull);
9239 expect(parameter.typeParameters, isNull);
9240 expect(parameter.parameters, isNotNull);
9241 expect(parameter.question, isNotNull);
9155 } 9242 }
9156 9243
9157 void test_parseNormalFormalParameter_function_void_typeParameterComments() { 9244 void test_parseNormalFormalParameter_function_void_typeParameterComments() {
9158 enableGenericMethodComments = true; 9245 enableGenericMethodComments = true;
9159 FunctionTypedFormalParameter parameter = 9246 FunctionTypedFormalParameter parameter =
9160 parse4("parseNormalFormalParameter", "void a/*<E>*/())"); 9247 parse4("parseNormalFormalParameter", "void a/*<E>*/())");
9161 expect(parameter.returnType, isNotNull); 9248 expect(parameter.returnType, isNotNull);
9162 expect(parameter.identifier, isNotNull); 9249 expect(parameter.identifier, isNotNull);
9163 expect(parameter.typeParameters, isNotNull); 9250 expect(parameter.typeParameters, isNotNull);
9164 expect(parameter.parameters, isNotNull); 9251 expect(parameter.parameters, isNotNull);
9252 expect(parameter.question, isNull);
9165 } 9253 }
9166 9254
9167 void test_parseNormalFormalParameter_function_void_typeParameters() { 9255 void test_parseNormalFormalParameter_function_void_typeParameters() {
9168 enableGenericMethods = true; 9256 enableGenericMethods = true;
9169 FunctionTypedFormalParameter parameter = 9257 FunctionTypedFormalParameter parameter =
9170 parse4("parseNormalFormalParameter", "void a<E>())"); 9258 parse4("parseNormalFormalParameter", "void a<E>())");
9171 expect(parameter.returnType, isNotNull); 9259 expect(parameter.returnType, isNotNull);
9172 expect(parameter.identifier, isNotNull); 9260 expect(parameter.identifier, isNotNull);
9173 expect(parameter.typeParameters, isNotNull); 9261 expect(parameter.typeParameters, isNotNull);
9174 expect(parameter.parameters, isNotNull); 9262 expect(parameter.parameters, isNotNull);
9263 expect(parameter.question, isNull);
9264 }
9265
9266 void test_parseNormalFormalParameter_function_void_typeParameters_nullable() {
9267 enableGenericMethods = true;
9268 enableNnbd = true;
9269 FunctionTypedFormalParameter parameter =
9270 parse4("parseNormalFormalParameter", "void a<E>()?)");
9271 expect(parameter.returnType, isNotNull);
9272 expect(parameter.identifier, isNotNull);
9273 expect(parameter.typeParameters, isNotNull);
9274 expect(parameter.parameters, isNotNull);
9275 expect(parameter.question, isNotNull);
9175 } 9276 }
9176 9277
9177 void test_parseNormalFormalParameter_simple_const_noType() { 9278 void test_parseNormalFormalParameter_simple_const_noType() {
9178 SimpleFormalParameter parameter = 9279 SimpleFormalParameter parameter =
9179 parse4("parseNormalFormalParameter", "const a)"); 9280 parse4("parseNormalFormalParameter", "const a)");
9180 expect(parameter.keyword, isNotNull); 9281 expect(parameter.keyword, isNotNull);
9181 expect(parameter.type, isNull); 9282 expect(parameter.type, isNull);
9182 expect(parameter.identifier, isNotNull); 9283 expect(parameter.identifier, isNotNull);
9183 } 9284 }
9184 9285
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
10367 expect(argumentList.arguments, hasLength(1)); 10468 expect(argumentList.arguments, hasLength(1));
10368 expect(argumentList.rightBracket, isNotNull); 10469 expect(argumentList.rightBracket, isNotNull);
10369 } 10470 }
10370 10471
10371 void test_parseTypeName_parameterized() { 10472 void test_parseTypeName_parameterized() {
10372 TypeName typeName = parse4("parseTypeName", "List<int>"); 10473 TypeName typeName = parse4("parseTypeName", "List<int>");
10373 expect(typeName.name, isNotNull); 10474 expect(typeName.name, isNotNull);
10374 expect(typeName.typeArguments, isNotNull); 10475 expect(typeName.typeArguments, isNotNull);
10375 } 10476 }
10376 10477
10478 void test_parseTypeName_parameterized_nullable() {
10479 enableNnbd = true;
10480 TypeName typeName = parse4("parseTypeName", "List<int>?");
10481 expect(typeName.name, isNotNull);
10482 expect(typeName.typeArguments, isNotNull);
scheglov 2016/09/16 15:29:38 Should we check for "question"?
Brian Wilkerson 2016/09/16 15:47:35 Done
10483 }
10484
10377 void test_parseTypeName_simple() { 10485 void test_parseTypeName_simple() {
10378 TypeName typeName = parse4("parseTypeName", "int"); 10486 TypeName typeName = parse4("parseTypeName", "int");
10379 expect(typeName.name, isNotNull); 10487 expect(typeName.name, isNotNull);
10380 expect(typeName.typeArguments, isNull); 10488 expect(typeName.typeArguments, isNull);
10381 } 10489 }
10382 10490
10491 void test_parseTypeName_simple_nullable() {
10492 enableNnbd = true;
10493 TypeName typeName = parse4("parseTypeName", "String?");
10494 expect(typeName.name, isNotNull);
10495 expect(typeName.typeArguments, isNull);
scheglov 2016/09/16 15:29:39 Should we check for "question"? Do we need a test
Brian Wilkerson 2016/09/16 15:47:35 Done
10496 }
10497
10383 void test_parseTypeParameter_bounded() { 10498 void test_parseTypeParameter_bounded() {
10384 TypeParameter parameter = parse4("parseTypeParameter", "A extends B"); 10499 TypeParameter parameter = parse4("parseTypeParameter", "A extends B");
10385 expect(parameter.bound, isNotNull); 10500 expect(parameter.bound, isNotNull);
10386 expect(parameter.extendsKeyword, isNotNull); 10501 expect(parameter.extendsKeyword, isNotNull);
10387 expect(parameter.name, isNotNull); 10502 expect(parameter.name, isNotNull);
10388 } 10503 }
10389 10504
10390 void test_parseTypeParameter_simple() { 10505 void test_parseTypeParameter_simple() {
10391 TypeParameter parameter = parse4("parseTypeParameter", "A"); 10506 TypeParameter parameter = parse4("parseTypeParameter", "A");
10392 expect(parameter.bound, isNull); 10507 expect(parameter.bound, isNull);
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
11006 new Scanner(null, new CharSequenceReader(source), listener); 11121 new Scanner(null, new CharSequenceReader(source), listener);
11007 Token tokenStream = scanner.tokenize(); 11122 Token tokenStream = scanner.tokenize();
11008 // 11123 //
11009 // Parse the source. 11124 // Parse the source.
11010 // 11125 //
11011 Parser parser = new Parser(null, listener); 11126 Parser parser = new Parser(null, listener);
11012 return invokeParserMethodImpl( 11127 return invokeParserMethodImpl(
11013 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 11128 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
11014 } 11129 }
11015 } 11130 }
OLDNEW
« pkg/analyzer/lib/src/generated/parser.dart ('K') | « 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