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

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

Issue 849863002: Replace @ReflectiveTestCase() with @reflectiveTest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | 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 @reflectiveTest
127 class ComplexParserTest extends ParserTestCase { 127 class ComplexParserTest extends ParserTestCase {
128 void test_additiveExpression_normal() { 128 void test_additiveExpression_normal() {
129 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z"); 129 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z");
130 EngineTestCase.assertInstanceOf( 130 EngineTestCase.assertInstanceOf(
131 (obj) => obj is BinaryExpression, 131 (obj) => obj is BinaryExpression,
132 BinaryExpression, 132 BinaryExpression,
133 expression.leftOperand); 133 expression.leftOperand);
134 } 134 }
135 135
136 void test_additiveExpression_noSpaces() { 136 void test_additiveExpression_noSpaces() {
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 577
578 void test_topLevelVariable_withMetadata() { 578 void test_topLevelVariable_withMetadata() {
579 ParserTestCase.parseCompilationUnit("String @A string;"); 579 ParserTestCase.parseCompilationUnit("String @A string;");
580 } 580 }
581 } 581 }
582 582
583 /** 583 /**
584 * 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
585 * that errors are correctly reported, and in some cases, not reported. 585 * that errors are correctly reported, and in some cases, not reported.
586 */ 586 */
587 @ReflectiveTestCase() 587 @reflectiveTest
588 class ErrorParserTest extends ParserTestCase { 588 class ErrorParserTest extends ParserTestCase {
589 void fail_expectedListOrMapLiteral() { 589 void fail_expectedListOrMapLiteral() {
590 // 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
591 // 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
592 // overridden for ListLiteral. The problem is that the synthetic list 592 // overridden for ListLiteral. The problem is that the synthetic list
593 // 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
594 // could have type parameters), which violates the contract of 594 // could have type parameters), which violates the contract of
595 // isSynthetic(). 595 // isSynthetic().
596 TypedLiteral literal = ParserTestCase.parse3( 596 TypedLiteral literal = ParserTestCase.parse3(
597 "parseListOrMapLiteral", 597 "parseListOrMapLiteral",
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 } 2571 }
2572 2572
2573 void test_wrongTerminatorForParameterGroup_optional() { 2573 void test_wrongTerminatorForParameterGroup_optional() {
2574 ParserTestCase.parse4( 2574 ParserTestCase.parse4(
2575 "parseFormalParameterList", 2575 "parseFormalParameterList",
2576 "(a, [b, c})", 2576 "(a, [b, c})",
2577 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]); 2577 [ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP]);
2578 } 2578 }
2579 } 2579 }
2580 2580
2581 @ReflectiveTestCase() 2581 @reflectiveTest
2582 class IncrementalParserTest extends EngineTestCase { 2582 class IncrementalParserTest extends EngineTestCase {
2583 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() { 2583 void fail_replace_identifier_with_functionLiteral_in_initializer_interp() {
2584 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs 2584 // TODO(paulberry, brianwilkerson): broken due to incremental scanning bugs
2585 2585
2586 // Function literals are allowed inside interpolation expressions in 2586 // Function literals are allowed inside interpolation expressions in
2587 // initializers. 2587 // initializers.
2588 // 2588 //
2589 // 'class A { var a; A(b) : a = "${b}";' 2589 // 'class A { var a; A(b) : a = "${b}";'
2590 // 'class A { var a; A(b) : a = "${() {}}";' 2590 // 'class A { var a; A(b) : a = "${() {}}";'
2591 _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
2962 expect(incrementalUnit, isNotNull); 2962 expect(incrementalUnit, isNotNull);
2963 // 2963 //
2964 // 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
2965 // full parse of the modified source. 2965 // full parse of the modified source.
2966 // 2966 //
2967 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue); 2967 expect(AstComparator.equalNodes(modifiedUnit, incrementalUnit), isTrue);
2968 // TODO(brianwilkerson) Verify that the errors are correct? 2968 // TODO(brianwilkerson) Verify that the errors are correct?
2969 } 2969 }
2970 } 2970 }
2971 2971
2972 @ReflectiveTestCase() 2972 @reflectiveTest
2973 class NonErrorParserTest extends ParserTestCase { 2973 class NonErrorParserTest extends ParserTestCase {
2974 void test_constFactory_external() { 2974 void test_constFactory_external() {
2975 ParserTestCase.parse( 2975 ParserTestCase.parse(
2976 "parseClassMember", 2976 "parseClassMember",
2977 <Object>["C"], 2977 <Object>["C"],
2978 "external const factory C();"); 2978 "external const factory C();");
2979 } 2979 }
2980 } 2980 }
2981 2981
2982 class ParserTestCase extends EngineTestCase { 2982 class ParserTestCase extends EngineTestCase {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 expect(statements, hasLength(expectedCount)); 3260 expect(statements, hasLength(expectedCount));
3261 listener.assertErrorsWithCodes(errorCodes); 3261 listener.assertErrorsWithCodes(errorCodes);
3262 return statements; 3262 return statements;
3263 } 3263 }
3264 } 3264 }
3265 3265
3266 /** 3266 /**
3267 * The class `RecoveryParserTest` defines parser tests that test the parsing of invalid code 3267 * The class `RecoveryParserTest` defines parser tests that test the parsing of invalid code
3268 * sequences to ensure that the correct recovery steps are taken in the parser. 3268 * sequences to ensure that the correct recovery steps are taken in the parser.
3269 */ 3269 */
3270 @ReflectiveTestCase() 3270 @reflectiveTest
3271 class RecoveryParserTest extends ParserTestCase { 3271 class RecoveryParserTest extends ParserTestCase {
3272 void fail_incomplete_returnType() { 3272 void fail_incomplete_returnType() {
3273 ParserTestCase.parseCompilationUnit(r''' 3273 ParserTestCase.parseCompilationUnit(r'''
3274 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) { 3274 Map<Symbol, convertStringToSymbolMap(Map<String, dynamic> map) {
3275 if (map == null) return null; 3275 if (map == null) return null;
3276 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>(); 3276 Map<Symbol, dynamic> result = new Map<Symbol, dynamic>();
3277 map.forEach((name, value) { 3277 map.forEach((name, value) {
3278 result[new Symbol(name)] = value; 3278 result[new Symbol(name)] = value;
3279 }); 3279 });
3280 return result; 3280 return result;
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
4506 (obj) => obj is FunctionTypeAlias, 4506 (obj) => obj is FunctionTypeAlias,
4507 FunctionTypeAlias, 4507 FunctionTypeAlias,
4508 member); 4508 member);
4509 } 4509 }
4510 4510
4511 void test_unaryPlus() { 4511 void test_unaryPlus() {
4512 ParserTestCase.parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]); 4512 ParserTestCase.parseExpression("+2", [ParserErrorCode.MISSING_IDENTIFIER]);
4513 } 4513 }
4514 } 4514 }
4515 4515
4516 @ReflectiveTestCase() 4516 @reflectiveTest
4517 class ResolutionCopierTest extends EngineTestCase { 4517 class ResolutionCopierTest extends EngineTestCase {
4518 void test_visitAnnotation() { 4518 void test_visitAnnotation() {
4519 String annotationName = "proxy"; 4519 String annotationName = "proxy";
4520 Annotation fromNode = 4520 Annotation fromNode =
4521 AstFactory.annotation(AstFactory.identifier3(annotationName)); 4521 AstFactory.annotation(AstFactory.identifier3(annotationName));
4522 Element element = ElementFactory.topLevelVariableElement2(annotationName); 4522 Element element = ElementFactory.topLevelVariableElement2(annotationName);
4523 fromNode.element = element; 4523 fromNode.element = element;
4524 Annotation toNode = 4524 Annotation toNode =
4525 AstFactory.annotation(AstFactory.identifier3(annotationName)); 4525 AstFactory.annotation(AstFactory.identifier3(annotationName));
4526 ResolutionCopier.copyResolutionData(fromNode, toNode); 4526 ResolutionCopier.copyResolutionData(fromNode, toNode);
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
5156 } 5156 }
5157 } 5157 }
5158 5158
5159 /** 5159 /**
5160 * The class `SimpleParserTest` defines parser tests that test individual parsin g method. The 5160 * 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 5161 * 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. 5162 * the interactions between the method under test and other methods.
5163 * 5163 *
5164 * More complex tests should be defined in the class [ComplexParserTest]. 5164 * More complex tests should be defined in the class [ComplexParserTest].
5165 */ 5165 */
5166 @ReflectiveTestCase() 5166 @reflectiveTest
5167 class SimpleParserTest extends ParserTestCase { 5167 class SimpleParserTest extends ParserTestCase {
5168 void fail_parseCommentReference_this() { 5168 void fail_parseCommentReference_this() {
5169 // This fails because we are returning null from the method and asserting 5169 // This fails because we are returning null from the method and asserting
5170 // that the return value is not null. 5170 // that the return value is not null.
5171 CommentReference reference = 5171 CommentReference reference =
5172 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], ""); 5172 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], "");
5173 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 5173 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
5174 (obj) => obj is SimpleIdentifier, 5174 (obj) => obj is SimpleIdentifier,
5175 SimpleIdentifier, 5175 SimpleIdentifier,
5176 reference.identifier); 5176 reference.identifier);
(...skipping 5804 matching lines...) Expand 10 before | Expand all | Expand 10 after
10981 // Parse the source. 10981 // Parse the source.
10982 // 10982 //
10983 Parser parser = new Parser(null, listener); 10983 Parser parser = new Parser(null, listener);
10984 return invokeParserMethodImpl( 10984 return invokeParserMethodImpl(
10985 parser, 10985 parser,
10986 methodName, 10986 methodName,
10987 <Object>[tokenStream], 10987 <Object>[tokenStream],
10988 tokenStream) as Token; 10988 tokenStream) as Token;
10989 } 10989 }
10990 } 10990 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698