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

Side by Side Diff: pkg/analyzer/test/generated/ast_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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.ast_test; 8 library engine.ast_test;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 BreadthFirstVisitor_BreadthFirstVisitorTest_testIt(this.nodes) : super(); 89 BreadthFirstVisitor_BreadthFirstVisitorTest_testIt(this.nodes) : super();
90 90
91 @override 91 @override
92 Object visitNode(AstNode node) { 92 Object visitNode(AstNode node) {
93 nodes.add(node); 93 nodes.add(node);
94 return super.visitNode(node); 94 return super.visitNode(node);
95 } 95 }
96 } 96 }
97 97
98 @ReflectiveTestCase() 98 @reflectiveTest
99 class BreadthFirstVisitorTest extends ParserTestCase { 99 class BreadthFirstVisitorTest extends ParserTestCase {
100 void test_it() { 100 void test_it() {
101 String source = r''' 101 String source = r'''
102 class A { 102 class A {
103 bool get g => true; 103 bool get g => true;
104 } 104 }
105 class B { 105 class B {
106 int f() { 106 int f() {
107 num q() { 107 num q() {
108 return 3; 108 return 3;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 FunctionDeclarationStatement, 140 FunctionDeclarationStatement,
141 nodes[27]); 141 nodes[27]);
142 EngineTestCase.assertInstanceOf( 142 EngineTestCase.assertInstanceOf(
143 (obj) => obj is IntegerLiteral, 143 (obj) => obj is IntegerLiteral,
144 IntegerLiteral, 144 IntegerLiteral,
145 nodes[58]); 145 nodes[58]);
146 //3 146 //3
147 } 147 }
148 } 148 }
149 149
150 @ReflectiveTestCase() 150 @reflectiveTest
151 class ClassDeclarationTest extends ParserTestCase { 151 class ClassDeclarationTest extends ParserTestCase {
152 void test_getConstructor() { 152 void test_getConstructor() {
153 List<ConstructorInitializer> initializers = 153 List<ConstructorInitializer> initializers =
154 new List<ConstructorInitializer>(); 154 new List<ConstructorInitializer>();
155 ConstructorDeclaration defaultConstructor = 155 ConstructorDeclaration defaultConstructor =
156 AstFactory.constructorDeclaration( 156 AstFactory.constructorDeclaration(
157 AstFactory.identifier3("Test"), 157 AstFactory.identifier3("Test"),
158 null, 158 null,
159 AstFactory.formalParameterList(), 159 AstFactory.formalParameterList(),
160 initializers); 160 initializers);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 Keyword.ABSTRACT, 239 Keyword.ABSTRACT,
240 "B", 240 "B",
241 null, 241 null,
242 null, 242 null,
243 null, 243 null,
244 null).isAbstract, 244 null).isAbstract,
245 isTrue); 245 isTrue);
246 } 246 }
247 } 247 }
248 248
249 @ReflectiveTestCase() 249 @reflectiveTest
250 class ClassTypeAliasTest extends ParserTestCase { 250 class ClassTypeAliasTest extends ParserTestCase {
251 void test_isAbstract() { 251 void test_isAbstract() {
252 expect( 252 expect(
253 AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract, 253 AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract,
254 isFalse); 254 isFalse);
255 expect( 255 expect(
256 AstFactory.classTypeAlias( 256 AstFactory.classTypeAlias(
257 "B", 257 "B",
258 null, 258 null,
259 Keyword.ABSTRACT, 259 Keyword.ABSTRACT,
260 null, 260 null,
261 null, 261 null,
262 null).isAbstract, 262 null).isAbstract,
263 isTrue); 263 isTrue);
264 } 264 }
265 } 265 }
266 266
267 @ReflectiveTestCase() 267 @reflectiveTest
268 class ConstantEvaluatorTest extends ParserTestCase { 268 class ConstantEvaluatorTest extends ParserTestCase {
269 void fail_constructor() { 269 void fail_constructor() {
270 Object value = _getConstantValue("?"); 270 Object value = _getConstantValue("?");
271 expect(value, null); 271 expect(value, null);
272 } 272 }
273 273
274 void fail_identifier_class() { 274 void fail_identifier_class() {
275 Object value = _getConstantValue("?"); 275 Object value = _getConstantValue("?");
276 expect(value, null); 276 expect(value, null);
277 } 277 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 void test_unary_negated_integer() { 575 void test_unary_negated_integer() {
576 Object value = _getConstantValue("-42"); 576 Object value = _getConstantValue("-42");
577 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 577 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
578 expect(value as int, -42); 578 expect(value as int, -42);
579 } 579 }
580 580
581 Object _getConstantValue(String source) => 581 Object _getConstantValue(String source) =>
582 ParserTestCase.parseExpression(source).accept(new ConstantEvaluator()); 582 ParserTestCase.parseExpression(source).accept(new ConstantEvaluator());
583 } 583 }
584 584
585 @ReflectiveTestCase() 585 @reflectiveTest
586 class ConstructorDeclarationTest extends EngineTestCase { 586 class ConstructorDeclarationTest extends EngineTestCase {
587 void test_firstTokenAfterCommentAndMetadata_all_inverted() { 587 void test_firstTokenAfterCommentAndMetadata_all_inverted() {
588 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 588 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
589 externalKeyword.offset = 14; 589 externalKeyword.offset = 14;
590 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 590 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
591 Keyword.CONST, 591 Keyword.CONST,
592 Keyword.FACTORY, 592 Keyword.FACTORY,
593 AstFactory.identifier3('int'), 593 AstFactory.identifier3('int'),
594 null, 594 null,
595 null, 595 null,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 null, 655 null,
656 null, 656 null,
657 null, 657 null,
658 null); 658 null);
659 expect( 659 expect(
660 declaration.firstTokenAfterCommentAndMetadata, 660 declaration.firstTokenAfterCommentAndMetadata,
661 declaration.factoryKeyword); 661 declaration.factoryKeyword);
662 } 662 }
663 } 663 }
664 664
665 @ReflectiveTestCase() 665 @reflectiveTest
666 class IndexExpressionTest extends EngineTestCase { 666 class IndexExpressionTest extends EngineTestCase {
667 void test_inGetterContext_assignment_compound_left() { 667 void test_inGetterContext_assignment_compound_left() {
668 IndexExpression expression = AstFactory.indexExpression( 668 IndexExpression expression = AstFactory.indexExpression(
669 AstFactory.identifier3("a"), 669 AstFactory.identifier3("a"),
670 AstFactory.identifier3("b")); 670 AstFactory.identifier3("b"));
671 // a[b] += c 671 // a[b] += c
672 AstFactory.assignmentExpression( 672 AstFactory.assignmentExpression(
673 expression, 673 expression,
674 TokenType.PLUS_EQ, 674 TokenType.PLUS_EQ,
675 AstFactory.identifier3("c")); 675 AstFactory.identifier3("c"));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 void test_inSetterContext_prefix_plusPlus() { 790 void test_inSetterContext_prefix_plusPlus() {
791 IndexExpression expression = AstFactory.indexExpression( 791 IndexExpression expression = AstFactory.indexExpression(
792 AstFactory.identifier3("a"), 792 AstFactory.identifier3("a"),
793 AstFactory.identifier3("b")); 793 AstFactory.identifier3("b"));
794 // ++a[b] 794 // ++a[b]
795 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); 795 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression);
796 expect(expression.inSetterContext(), isTrue); 796 expect(expression.inSetterContext(), isTrue);
797 } 797 }
798 } 798 }
799 799
800 @ReflectiveTestCase() 800 @reflectiveTest
801 class NodeListTest extends EngineTestCase { 801 class NodeListTest extends EngineTestCase {
802 void test_add() { 802 void test_add() {
803 AstNode parent = AstFactory.argumentList(); 803 AstNode parent = AstFactory.argumentList();
804 AstNode firstNode = AstFactory.booleanLiteral(true); 804 AstNode firstNode = AstFactory.booleanLiteral(true);
805 AstNode secondNode = AstFactory.booleanLiteral(false); 805 AstNode secondNode = AstFactory.booleanLiteral(false);
806 NodeList<AstNode> list = new NodeList<AstNode>(parent); 806 NodeList<AstNode> list = new NodeList<AstNode>(parent);
807 list.insert(0, secondNode); 807 list.insert(0, secondNode);
808 list.insert(0, firstNode); 808 list.insert(0, firstNode);
809 expect(list, hasLength(2)); 809 expect(list, hasLength(2));
810 expect(list[0], same(firstNode)); 810 expect(list[0], same(firstNode));
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 1018 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList());
1019 try { 1019 try {
1020 javaListSet(list, 1, node); 1020 javaListSet(list, 1, node);
1021 fail("Expected IndexOutOfBoundsException"); 1021 fail("Expected IndexOutOfBoundsException");
1022 } on RangeError catch (exception) { 1022 } on RangeError catch (exception) {
1023 // Expected 1023 // Expected
1024 } 1024 }
1025 } 1025 }
1026 } 1026 }
1027 1027
1028 @ReflectiveTestCase() 1028 @reflectiveTest
1029 class NodeLocatorTest extends ParserTestCase { 1029 class NodeLocatorTest extends ParserTestCase {
1030 void test_range() { 1030 void test_range() {
1031 CompilationUnit unit = 1031 CompilationUnit unit =
1032 ParserTestCase.parseCompilationUnit("library myLib;"); 1032 ParserTestCase.parseCompilationUnit("library myLib;");
1033 _assertLocate( 1033 _assertLocate(
1034 unit, 1034 unit,
1035 4, 1035 4,
1036 10, 1036 10,
1037 (node) => node is LibraryDirective, 1037 (node) => node is LibraryDirective,
1038 LibraryDirective); 1038 LibraryDirective);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 expect(locator.foundNode, same(node)); 1080 expect(locator.foundNode, same(node));
1081 expect(node.offset <= start, isTrue, reason: "Node starts after range"); 1081 expect(node.offset <= start, isTrue, reason: "Node starts after range");
1082 expect( 1082 expect(
1083 node.offset + node.length > end, 1083 node.offset + node.length > end,
1084 isTrue, 1084 isTrue,
1085 reason: "Node ends before range"); 1085 reason: "Node ends before range");
1086 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); 1086 EngineTestCase.assertInstanceOf(predicate, expectedClass, node);
1087 } 1087 }
1088 } 1088 }
1089 1089
1090 @ReflectiveTestCase() 1090 @reflectiveTest
1091 class SimpleIdentifierTest extends ParserTestCase { 1091 class SimpleIdentifierTest extends ParserTestCase {
1092 void test_inDeclarationContext_catch_exception() { 1092 void test_inDeclarationContext_catch_exception() {
1093 SimpleIdentifier identifier = 1093 SimpleIdentifier identifier =
1094 AstFactory.catchClause("e").exceptionParameter; 1094 AstFactory.catchClause("e").exceptionParameter;
1095 expect(identifier.inDeclarationContext(), isTrue); 1095 expect(identifier.inDeclarationContext(), isTrue);
1096 } 1096 }
1097 1097
1098 void test_inDeclarationContext_catch_stack() { 1098 void test_inDeclarationContext_catch_stack() {
1099 SimpleIdentifier identifier = 1099 SimpleIdentifier identifier =
1100 AstFactory.catchClause2("e", "s").stackTraceParameter; 1100 AstFactory.catchClause2("e", "s").stackTraceParameter;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 AstNode child = identifier; 1399 AstNode child = identifier;
1400 AstNode parent = identifier.parent; 1400 AstNode parent = identifier.parent;
1401 while (parent != null) { 1401 while (parent != null) {
1402 child = parent; 1402 child = parent;
1403 parent = parent.parent; 1403 parent = parent.parent;
1404 } 1404 }
1405 return child; 1405 return child;
1406 } 1406 }
1407 } 1407 }
1408 1408
1409 @ReflectiveTestCase() 1409 @reflectiveTest
1410 class SimpleStringLiteralTest extends ParserTestCase { 1410 class SimpleStringLiteralTest extends ParserTestCase {
1411 void test_contentsEnd() { 1411 void test_contentsEnd() {
1412 expect( 1412 expect(
1413 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").conten tsEnd, 1413 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").conten tsEnd,
1414 2); 1414 2);
1415 expect( 1415 expect(
1416 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").cont entsEnd, 1416 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").cont entsEnd,
1417 2); 1417 2);
1418 expect( 1418 expect(
1419 new SimpleStringLiteral( 1419 new SimpleStringLiteral(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 void test_simple() { 1613 void test_simple() {
1614 Token token = TokenFactory.tokenFromString("'value'"); 1614 Token token = TokenFactory.tokenFromString("'value'");
1615 SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value"); 1615 SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value");
1616 expect(stringLiteral.literal, same(token)); 1616 expect(stringLiteral.literal, same(token));
1617 expect(stringLiteral.beginToken, same(token)); 1617 expect(stringLiteral.beginToken, same(token));
1618 expect(stringLiteral.endToken, same(token)); 1618 expect(stringLiteral.endToken, same(token));
1619 expect(stringLiteral.value, "value"); 1619 expect(stringLiteral.value, "value");
1620 } 1620 }
1621 } 1621 }
1622 1622
1623 @ReflectiveTestCase() 1623 @reflectiveTest
1624 class StringInterpolationTest extends ParserTestCase { 1624 class StringInterpolationTest extends ParserTestCase {
1625 void test_contentsOffsetEnd() { 1625 void test_contentsOffsetEnd() {
1626 AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1626 AstFactory.interpolationExpression(AstFactory.identifier3('bb'));
1627 // 'a${bb}ccc' 1627 // 'a${bb}ccc'
1628 { 1628 {
1629 var ae = AstFactory.interpolationString("'a", "a"); 1629 var ae = AstFactory.interpolationString("'a", "a");
1630 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); 1630 var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
1631 var cElement = new InterpolationString(cToken, 'ccc'); 1631 var cElement = new InterpolationString(cToken, 'ccc');
1632 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1632 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1633 expect(node.contentsOffset, 1); 1633 expect(node.contentsOffset, 1);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 // ''' 1743 // '''
1744 { 1744 {
1745 var a = AstFactory.interpolationString("'''a", "a"); 1745 var a = AstFactory.interpolationString("'''a", "a");
1746 var c = AstFactory.interpolationString("ccc'''", "ccc"); 1746 var c = AstFactory.interpolationString("ccc'''", "ccc");
1747 StringInterpolation node = AstFactory.string([a, b, c]); 1747 StringInterpolation node = AstFactory.string([a, b, c]);
1748 expect(node.isSingleQuoted, isTrue); 1748 expect(node.isSingleQuoted, isTrue);
1749 } 1749 }
1750 } 1750 }
1751 } 1751 }
1752 1752
1753 @ReflectiveTestCase() 1753 @reflectiveTest
1754 class ToSourceVisitorTest extends EngineTestCase { 1754 class ToSourceVisitorTest extends EngineTestCase {
1755 void test_visitAdjacentStrings() { 1755 void test_visitAdjacentStrings() {
1756 _assertSource( 1756 _assertSource(
1757 "'a' 'b'", 1757 "'a' 'b'",
1758 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2( "b")])); 1758 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2( "b")]));
1759 } 1759 }
1760 1760
1761 void test_visitAnnotation_constant() { 1761 void test_visitAnnotation_constant() {
1762 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); 1762 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A")));
1763 } 1763 }
(...skipping 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4037 * @param node the AST node being visited to produce the actual source 4037 * @param node the AST node being visited to produce the actual source
4038 * @throws AFE if the visitor does not produce the expected source for the giv en node 4038 * @throws AFE if the visitor does not produce the expected source for the giv en node
4039 */ 4039 */
4040 void _assertSource(String expectedSource, AstNode node) { 4040 void _assertSource(String expectedSource, AstNode node) {
4041 PrintStringWriter writer = new PrintStringWriter(); 4041 PrintStringWriter writer = new PrintStringWriter();
4042 node.accept(new ToSourceVisitor(writer)); 4042 node.accept(new ToSourceVisitor(writer));
4043 expect(writer.toString(), expectedSource); 4043 expect(writer.toString(), expectedSource);
4044 } 4044 }
4045 } 4045 }
4046 4046
4047 @ReflectiveTestCase() 4047 @reflectiveTest
4048 class VariableDeclarationTest extends ParserTestCase { 4048 class VariableDeclarationTest extends ParserTestCase {
4049 void test_getDocumentationComment_onGrandParent() { 4049 void test_getDocumentationComment_onGrandParent() {
4050 VariableDeclaration varDecl = AstFactory.variableDeclaration("a"); 4050 VariableDeclaration varDecl = AstFactory.variableDeclaration("a");
4051 TopLevelVariableDeclaration decl = 4051 TopLevelVariableDeclaration decl =
4052 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]); 4052 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]);
4053 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 4053 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
4054 expect(varDecl.documentationComment, isNull); 4054 expect(varDecl.documentationComment, isNull);
4055 decl.documentationComment = comment; 4055 decl.documentationComment = comment;
4056 expect(varDecl.documentationComment, isNotNull); 4056 expect(varDecl.documentationComment, isNotNull);
4057 expect(decl.documentationComment, isNotNull); 4057 expect(decl.documentationComment, isNotNull);
(...skipping 24 matching lines...) Expand all
4082 4082
4083 static const List<WrapperKind> values = const [ 4083 static const List<WrapperKind> values = const [
4084 PREFIXED_LEFT, 4084 PREFIXED_LEFT,
4085 PREFIXED_RIGHT, 4085 PREFIXED_RIGHT,
4086 PROPERTY_LEFT, 4086 PROPERTY_LEFT,
4087 PROPERTY_RIGHT, 4087 PROPERTY_RIGHT,
4088 NONE]; 4088 NONE];
4089 4089
4090 const WrapperKind(String name, int ordinal) : super(name, ordinal); 4090 const WrapperKind(String name, int ordinal) : super(name, ordinal);
4091 } 4091 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698