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

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

Issue 780763004: Annotate analyzer tests with @ReflectiveTestCase(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | Annotate | Revision Log
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 engine.parser_test; 5 library engine.parser_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/incremental_scanner.dart'; 10 import 'package:analyzer/src/generated/incremental_scanner.dart';
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 } 117 }
118 118
119 /** 119 /**
120 * The class `ComplexParserTest` defines parser tests that test the parsing of m ore complex 120 * The class `ComplexParserTest` defines parser tests that test the parsing of m ore complex
121 * code fragments or the interactions between multiple parsing methods. For exam ple, tests to ensure 121 * code fragments or the interactions between multiple parsing methods. For exam ple, tests to ensure
122 * that the precedence of operations is being handled correctly should be define d in this class. 122 * that the precedence of operations is being handled correctly should be define d in this class.
123 * 123 *
124 * Simpler tests should be defined in the class [SimpleParserTest]. 124 * Simpler tests should be defined in the class [SimpleParserTest].
125 */ 125 */
126 @ReflectiveTestCase()
126 class ComplexParserTest extends ParserTestCase { 127 class ComplexParserTest extends ParserTestCase {
127 void test_additiveExpression_normal() { 128 void test_additiveExpression_normal() {
128 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z"); 129 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z");
129 EngineTestCase.assertInstanceOf( 130 EngineTestCase.assertInstanceOf(
130 (obj) => obj is BinaryExpression, 131 (obj) => obj is BinaryExpression,
131 BinaryExpression, 132 BinaryExpression,
132 expression.leftOperand); 133 expression.leftOperand);
133 } 134 }
134 135
135 void test_additiveExpression_noSpaces() { 136 void test_additiveExpression_noSpaces() {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 577
577 void test_topLevelVariable_withMetadata() { 578 void test_topLevelVariable_withMetadata() {
578 ParserTestCase.parseCompilationUnit("String @A string;"); 579 ParserTestCase.parseCompilationUnit("String @A string;");
579 } 580 }
580 } 581 }
581 582
582 /** 583 /**
583 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure 584 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure
584 * that errors are correctly reported, and in some cases, not reported. 585 * that errors are correctly reported, and in some cases, not reported.
585 */ 586 */
587 @ReflectiveTestCase()
586 class ErrorParserTest extends ParserTestCase { 588 class ErrorParserTest extends ParserTestCase {
587 void fail_expectedListOrMapLiteral() { 589 void fail_expectedListOrMapLiteral() {
588 // It isn't clear that this test can ever pass. The parser is currently 590 // It isn't clear that this test can ever pass. The parser is currently
589 // create a synthetic list literal in this case, but isSynthetic() isn't 591 // create a synthetic list literal in this case, but isSynthetic() isn't
590 // overridden for ListLiteral. The problem is that the synthetic list 592 // overridden for ListLiteral. The problem is that the synthetic list
591 // literals that are being created are not always zero length (because they 593 // literals that are being created are not always zero length (because they
592 // could have type parameters), which violates the contract of 594 // could have type parameters), which violates the contract of
593 // isSynthetic(). 595 // isSynthetic().
594 TypedLiteral literal = ParserTestCase.parse3( 596 TypedLiteral literal = ParserTestCase.parse3(
595 "parseListOrMapLiteral", 597 "parseListOrMapLiteral",
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 } 2571 }
2570 2572
2571 void test_wrongTerminatorForParameterGroup_optional() { 2573 void test_wrongTerminatorForParameterGroup_optional() {
2572 ParserTestCase.parse4( 2574 ParserTestCase.parse4(
2573 "parseFormalParameterList", 2575 "parseFormalParameterList",
2574 "(a, [b, c})", 2576 "(a, [b, c})",
2575 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); 2577 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]);
2576 } 2578 }
2577 } 2579 }
2578 2580
2581 @ReflectiveTestCase()
2579 class IncrementalParserTest extends EngineTestCase { 2582 class IncrementalParserTest extends EngineTestCase {
2580 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() { 2583 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() {
2581 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs 2584 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs
2582 2585
2583 // Function literals are allowed inside interpolation expressions in 2586 // Function literals are allowed inside interpolation expressions in
2584 // initializers. 2587 // initializers.
2585 // 2588 //
2586 // 'class A { var a; A(b) : a = "${b}";' 2589 // 'class A { var a; A(b) : a = "${b}";'
2587 // 'class A { var a; A(b) : a = "${() {}}";' 2590 // 'class A { var a; A(b) : a = "${() {}}";'
2588 _assertParse(r'class A { var a; A(b) : a = "${', 'b', '() {}', '}";'); 2591 _assertParse(r'class A { var a; A(b) : a = "${', 'b', '() {}', '}";');
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 expect(incrementalUnit, isNotNull); 2962 expect(incrementalUnit, isNotNull);
2960 // 2963 //
2961 // Validate that the results of the incremental parse are the same as the 2964 // Validate that the results of the incremental parse are the same as the
2962 // full parse of the modified source. 2965 // full parse of the modified source.
2963 // 2966 //
2964 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue); 2967 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue);
2965 // TODO(brianwilkerson) Verify that the errors are correct? 2968 // TODO(brianwilkerson) Verify that the errors are correct?
2966 } 2969 }
2967 } 2970 }
2968 2971
2972 @ReflectiveTestCase()
2969 class NonErrorParserTest extends ParserTestCase { 2973 class NonErrorParserTest extends ParserTestCase {
2970 void test_constFactory_external() { 2974 void test_constFactory_external() {
2971 ParserTestCase.parse( 2975 ParserTestCase.parse(
2972 "parseClassMember", 2976 "parseClassMember",
2973 <Object>["C"], 2977 <Object>["C"],
2974 "external const factory C();"); 2978 "external const factory C();");
2975 } 2979 }
2976 } 2980 }
2977 2981
2978 class ParserTestCase extends EngineTestCase { 2982 class ParserTestCase extends EngineTestCase {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 expect(statements, hasLength(expectedCount)); 3266 expect(statements, hasLength(expectedCount));
3263 listener.assertErrorsWithCodes(errorCodes); 3267 listener.assertErrorsWithCodes(errorCodes);
3264 return statements; 3268 return statements;
3265 } 3269 }
3266 } 3270 }
3267 3271
3268 /** 3272 /**
3269 * The class `RecoveryParserTest` defines parser tests that test the parsing of invalid code 3273 * The class `RecoveryParserTest` defines parser tests that test the parsing of invalid code
3270 * sequences to ensure that the correct recovery steps are taken in the parser. 3274 * sequences to ensure that the correct recovery steps are taken in the parser.
3271 */ 3275 */
3276 @ReflectiveTestCase()
3272 class RecoveryParserTest extends ParserTestCase { 3277 class RecoveryParserTest extends ParserTestCase {
3273 void fail_incomplete_returnType() { 3278 void fail_incomplete_returnType() {
3274 ParserTestCase.parseCompilationUnit(r''' 3279 ParserTestCase.parseCompilationUnit(r'''
3275 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) { 3280 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) {
3276 if (map == null) return null; 3281 if (map == null) return null;
3277 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); 3282 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>();
3278 map.forEach((name, value) { 3283 map.forEach((name, value) {
3279 result[new Symbol(name)] = value; 3284 result[new Symbol(name)] = value;
3280 }); 3285 });
3281 return result; 3286 return result;
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
4507 (obj) => obj is FunctionTypeAlias, 4512 (obj) => obj is FunctionTypeAlias,
4508 FunctionTypeAlias, 4513 FunctionTypeAlias,
4509 member); 4514 member);
4510 } 4515 }
4511 4516
4512 void test_unaryPlus() { 4517 void test_unaryPlus() {
4513 ParserTestCase.parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]); 4518 ParserTestCase.parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]);
4514 } 4519 }
4515 } 4520 }
4516 4521
4522 @ReflectiveTestCase()
4517 class ResolutionCopierTest extends EngineTestCase { 4523 class ResolutionCopierTest extends EngineTestCase {
4518 void test_visitAnnotation() { 4524 void test_visitAnnotation() {
4519 String annotationName = "proxy"; 4525 String annotationName = "proxy";
4520 Annotation fromNode = 4526 Annotation fromNode =
4521 AstFactory.annotation(AstFactory.identifier3(annotationName)); 4527 AstFactory.annotation(AstFactory.identifier3(annotationName));
4522 Element element = ElementFactory.topLevelVariableElement2(annotationName); 4528 Element element = ElementFactory.topLevelVariableElement2(annotationName);
4523 fromNode.element = element; 4529 fromNode.element = element;
4524 Annotation toNode = 4530 Annotation toNode =
4525 AstFactory.annotation(AstFactory.identifier3(annotationName)); 4531 AstFactory.annotation(AstFactory.identifier3(annotationName));
4526 ResolutionCopier.copyResolutionData(fromNode, toNode); 4532 ResolutionCopier.copyResolutionData(fromNode, toNode);
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
5156 } 5162 }
5157 } 5163 }
5158 5164
5159 /** 5165 /**
5160 * The class `SimpleParserTest` defines parser tests that test individual parsin g method. The 5166 * The class `SimpleParserTest` defines parser tests that test individual parsin g method. The
5161 * code fragments should be as minimal as possible in order to test the method, but should not test 5167 * code fragments should be as minimal as possible in order to test the method, but should not test
5162 * the interactions between the method under test and other methods. 5168 * the interactions between the method under test and other methods.
5163 * 5169 *
5164 * More complex tests should be defined in the class [ComplexParserTest]. 5170 * More complex tests should be defined in the class [ComplexParserTest].
5165 */ 5171 */
5172 @ReflectiveTestCase()
5166 class SimpleParserTest extends ParserTestCase { 5173 class SimpleParserTest extends ParserTestCase {
5167 void fail_parseCommentReference_this() { 5174 void fail_parseCommentReference_this() {
5168 // This fails because we are returning null from the method and asserting 5175 // This fails because we are returning null from the method and asserting
5169 // that the return value is not null. 5176 // that the return value is not null.
5170 CommentReference reference = 5177 CommentReference reference =
5171 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], ""); 5178 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], "");
5172 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 5179 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
5173 (obj) => obj is SimpleIdentifier, 5180 (obj) => obj is SimpleIdentifier,
5174 SimpleIdentifier, 5181 SimpleIdentifier,
5175 reference.identifier); 5182 reference.identifier);
(...skipping 5804 matching lines...) Expand 10 before | Expand all | Expand 10 after
10980 // Parse the source. 10987 // Parse the source.
10981 // 10988 //
10982 Parser parser = new Parser(null, listener); 10989 Parser parser = new Parser(null, listener);
10983 return invokeParserMethodImpl( 10990 return invokeParserMethodImpl(
10984 parser, 10991 parser,
10985 methodName, 10992 methodName,
10986 <Object>[tokenStream], 10993 <Object>[tokenStream],
10987 tokenStream) as Token; 10994 tokenStream) as Token;
10988 } 10995 }
10989 } 10996 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/incremental_scanner_test.dart ('k') | pkg/analyzer/test/generated/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698