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

Side by Side Diff: pkg/analyzer/test/generated/ast_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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/incremental_scanner_test.dart » ('j') | 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 // 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 class BreadthFirstVisitorTest extends ParserTestCase { 99 class BreadthFirstVisitorTest extends ParserTestCase {
99 void test_it() { 100 void test_it() {
100 String source = r''' 101 String source = r'''
101 class A { 102 class A {
102 bool get g => true; 103 bool get g => true;
103 } 104 }
104 class B { 105 class B {
105 int f() { 106 int f() {
106 num q() { 107 num q() {
107 return 3; 108 return 3;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 FunctionDeclarationStatement, 140 FunctionDeclarationStatement,
140 nodes[27]); 141 nodes[27]);
141 EngineTestCase.assertInstanceOf( 142 EngineTestCase.assertInstanceOf(
142 (obj) => obj is IntegerLiteral, 143 (obj) => obj is IntegerLiteral,
143 IntegerLiteral, 144 IntegerLiteral,
144 nodes[58]); 145 nodes[58]);
145 //3 146 //3
146 } 147 }
147 } 148 }
148 149
150 @ReflectiveTestCase()
149 class ClassDeclarationTest extends ParserTestCase { 151 class ClassDeclarationTest extends ParserTestCase {
150 void test_getConstructor() { 152 void test_getConstructor() {
151 List<ConstructorInitializer> initializers = 153 List<ConstructorInitializer> initializers =
152 new List<ConstructorInitializer>(); 154 new List<ConstructorInitializer>();
153 ConstructorDeclaration defaultConstructor = 155 ConstructorDeclaration defaultConstructor =
154 AstFactory.constructorDeclaration( 156 AstFactory.constructorDeclaration(
155 AstFactory.identifier3("Test"), 157 AstFactory.identifier3("Test"),
156 null, 158 null,
157 AstFactory.formalParameterList(), 159 AstFactory.formalParameterList(),
158 initializers); 160 initializers);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Keyword.ABSTRACT, 239 Keyword.ABSTRACT,
238 "B", 240 "B",
239 null, 241 null,
240 null, 242 null,
241 null, 243 null,
242 null).isAbstract, 244 null).isAbstract,
243 isTrue); 245 isTrue);
244 } 246 }
245 } 247 }
246 248
249 @ReflectiveTestCase()
247 class ClassTypeAliasTest extends ParserTestCase { 250 class ClassTypeAliasTest extends ParserTestCase {
248 void test_isAbstract() { 251 void test_isAbstract() {
249 expect( 252 expect(
250 AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract, 253 AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract,
251 isFalse); 254 isFalse);
252 expect( 255 expect(
253 AstFactory.classTypeAlias( 256 AstFactory.classTypeAlias(
254 "B", 257 "B",
255 null, 258 null,
256 Keyword.ABSTRACT, 259 Keyword.ABSTRACT,
257 null, 260 null,
258 null, 261 null,
259 null).isAbstract, 262 null).isAbstract,
260 isTrue); 263 isTrue);
261 } 264 }
262 } 265 }
263 266
267 @ReflectiveTestCase()
264 class ConstantEvaluatorTest extends ParserTestCase { 268 class ConstantEvaluatorTest extends ParserTestCase {
265 void fail_constructor() { 269 void fail_constructor() {
266 Object value = _getConstantValue("?"); 270 Object value = _getConstantValue("?");
267 expect(value, null); 271 expect(value, null);
268 } 272 }
269 273
270 void fail_identifier_class() { 274 void fail_identifier_class() {
271 Object value = _getConstantValue("?"); 275 Object value = _getConstantValue("?");
272 expect(value, null); 276 expect(value, null);
273 } 277 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 void test_unary_negated_integer() { 575 void test_unary_negated_integer() {
572 Object value = _getConstantValue("-42"); 576 Object value = _getConstantValue("-42");
573 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 577 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
574 expect(value as int, -42); 578 expect(value as int, -42);
575 } 579 }
576 580
577 Object _getConstantValue(String source) => 581 Object _getConstantValue(String source) =>
578 ParserTestCase.parseExpression(source).accept(new ConstantEvaluator()); 582 ParserTestCase.parseExpression(source).accept(new ConstantEvaluator());
579 } 583 }
580 584
585 @ReflectiveTestCase()
581 class ConstructorDeclarationTest extends EngineTestCase { 586 class ConstructorDeclarationTest extends EngineTestCase {
582 void test_firstTokenAfterCommentAndMetadata_all_inverted() { 587 void test_firstTokenAfterCommentAndMetadata_all_inverted() {
583 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 588 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
584 externalKeyword.offset = 14; 589 externalKeyword.offset = 14;
585 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 590 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2(
586 Keyword.CONST, 591 Keyword.CONST,
587 Keyword.FACTORY, 592 Keyword.FACTORY,
588 AstFactory.identifier3('int'), 593 AstFactory.identifier3('int'),
589 null, 594 null,
590 null, 595 null,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 null, 655 null,
651 null, 656 null,
652 null, 657 null,
653 null); 658 null);
654 expect( 659 expect(
655 declaration.firstTokenAfterCommentAndMetadata, 660 declaration.firstTokenAfterCommentAndMetadata,
656 declaration.factoryKeyword); 661 declaration.factoryKeyword);
657 } 662 }
658 } 663 }
659 664
665 @ReflectiveTestCase()
660 class IndexExpressionTest extends EngineTestCase { 666 class IndexExpressionTest extends EngineTestCase {
661 void test_inGetterContext_assignment_compound_left() { 667 void test_inGetterContext_assignment_compound_left() {
662 IndexExpression expression = AstFactory.indexExpression( 668 IndexExpression expression = AstFactory.indexExpression(
663 AstFactory.identifier3("a"), 669 AstFactory.identifier3("a"),
664 AstFactory.identifier3("b")); 670 AstFactory.identifier3("b"));
665 // a[b] += c 671 // a[b] += c
666 AstFactory.assignmentExpression( 672 AstFactory.assignmentExpression(
667 expression, 673 expression,
668 TokenType.PLUS_EQ, 674 TokenType.PLUS_EQ,
669 AstFactory.identifier3("c")); 675 AstFactory.identifier3("c"));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 void test_inSetterContext_prefix_plusPlus() { 790 void test_inSetterContext_prefix_plusPlus() {
785 IndexExpression expression = AstFactory.indexExpression( 791 IndexExpression expression = AstFactory.indexExpression(
786 AstFactory.identifier3("a"), 792 AstFactory.identifier3("a"),
787 AstFactory.identifier3("b")); 793 AstFactory.identifier3("b"));
788 // ++a[b] 794 // ++a[b]
789 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); 795 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression);
790 expect(expression.inSetterContext(), isTrue); 796 expect(expression.inSetterContext(), isTrue);
791 } 797 }
792 } 798 }
793 799
800 @ReflectiveTestCase()
794 class NodeListTest extends EngineTestCase { 801 class NodeListTest extends EngineTestCase {
795 void test_add() { 802 void test_add() {
796 AstNode parent = AstFactory.argumentList(); 803 AstNode parent = AstFactory.argumentList();
797 AstNode firstNode = AstFactory.booleanLiteral(true); 804 AstNode firstNode = AstFactory.booleanLiteral(true);
798 AstNode secondNode = AstFactory.booleanLiteral(false); 805 AstNode secondNode = AstFactory.booleanLiteral(false);
799 NodeList<AstNode> list = new NodeList<AstNode>(parent); 806 NodeList<AstNode> list = new NodeList<AstNode>(parent);
800 list.insert(0, secondNode); 807 list.insert(0, secondNode);
801 list.insert(0, firstNode); 808 list.insert(0, firstNode);
802 expect(list, hasLength(2)); 809 expect(list, hasLength(2));
803 expect(list[0], same(firstNode)); 810 expect(list[0], same(firstNode));
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 1018 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList());
1012 try { 1019 try {
1013 javaListSet(list, 1, node); 1020 javaListSet(list, 1, node);
1014 fail("Expected IndexOutOfBoundsException"); 1021 fail("Expected IndexOutOfBoundsException");
1015 } on RangeError catch (exception) { 1022 } on RangeError catch (exception) {
1016 // Expected 1023 // Expected
1017 } 1024 }
1018 } 1025 }
1019 } 1026 }
1020 1027
1028 @ReflectiveTestCase()
1021 class NodeLocatorTest extends ParserTestCase { 1029 class NodeLocatorTest extends ParserTestCase {
1022 void test_range() { 1030 void test_range() {
1023 CompilationUnit unit = 1031 CompilationUnit unit =
1024 ParserTestCase.parseCompilationUnit("library myLib;"); 1032 ParserTestCase.parseCompilationUnit("library myLib;");
1025 _assertLocate( 1033 _assertLocate(
1026 unit, 1034 unit,
1027 4, 1035 4,
1028 10, 1036 10,
1029 (node) => node is LibraryDirective, 1037 (node) => node is LibraryDirective,
1030 LibraryDirective); 1038 LibraryDirective);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 expect(locator.foundNode, same(node)); 1080 expect(locator.foundNode, same(node));
1073 expect(node.offset <= start, isTrue, reason: "Node starts after range"); 1081 expect(node.offset <= start, isTrue, reason: "Node starts after range");
1074 expect( 1082 expect(
1075 node.offset + node.length > end, 1083 node.offset + node.length > end,
1076 isTrue, 1084 isTrue,
1077 reason: "Node ends before range"); 1085 reason: "Node ends before range");
1078 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); 1086 EngineTestCase.assertInstanceOf(predicate, expectedClass, node);
1079 } 1087 }
1080 } 1088 }
1081 1089
1090 @ReflectiveTestCase()
1082 class SimpleIdentifierTest extends ParserTestCase { 1091 class SimpleIdentifierTest extends ParserTestCase {
1083 void test_inDeclarationContext_catch_exception() { 1092 void test_inDeclarationContext_catch_exception() {
1084 SimpleIdentifier identifier = 1093 SimpleIdentifier identifier =
1085 AstFactory.catchClause("e").exceptionParameter; 1094 AstFactory.catchClause("e").exceptionParameter;
1086 expect(identifier.inDeclarationContext(), isTrue); 1095 expect(identifier.inDeclarationContext(), isTrue);
1087 } 1096 }
1088 1097
1089 void test_inDeclarationContext_catch_stack() { 1098 void test_inDeclarationContext_catch_stack() {
1090 SimpleIdentifier identifier = 1099 SimpleIdentifier identifier =
1091 AstFactory.catchClause2("e", "s").stackTraceParameter; 1100 AstFactory.catchClause2("e", "s").stackTraceParameter;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 AstNode child = identifier; 1399 AstNode child = identifier;
1391 AstNode parent = identifier.parent; 1400 AstNode parent = identifier.parent;
1392 while (parent != null) { 1401 while (parent != null) {
1393 child = parent; 1402 child = parent;
1394 parent = parent.parent; 1403 parent = parent.parent;
1395 } 1404 }
1396 return child; 1405 return child;
1397 } 1406 }
1398 } 1407 }
1399 1408
1409 @ReflectiveTestCase()
1400 class SimpleStringLiteralTest extends ParserTestCase { 1410 class SimpleStringLiteralTest extends ParserTestCase {
1401 void test_contentsEnd() { 1411 void test_contentsEnd() {
1402 expect( 1412 expect(
1403 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").conten tsEnd, 1413 new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").conten tsEnd,
1404 2); 1414 2);
1405 expect( 1415 expect(
1406 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").cont entsEnd, 1416 new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").cont entsEnd,
1407 2); 1417 2);
1408 expect( 1418 expect(
1409 new SimpleStringLiteral( 1419 new SimpleStringLiteral(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 void test_simple() { 1613 void test_simple() {
1604 Token token = TokenFactory.tokenFromString("'value'"); 1614 Token token = TokenFactory.tokenFromString("'value'");
1605 SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value"); 1615 SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value");
1606 expect(stringLiteral.literal, same(token)); 1616 expect(stringLiteral.literal, same(token));
1607 expect(stringLiteral.beginToken, same(token)); 1617 expect(stringLiteral.beginToken, same(token));
1608 expect(stringLiteral.endToken, same(token)); 1618 expect(stringLiteral.endToken, same(token));
1609 expect(stringLiteral.value, "value"); 1619 expect(stringLiteral.value, "value");
1610 } 1620 }
1611 } 1621 }
1612 1622
1623 @ReflectiveTestCase()
1613 class StringInterpolationTest extends ParserTestCase { 1624 class StringInterpolationTest extends ParserTestCase {
1614 void test_contentsOffsetEnd() { 1625 void test_contentsOffsetEnd() {
1615 AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1626 AstFactory.interpolationExpression(AstFactory.identifier3('bb'));
1616 // 'a${bb}ccc' 1627 // 'a${bb}ccc'
1617 { 1628 {
1618 var ae = AstFactory.interpolationString("'a", "a"); 1629 var ae = AstFactory.interpolationString("'a", "a");
1619 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); 1630 var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
1620 var cElement = new InterpolationString(cToken, 'ccc'); 1631 var cElement = new InterpolationString(cToken, 'ccc');
1621 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1632 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1622 expect(node.contentsOffset, 1); 1633 expect(node.contentsOffset, 1);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 // ''' 1743 // '''
1733 { 1744 {
1734 var a = AstFactory.interpolationString("'''a", "a"); 1745 var a = AstFactory.interpolationString("'''a", "a");
1735 var c = AstFactory.interpolationString("ccc'''", "ccc"); 1746 var c = AstFactory.interpolationString("ccc'''", "ccc");
1736 StringInterpolation node = AstFactory.string([a, b, c]); 1747 StringInterpolation node = AstFactory.string([a, b, c]);
1737 expect(node.isSingleQuoted, isTrue); 1748 expect(node.isSingleQuoted, isTrue);
1738 } 1749 }
1739 } 1750 }
1740 } 1751 }
1741 1752
1753 @ReflectiveTestCase()
1742 class ToSourceVisitorTest extends EngineTestCase { 1754 class ToSourceVisitorTest extends EngineTestCase {
1743 void test_visitAdjacentStrings() { 1755 void test_visitAdjacentStrings() {
1744 _assertSource( 1756 _assertSource(
1745 "'a' 'b'", 1757 "'a' 'b'",
1746 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2( "b")])); 1758 AstFactory.adjacentStrings([AstFactory.string2("a"), AstFactory.string2( "b")]));
1747 } 1759 }
1748 1760
1749 void test_visitAnnotation_constant() { 1761 void test_visitAnnotation_constant() {
1750 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); 1762 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A")));
1751 } 1763 }
(...skipping 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 * @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
4026 * @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
4027 */ 4039 */
4028 void _assertSource(String expectedSource, AstNode node) { 4040 void _assertSource(String expectedSource, AstNode node) {
4029 PrintStringWriter writer = new PrintStringWriter(); 4041 PrintStringWriter writer = new PrintStringWriter();
4030 node.accept(new ToSourceVisitor(writer)); 4042 node.accept(new ToSourceVisitor(writer));
4031 expect(writer.toString(), expectedSource); 4043 expect(writer.toString(), expectedSource);
4032 } 4044 }
4033 } 4045 }
4034 4046
4047 @ReflectiveTestCase()
4035 class VariableDeclarationTest extends ParserTestCase { 4048 class VariableDeclarationTest extends ParserTestCase {
4036 void test_getDocumentationComment_onGrandParent() { 4049 void test_getDocumentationComment_onGrandParent() {
4037 VariableDeclaration varDecl = AstFactory.variableDeclaration("a"); 4050 VariableDeclaration varDecl = AstFactory.variableDeclaration("a");
4038 TopLevelVariableDeclaration decl = 4051 TopLevelVariableDeclaration decl =
4039 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]); 4052 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]);
4040 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 4053 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
4041 expect(varDecl.documentationComment, isNull); 4054 expect(varDecl.documentationComment, isNull);
4042 decl.documentationComment = comment; 4055 decl.documentationComment = comment;
4043 expect(varDecl.documentationComment, isNotNull); 4056 expect(varDecl.documentationComment, isNotNull);
4044 expect(decl.documentationComment, isNotNull); 4057 expect(decl.documentationComment, isNotNull);
(...skipping 24 matching lines...) Expand all
4069 4082
4070 static const List<WrapperKind> values = const [ 4083 static const List<WrapperKind> values = const [
4071 PREFIXED_LEFT, 4084 PREFIXED_LEFT,
4072 PREFIXED_RIGHT, 4085 PREFIXED_RIGHT,
4073 PROPERTY_LEFT, 4086 PROPERTY_LEFT,
4074 PROPERTY_RIGHT, 4087 PROPERTY_RIGHT,
4075 NONE]; 4088 NONE];
4076 4089
4077 const WrapperKind(String name, int ordinal) : super(name, ordinal); 4090 const WrapperKind(String name, int ordinal) : super(name, ordinal);
4078 } 4091 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/incremental_scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698