OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 library engine.ast_test; | 3 library engine.ast_test; |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; | 6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; |
7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
8 import 'package:analyzer_experimental/src/generated/source.dart'; | 8 import 'package:analyzer_experimental/src/generated/source.dart'; |
9 import 'package:analyzer_experimental/src/generated/error.dart'; | 9 import 'package:analyzer_experimental/src/generated/error.dart'; |
10 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 10 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 final __test = new IndexExpressionTest(); | 175 final __test = new IndexExpressionTest(); |
176 runJUnitTest(__test, __test.test_inSetterContext_prefix_minusMinus); | 176 runJUnitTest(__test, __test.test_inSetterContext_prefix_minusMinus); |
177 }); | 177 }); |
178 _ut.test('test_inSetterContext_prefix_plusPlus', () { | 178 _ut.test('test_inSetterContext_prefix_plusPlus', () { |
179 final __test = new IndexExpressionTest(); | 179 final __test = new IndexExpressionTest(); |
180 runJUnitTest(__test, __test.test_inSetterContext_prefix_plusPlus); | 180 runJUnitTest(__test, __test.test_inSetterContext_prefix_plusPlus); |
181 }); | 181 }); |
182 }); | 182 }); |
183 } | 183 } |
184 } | 184 } |
| 185 class VariableDeclarationTest extends ParserTestCase { |
| 186 void test_getDocumentationComment_onGrandParent() { |
| 187 VariableDeclaration varDecl = ASTFactory.variableDeclaration("a"); |
| 188 TopLevelVariableDeclaration decl = ASTFactory.topLevelVariableDeclaration2(K
eyword.VAR, [varDecl]); |
| 189 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 190 JUnitTestCase.assertNull(varDecl.documentationComment); |
| 191 decl.documentationComment = comment; |
| 192 JUnitTestCase.assertNotNull(varDecl.documentationComment); |
| 193 JUnitTestCase.assertNotNull(decl.documentationComment); |
| 194 } |
| 195 void test_getDocumentationComment_onNode() { |
| 196 VariableDeclaration decl = ASTFactory.variableDeclaration("a"); |
| 197 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); |
| 198 decl.documentationComment = comment; |
| 199 JUnitTestCase.assertNotNull(decl.documentationComment); |
| 200 } |
| 201 static dartSuite() { |
| 202 _ut.group('VariableDeclarationTest', () { |
| 203 _ut.test('test_getDocumentationComment_onGrandParent', () { |
| 204 final __test = new VariableDeclarationTest(); |
| 205 runJUnitTest(__test, __test.test_getDocumentationComment_onGrandParent); |
| 206 }); |
| 207 _ut.test('test_getDocumentationComment_onNode', () { |
| 208 final __test = new VariableDeclarationTest(); |
| 209 runJUnitTest(__test, __test.test_getDocumentationComment_onNode); |
| 210 }); |
| 211 }); |
| 212 } |
| 213 } |
185 /** | 214 /** |
186 * The class {@code ASTFactory} defines utility methods that can be used to crea
te AST nodes. The | 215 * The class {@code ASTFactory} defines utility methods that can be used to crea
te AST nodes. The |
187 * nodes that are created are complete in the sense that all of the tokens that
would have been | 216 * nodes that are created are complete in the sense that all of the tokens that
would have been |
188 * associated with the nodes by a parser are also created, but the token stream
is not constructed. | 217 * associated with the nodes by a parser are also created, but the token stream
is not constructed. |
189 * None of the nodes are resolved. | 218 * None of the nodes are resolved. |
190 * <p> | 219 * <p> |
191 * The general pattern is for the name of the factory method to be the same as t
he name of the class | 220 * The general pattern is for the name of the factory method to be the same as t
he name of the class |
192 * of AST node being created. There are two notable exceptions. The first is for
methods creating | 221 * of AST node being created. There are two notable exceptions. The first is for
methods creating |
193 * nodes that are part of a cascade expression. These methods are all prefixed w
ith 'cascaded'. The | 222 * nodes that are part of a cascade expression. These methods are all prefixed w
ith 'cascaded'. The |
194 * second is places where a shorter name seemed unambiguous and easier to read,
such as using | 223 * second is places where a shorter name seemed unambiguous and easier to read,
such as using |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 static final List<AssignmentKind> values = [BINARY, COMPOUND_LEFT, COMPOUND_RI
GHT, POSTFIX_INC, PREFIX_DEC, PREFIX_INC, PREFIX_NOT, SIMPLE_LEFT, SIMPLE_RIGHT,
NONE]; | 701 static final List<AssignmentKind> values = [BINARY, COMPOUND_LEFT, COMPOUND_RI
GHT, POSTFIX_INC, PREFIX_DEC, PREFIX_INC, PREFIX_NOT, SIMPLE_LEFT, SIMPLE_RIGHT,
NONE]; |
673 | 702 |
674 /// The name of this enum constant, as declared in the enum declaration. | 703 /// The name of this enum constant, as declared in the enum declaration. |
675 final String name; | 704 final String name; |
676 | 705 |
677 /// The position in the enum declaration. | 706 /// The position in the enum declaration. |
678 final int ordinal; | 707 final int ordinal; |
679 AssignmentKind(this.name, this.ordinal) { | 708 AssignmentKind(this.name, this.ordinal) { |
680 } | 709 } |
681 int compareTo(AssignmentKind other) => ordinal - other.ordinal; | 710 int compareTo(AssignmentKind other) => ordinal - other.ordinal; |
| 711 int get hashCode => ordinal; |
682 String toString() => name; | 712 String toString() => name; |
683 } | 713 } |
684 class WrapperKind implements Comparable<WrapperKind> { | 714 class WrapperKind implements Comparable<WrapperKind> { |
685 static final WrapperKind PREFIXED_LEFT = new WrapperKind('PREFIXED_LEFT', 0); | 715 static final WrapperKind PREFIXED_LEFT = new WrapperKind('PREFIXED_LEFT', 0); |
686 static final WrapperKind PREFIXED_RIGHT = new WrapperKind('PREFIXED_RIGHT', 1)
; | 716 static final WrapperKind PREFIXED_RIGHT = new WrapperKind('PREFIXED_RIGHT', 1)
; |
687 static final WrapperKind PROPERTY_LEFT = new WrapperKind('PROPERTY_LEFT', 2); | 717 static final WrapperKind PROPERTY_LEFT = new WrapperKind('PROPERTY_LEFT', 2); |
688 static final WrapperKind PROPERTY_RIGHT = new WrapperKind('PROPERTY_RIGHT', 3)
; | 718 static final WrapperKind PROPERTY_RIGHT = new WrapperKind('PROPERTY_RIGHT', 3)
; |
689 static final WrapperKind NONE = new WrapperKind('NONE', 4); | 719 static final WrapperKind NONE = new WrapperKind('NONE', 4); |
690 static final List<WrapperKind> values = [PREFIXED_LEFT, PREFIXED_RIGHT, PROPER
TY_LEFT, PROPERTY_RIGHT, NONE]; | 720 static final List<WrapperKind> values = [PREFIXED_LEFT, PREFIXED_RIGHT, PROPER
TY_LEFT, PROPERTY_RIGHT, NONE]; |
691 | 721 |
692 /// The name of this enum constant, as declared in the enum declaration. | 722 /// The name of this enum constant, as declared in the enum declaration. |
693 final String name; | 723 final String name; |
694 | 724 |
695 /// The position in the enum declaration. | 725 /// The position in the enum declaration. |
696 final int ordinal; | 726 final int ordinal; |
697 WrapperKind(this.name, this.ordinal) { | 727 WrapperKind(this.name, this.ordinal) { |
698 } | 728 } |
699 int compareTo(WrapperKind other) => ordinal - other.ordinal; | 729 int compareTo(WrapperKind other) => ordinal - other.ordinal; |
| 730 int get hashCode => ordinal; |
700 String toString() => name; | 731 String toString() => name; |
701 } | 732 } |
702 class BreadthFirstVisitorTest extends ParserTestCase { | 733 class BreadthFirstVisitorTest extends ParserTestCase { |
703 void testIt() { | 734 void testIt() { |
704 String source = EngineTestCase.createSource(["class A {", " bool get g => t
rue;", "}", "class B {", " int f() {", " num q() {", " return 3;", "
}", " return q() + 4;", " }", "}", "A f(var p) {", " if ((p as A).g) {", "
return p;", " } else {", " return null;", " }", "}"]); | 735 String source = EngineTestCase.createSource(["class A {", " bool get g => t
rue;", "}", "class B {", " int f() {", " num q() {", " return 3;", "
}", " return q() + 4;", " }", "}", "A f(var p) {", " if ((p as A).g) {", "
return p;", " } else {", " return null;", " }", "}"]); |
705 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []); | 736 CompilationUnit unit = ParserTestCase.parseCompilationUnit(source, []); |
706 List<ASTNode> nodes = new List<ASTNode>(); | 737 List<ASTNode> nodes = new List<ASTNode>(); |
707 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_15(nodes); | 738 BreadthFirstVisitor<Object> visitor = new BreadthFirstVisitor_15(nodes); |
708 visitor.visitAllNodes(unit); | 739 visitor.visitAllNodes(unit); |
709 EngineTestCase.assertSize(59, nodes); | 740 EngineTestCase.assertSize(59, nodes); |
(...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 }); | 2934 }); |
2904 } | 2935 } |
2905 } | 2936 } |
2906 main() { | 2937 main() { |
2907 ConstantEvaluatorTest.dartSuite(); | 2938 ConstantEvaluatorTest.dartSuite(); |
2908 NodeLocatorTest.dartSuite(); | 2939 NodeLocatorTest.dartSuite(); |
2909 ToSourceVisitorTest.dartSuite(); | 2940 ToSourceVisitorTest.dartSuite(); |
2910 BreadthFirstVisitorTest.dartSuite(); | 2941 BreadthFirstVisitorTest.dartSuite(); |
2911 IndexExpressionTest.dartSuite(); | 2942 IndexExpressionTest.dartSuite(); |
2912 SimpleIdentifierTest.dartSuite(); | 2943 SimpleIdentifierTest.dartSuite(); |
| 2944 VariableDeclarationTest.dartSuite(); |
2913 } | 2945 } |
OLD | NEW |