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

Side by Side Diff: pkg/analyzer/test/dart/ast/ast_test.dart

Issue 2524903002: Rename AstFactory -> AstTestFactory. (Closed)
Patch Set: Created 4 years, 1 month 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
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 analyzer.test.dart.ast.ast_test; 5 library analyzer.test.dart.ast.ast_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/src/dart/ast/token.dart'; 9 import 'package:analyzer/src/dart/ast/token.dart';
10 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 10 import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
11 import 'package:analyzer/src/generated/testing/token_factory.dart'; 11 import 'package:analyzer/src/generated/testing/token_factory.dart';
12 import 'package:test/test.dart'; 12 import 'package:test/test.dart';
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; 13 import 'package:test_reflective_loader/test_reflective_loader.dart';
14 14
15 import '../../generated/parser_test.dart' show ParserTestCase; 15 import '../../generated/parser_test.dart' show ParserTestCase;
16 import '../../generated/test_support.dart'; 16 import '../../generated/test_support.dart';
17 17
18 main() { 18 main() {
19 defineReflectiveSuite(() { 19 defineReflectiveSuite(() {
20 defineReflectiveTests(ClassDeclarationTest); 20 defineReflectiveTests(ClassDeclarationTest);
21 defineReflectiveTests(ClassTypeAliasTest); 21 defineReflectiveTests(ClassTypeAliasTest);
22 defineReflectiveTests(ConstructorDeclarationTest); 22 defineReflectiveTests(ConstructorDeclarationTest);
23 defineReflectiveTests(FieldFormalParameterTest); 23 defineReflectiveTests(FieldFormalParameterTest);
24 defineReflectiveTests(IndexExpressionTest); 24 defineReflectiveTests(IndexExpressionTest);
25 defineReflectiveTests(MethodDeclarationTest); 25 defineReflectiveTests(MethodDeclarationTest);
26 defineReflectiveTests(NodeListTest); 26 defineReflectiveTests(NodeListTest);
27 defineReflectiveTests(SimpleIdentifierTest); 27 defineReflectiveTests(SimpleIdentifierTest);
28 defineReflectiveTests(SimpleStringLiteralTest); 28 defineReflectiveTests(SimpleStringLiteralTest);
29 defineReflectiveTests(StringInterpolationTest); 29 defineReflectiveTests(StringInterpolationTest);
30 defineReflectiveTests(VariableDeclarationTest); 30 defineReflectiveTests(VariableDeclarationTest);
31 }); 31 });
32 } 32 }
33 33
34 @reflectiveTest 34 @reflectiveTest
35 class ClassDeclarationTest extends ParserTestCase { 35 class ClassDeclarationTest extends ParserTestCase {
36 void test_getConstructor() { 36 void test_getConstructor() {
37 List<ConstructorInitializer> initializers = 37 List<ConstructorInitializer> initializers =
38 new List<ConstructorInitializer>(); 38 new List<ConstructorInitializer>();
39 ConstructorDeclaration defaultConstructor = 39 ConstructorDeclaration defaultConstructor =
40 AstFactory.constructorDeclaration(AstFactory.identifier3("Test"), null, 40 AstTestFactory.constructorDeclaration(
41 AstFactory.formalParameterList(), initializers); 41 AstTestFactory.identifier3("Test"),
42 ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration( 42 null,
43 AstFactory.identifier3("Test"), 43 AstTestFactory.formalParameterList(),
44 initializers);
45 ConstructorDeclaration aConstructor = AstTestFactory.constructorDeclaration(
46 AstTestFactory.identifier3("Test"),
44 "a", 47 "a",
45 AstFactory.formalParameterList(), 48 AstTestFactory.formalParameterList(),
46 initializers); 49 initializers);
47 ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration( 50 ConstructorDeclaration bConstructor = AstTestFactory.constructorDeclaration(
48 AstFactory.identifier3("Test"), 51 AstTestFactory.identifier3("Test"),
49 "b", 52 "b",
50 AstFactory.formalParameterList(), 53 AstTestFactory.formalParameterList(),
51 initializers); 54 initializers);
52 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, 55 ClassDeclaration clazz = AstTestFactory.classDeclaration(null, "Test", null,
53 null, null, null, [defaultConstructor, aConstructor, bConstructor]); 56 null, null, null, [defaultConstructor, aConstructor, bConstructor]);
54 expect(clazz.getConstructor(null), same(defaultConstructor)); 57 expect(clazz.getConstructor(null), same(defaultConstructor));
55 expect(clazz.getConstructor("a"), same(aConstructor)); 58 expect(clazz.getConstructor("a"), same(aConstructor));
56 expect(clazz.getConstructor("b"), same(bConstructor)); 59 expect(clazz.getConstructor("b"), same(bConstructor));
57 expect(clazz.getConstructor("noSuchConstructor"), same(null)); 60 expect(clazz.getConstructor("noSuchConstructor"), same(null));
58 } 61 }
59 62
60 void test_getField() { 63 void test_getField() {
61 VariableDeclaration aVar = AstFactory.variableDeclaration("a"); 64 VariableDeclaration aVar = AstTestFactory.variableDeclaration("a");
62 VariableDeclaration bVar = AstFactory.variableDeclaration("b"); 65 VariableDeclaration bVar = AstTestFactory.variableDeclaration("b");
63 VariableDeclaration cVar = AstFactory.variableDeclaration("c"); 66 VariableDeclaration cVar = AstTestFactory.variableDeclaration("c");
64 ClassDeclaration clazz = 67 ClassDeclaration clazz =
65 AstFactory.classDeclaration(null, "Test", null, null, null, null, [ 68 AstTestFactory.classDeclaration(null, "Test", null, null, null, null, [
66 AstFactory.fieldDeclaration2(false, null, [aVar]), 69 AstTestFactory.fieldDeclaration2(false, null, [aVar]),
67 AstFactory.fieldDeclaration2(false, null, [bVar, cVar]) 70 AstTestFactory.fieldDeclaration2(false, null, [bVar, cVar])
68 ]); 71 ]);
69 expect(clazz.getField("a"), same(aVar)); 72 expect(clazz.getField("a"), same(aVar));
70 expect(clazz.getField("b"), same(bVar)); 73 expect(clazz.getField("b"), same(bVar));
71 expect(clazz.getField("c"), same(cVar)); 74 expect(clazz.getField("c"), same(cVar));
72 expect(clazz.getField("noSuchField"), same(null)); 75 expect(clazz.getField("noSuchField"), same(null));
73 } 76 }
74 77
75 void test_getMethod() { 78 void test_getMethod() {
76 MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null, 79 MethodDeclaration aMethod = AstTestFactory.methodDeclaration(
77 null, AstFactory.identifier3("a"), AstFactory.formalParameterList()); 80 null,
78 MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null, 81 null,
79 null, AstFactory.identifier3("b"), AstFactory.formalParameterList()); 82 null,
80 ClassDeclaration clazz = AstFactory.classDeclaration( 83 null,
84 AstTestFactory.identifier3("a"),
85 AstTestFactory.formalParameterList());
86 MethodDeclaration bMethod = AstTestFactory.methodDeclaration(
87 null,
88 null,
89 null,
90 null,
91 AstTestFactory.identifier3("b"),
92 AstTestFactory.formalParameterList());
93 ClassDeclaration clazz = AstTestFactory.classDeclaration(
81 null, "Test", null, null, null, null, [aMethod, bMethod]); 94 null, "Test", null, null, null, null, [aMethod, bMethod]);
82 expect(clazz.getMethod("a"), same(aMethod)); 95 expect(clazz.getMethod("a"), same(aMethod));
83 expect(clazz.getMethod("b"), same(bMethod)); 96 expect(clazz.getMethod("b"), same(bMethod));
84 expect(clazz.getMethod("noSuchMethod"), same(null)); 97 expect(clazz.getMethod("noSuchMethod"), same(null));
85 } 98 }
86 99
87 void test_isAbstract() { 100 void test_isAbstract() {
88 expect( 101 expect(
89 AstFactory 102 AstTestFactory
90 .classDeclaration(null, "A", null, null, null, null) 103 .classDeclaration(null, "A", null, null, null, null)
91 .isAbstract, 104 .isAbstract,
92 isFalse); 105 isFalse);
93 expect( 106 expect(
94 AstFactory 107 AstTestFactory
95 .classDeclaration(Keyword.ABSTRACT, "B", null, null, null, null) 108 .classDeclaration(Keyword.ABSTRACT, "B", null, null, null, null)
96 .isAbstract, 109 .isAbstract,
97 isTrue); 110 isTrue);
98 } 111 }
99 } 112 }
100 113
101 @reflectiveTest 114 @reflectiveTest
102 class ClassTypeAliasTest extends ParserTestCase { 115 class ClassTypeAliasTest extends ParserTestCase {
103 void test_isAbstract() { 116 void test_isAbstract() {
104 expect( 117 expect(
105 AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstract, 118 AstTestFactory
119 .classTypeAlias("A", null, null, null, null, null)
120 .isAbstract,
106 isFalse); 121 isFalse);
107 expect( 122 expect(
108 AstFactory 123 AstTestFactory
109 .classTypeAlias("B", null, Keyword.ABSTRACT, null, null, null) 124 .classTypeAlias("B", null, Keyword.ABSTRACT, null, null, null)
110 .isAbstract, 125 .isAbstract,
111 isTrue); 126 isTrue);
112 } 127 }
113 } 128 }
114 129
115 @reflectiveTest 130 @reflectiveTest
116 class ConstructorDeclarationTest extends EngineTestCase { 131 class ConstructorDeclarationTest extends EngineTestCase {
117 void test_firstTokenAfterCommentAndMetadata_all_inverted() { 132 void test_firstTokenAfterCommentAndMetadata_all_inverted() {
118 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 133 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
119 externalKeyword.offset = 14; 134 externalKeyword.offset = 14;
120 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 135 ConstructorDeclaration declaration = AstTestFactory.constructorDeclaration2(
121 Keyword.CONST, 136 Keyword.CONST,
122 Keyword.FACTORY, 137 Keyword.FACTORY,
123 AstFactory.identifier3('int'), 138 AstTestFactory.identifier3('int'),
124 null, 139 null,
125 null, 140 null,
126 null, 141 null,
127 null); 142 null);
128 declaration.externalKeyword = externalKeyword; 143 declaration.externalKeyword = externalKeyword;
129 declaration.constKeyword.offset = 8; 144 declaration.constKeyword.offset = 8;
130 Token factoryKeyword = declaration.factoryKeyword; 145 Token factoryKeyword = declaration.factoryKeyword;
131 factoryKeyword.offset = 0; 146 factoryKeyword.offset = 0;
132 expect(declaration.firstTokenAfterCommentAndMetadata, factoryKeyword); 147 expect(declaration.firstTokenAfterCommentAndMetadata, factoryKeyword);
133 } 148 }
134 149
135 void test_firstTokenAfterCommentAndMetadata_all_normal() { 150 void test_firstTokenAfterCommentAndMetadata_all_normal() {
136 Token token = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 151 Token token = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
137 token.offset = 0; 152 token.offset = 0;
138 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 153 ConstructorDeclaration declaration = AstTestFactory.constructorDeclaration2(
139 Keyword.CONST, 154 Keyword.CONST,
140 Keyword.FACTORY, 155 Keyword.FACTORY,
141 AstFactory.identifier3('int'), 156 AstTestFactory.identifier3('int'),
142 null, 157 null,
143 null, 158 null,
144 null, 159 null,
145 null); 160 null);
146 declaration.externalKeyword = token; 161 declaration.externalKeyword = token;
147 declaration.constKeyword.offset = 9; 162 declaration.constKeyword.offset = 9;
148 declaration.factoryKeyword.offset = 15; 163 declaration.factoryKeyword.offset = 15;
149 expect(declaration.firstTokenAfterCommentAndMetadata, token); 164 expect(declaration.firstTokenAfterCommentAndMetadata, token);
150 } 165 }
151 166
152 void test_firstTokenAfterCommentAndMetadata_constOnly() { 167 void test_firstTokenAfterCommentAndMetadata_constOnly() {
153 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 168 ConstructorDeclaration declaration = AstTestFactory.constructorDeclaration2(
154 Keyword.CONST, 169 Keyword.CONST,
155 null, 170 null,
156 AstFactory.identifier3('int'), 171 AstTestFactory.identifier3('int'),
157 null, 172 null,
158 null, 173 null,
159 null, 174 null,
160 null); 175 null);
161 expect(declaration.firstTokenAfterCommentAndMetadata, 176 expect(declaration.firstTokenAfterCommentAndMetadata,
162 declaration.constKeyword); 177 declaration.constKeyword);
163 } 178 }
164 179
165 void test_firstTokenAfterCommentAndMetadata_externalOnly() { 180 void test_firstTokenAfterCommentAndMetadata_externalOnly() {
166 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 181 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
167 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 182 ConstructorDeclaration declaration = AstTestFactory.constructorDeclaration2(
168 null, null, AstFactory.identifier3('int'), null, null, null, null); 183 null, null, AstTestFactory.identifier3('int'), null, null, null, null);
169 declaration.externalKeyword = externalKeyword; 184 declaration.externalKeyword = externalKeyword;
170 expect(declaration.firstTokenAfterCommentAndMetadata, externalKeyword); 185 expect(declaration.firstTokenAfterCommentAndMetadata, externalKeyword);
171 } 186 }
172 187
173 void test_firstTokenAfterCommentAndMetadata_factoryOnly() { 188 void test_firstTokenAfterCommentAndMetadata_factoryOnly() {
174 ConstructorDeclaration declaration = AstFactory.constructorDeclaration2( 189 ConstructorDeclaration declaration = AstTestFactory.constructorDeclaration2(
175 null, 190 null,
176 Keyword.FACTORY, 191 Keyword.FACTORY,
177 AstFactory.identifier3('int'), 192 AstTestFactory.identifier3('int'),
178 null, 193 null,
179 null, 194 null,
180 null, 195 null,
181 null); 196 null);
182 expect(declaration.firstTokenAfterCommentAndMetadata, 197 expect(declaration.firstTokenAfterCommentAndMetadata,
183 declaration.factoryKeyword); 198 declaration.factoryKeyword);
184 } 199 }
185 } 200 }
186 201
187 @reflectiveTest 202 @reflectiveTest
188 class FieldFormalParameterTest extends EngineTestCase { 203 class FieldFormalParameterTest extends EngineTestCase {
189 void test_endToken_noParameters() { 204 void test_endToken_noParameters() {
190 FieldFormalParameter parameter = AstFactory.fieldFormalParameter2('field'); 205 FieldFormalParameter parameter =
206 AstTestFactory.fieldFormalParameter2('field');
191 expect(parameter.endToken, parameter.identifier.endToken); 207 expect(parameter.endToken, parameter.identifier.endToken);
192 } 208 }
193 209
194 void test_endToken_parameters() { 210 void test_endToken_parameters() {
195 FieldFormalParameter parameter = AstFactory.fieldFormalParameter( 211 FieldFormalParameter parameter = AstTestFactory.fieldFormalParameter(
196 null, null, 'field', AstFactory.formalParameterList([])); 212 null, null, 'field', AstTestFactory.formalParameterList([]));
197 expect(parameter.endToken, parameter.parameters.endToken); 213 expect(parameter.endToken, parameter.parameters.endToken);
198 } 214 }
199 } 215 }
200 216
201 @reflectiveTest 217 @reflectiveTest
202 class IndexExpressionTest extends EngineTestCase { 218 class IndexExpressionTest extends EngineTestCase {
203 void test_inGetterContext_assignment_compound_left() { 219 void test_inGetterContext_assignment_compound_left() {
204 IndexExpression expression = AstFactory.indexExpression( 220 IndexExpression expression = AstTestFactory.indexExpression(
205 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 221 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
206 // a[b] += c 222 // a[b] += c
207 AstFactory.assignmentExpression( 223 AstTestFactory.assignmentExpression(
208 expression, TokenType.PLUS_EQ, AstFactory.identifier3("c")); 224 expression, TokenType.PLUS_EQ, AstTestFactory.identifier3("c"));
209 expect(expression.inGetterContext(), isTrue); 225 expect(expression.inGetterContext(), isTrue);
210 } 226 }
211 227
212 void test_inGetterContext_assignment_simple_left() { 228 void test_inGetterContext_assignment_simple_left() {
213 IndexExpression expression = AstFactory.indexExpression( 229 IndexExpression expression = AstTestFactory.indexExpression(
214 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 230 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
215 // a[b] = c 231 // a[b] = c
216 AstFactory.assignmentExpression( 232 AstTestFactory.assignmentExpression(
217 expression, TokenType.EQ, AstFactory.identifier3("c")); 233 expression, TokenType.EQ, AstTestFactory.identifier3("c"));
218 expect(expression.inGetterContext(), isFalse); 234 expect(expression.inGetterContext(), isFalse);
219 } 235 }
220 236
221 void test_inGetterContext_nonAssignment() { 237 void test_inGetterContext_nonAssignment() {
222 IndexExpression expression = AstFactory.indexExpression( 238 IndexExpression expression = AstTestFactory.indexExpression(
223 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 239 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
224 // a[b] + c 240 // a[b] + c
225 AstFactory.binaryExpression( 241 AstTestFactory.binaryExpression(
226 expression, TokenType.PLUS, AstFactory.identifier3("c")); 242 expression, TokenType.PLUS, AstTestFactory.identifier3("c"));
227 expect(expression.inGetterContext(), isTrue); 243 expect(expression.inGetterContext(), isTrue);
228 } 244 }
229 245
230 void test_inSetterContext_assignment_compound_left() { 246 void test_inSetterContext_assignment_compound_left() {
231 IndexExpression expression = AstFactory.indexExpression( 247 IndexExpression expression = AstTestFactory.indexExpression(
232 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 248 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
233 // a[b] += c 249 // a[b] += c
234 AstFactory.assignmentExpression( 250 AstTestFactory.assignmentExpression(
235 expression, TokenType.PLUS_EQ, AstFactory.identifier3("c")); 251 expression, TokenType.PLUS_EQ, AstTestFactory.identifier3("c"));
236 expect(expression.inSetterContext(), isTrue); 252 expect(expression.inSetterContext(), isTrue);
237 } 253 }
238 254
239 void test_inSetterContext_assignment_compound_right() { 255 void test_inSetterContext_assignment_compound_right() {
240 IndexExpression expression = AstFactory.indexExpression( 256 IndexExpression expression = AstTestFactory.indexExpression(
241 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 257 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
242 // c += a[b] 258 // c += a[b]
243 AstFactory.assignmentExpression( 259 AstTestFactory.assignmentExpression(
244 AstFactory.identifier3("c"), TokenType.PLUS_EQ, expression); 260 AstTestFactory.identifier3("c"), TokenType.PLUS_EQ, expression);
245 expect(expression.inSetterContext(), isFalse); 261 expect(expression.inSetterContext(), isFalse);
246 } 262 }
247 263
248 void test_inSetterContext_assignment_simple_left() { 264 void test_inSetterContext_assignment_simple_left() {
249 IndexExpression expression = AstFactory.indexExpression( 265 IndexExpression expression = AstTestFactory.indexExpression(
250 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 266 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
251 // a[b] = c 267 // a[b] = c
252 AstFactory.assignmentExpression( 268 AstTestFactory.assignmentExpression(
253 expression, TokenType.EQ, AstFactory.identifier3("c")); 269 expression, TokenType.EQ, AstTestFactory.identifier3("c"));
254 expect(expression.inSetterContext(), isTrue); 270 expect(expression.inSetterContext(), isTrue);
255 } 271 }
256 272
257 void test_inSetterContext_assignment_simple_right() { 273 void test_inSetterContext_assignment_simple_right() {
258 IndexExpression expression = AstFactory.indexExpression( 274 IndexExpression expression = AstTestFactory.indexExpression(
259 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 275 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
260 // c = a[b] 276 // c = a[b]
261 AstFactory.assignmentExpression( 277 AstTestFactory.assignmentExpression(
262 AstFactory.identifier3("c"), TokenType.EQ, expression); 278 AstTestFactory.identifier3("c"), TokenType.EQ, expression);
263 expect(expression.inSetterContext(), isFalse); 279 expect(expression.inSetterContext(), isFalse);
264 } 280 }
265 281
266 void test_inSetterContext_nonAssignment() { 282 void test_inSetterContext_nonAssignment() {
267 IndexExpression expression = AstFactory.indexExpression( 283 IndexExpression expression = AstTestFactory.indexExpression(
268 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 284 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
269 AstFactory.binaryExpression( 285 AstTestFactory.binaryExpression(
270 expression, TokenType.PLUS, AstFactory.identifier3("c")); 286 expression, TokenType.PLUS, AstTestFactory.identifier3("c"));
271 // a[b] + cc 287 // a[b] + cc
272 expect(expression.inSetterContext(), isFalse); 288 expect(expression.inSetterContext(), isFalse);
273 } 289 }
274 290
275 void test_inSetterContext_postfix() { 291 void test_inSetterContext_postfix() {
276 IndexExpression expression = AstFactory.indexExpression( 292 IndexExpression expression = AstTestFactory.indexExpression(
277 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 293 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
278 AstFactory.postfixExpression(expression, TokenType.PLUS_PLUS); 294 AstTestFactory.postfixExpression(expression, TokenType.PLUS_PLUS);
279 // a[b]++ 295 // a[b]++
280 expect(expression.inSetterContext(), isTrue); 296 expect(expression.inSetterContext(), isTrue);
281 } 297 }
282 298
283 void test_inSetterContext_prefix_bang() { 299 void test_inSetterContext_prefix_bang() {
284 IndexExpression expression = AstFactory.indexExpression( 300 IndexExpression expression = AstTestFactory.indexExpression(
285 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 301 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
286 // !a[b] 302 // !a[b]
287 AstFactory.prefixExpression(TokenType.BANG, expression); 303 AstTestFactory.prefixExpression(TokenType.BANG, expression);
288 expect(expression.inSetterContext(), isFalse); 304 expect(expression.inSetterContext(), isFalse);
289 } 305 }
290 306
291 void test_inSetterContext_prefix_minusMinus() { 307 void test_inSetterContext_prefix_minusMinus() {
292 IndexExpression expression = AstFactory.indexExpression( 308 IndexExpression expression = AstTestFactory.indexExpression(
293 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 309 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
294 // --a[b] 310 // --a[b]
295 AstFactory.prefixExpression(TokenType.MINUS_MINUS, expression); 311 AstTestFactory.prefixExpression(TokenType.MINUS_MINUS, expression);
296 expect(expression.inSetterContext(), isTrue); 312 expect(expression.inSetterContext(), isTrue);
297 } 313 }
298 314
299 void test_inSetterContext_prefix_plusPlus() { 315 void test_inSetterContext_prefix_plusPlus() {
300 IndexExpression expression = AstFactory.indexExpression( 316 IndexExpression expression = AstTestFactory.indexExpression(
301 AstFactory.identifier3("a"), AstFactory.identifier3("b")); 317 AstTestFactory.identifier3("a"), AstTestFactory.identifier3("b"));
302 // ++a[b] 318 // ++a[b]
303 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); 319 AstTestFactory.prefixExpression(TokenType.PLUS_PLUS, expression);
304 expect(expression.inSetterContext(), isTrue); 320 expect(expression.inSetterContext(), isTrue);
305 } 321 }
306 } 322 }
307 323
308 @reflectiveTest 324 @reflectiveTest
309 class MethodDeclarationTest extends EngineTestCase { 325 class MethodDeclarationTest extends EngineTestCase {
310 void test_firstTokenAfterCommentAndMetadata_external() { 326 void test_firstTokenAfterCommentAndMetadata_external() {
311 MethodDeclaration declaration = 327 MethodDeclaration declaration =
312 AstFactory.methodDeclaration4(external: true, name: 'm'); 328 AstTestFactory.methodDeclaration4(external: true, name: 'm');
313 expect(declaration.firstTokenAfterCommentAndMetadata, 329 expect(declaration.firstTokenAfterCommentAndMetadata,
314 declaration.externalKeyword); 330 declaration.externalKeyword);
315 } 331 }
316 332
317 void test_firstTokenAfterCommentAndMetadata_external_getter() { 333 void test_firstTokenAfterCommentAndMetadata_external_getter() {
318 MethodDeclaration declaration = AstFactory.methodDeclaration4( 334 MethodDeclaration declaration = AstTestFactory.methodDeclaration4(
319 external: true, property: Keyword.GET, name: 'm'); 335 external: true, property: Keyword.GET, name: 'm');
320 expect(declaration.firstTokenAfterCommentAndMetadata, 336 expect(declaration.firstTokenAfterCommentAndMetadata,
321 declaration.externalKeyword); 337 declaration.externalKeyword);
322 } 338 }
323 339
324 void test_firstTokenAfterCommentAndMetadata_external_operator() { 340 void test_firstTokenAfterCommentAndMetadata_external_operator() {
325 MethodDeclaration declaration = AstFactory.methodDeclaration4( 341 MethodDeclaration declaration = AstTestFactory.methodDeclaration4(
326 external: true, operator: true, name: 'm'); 342 external: true, operator: true, name: 'm');
327 expect(declaration.firstTokenAfterCommentAndMetadata, 343 expect(declaration.firstTokenAfterCommentAndMetadata,
328 declaration.externalKeyword); 344 declaration.externalKeyword);
329 } 345 }
330 346
331 void test_firstTokenAfterCommentAndMetadata_getter() { 347 void test_firstTokenAfterCommentAndMetadata_getter() {
332 MethodDeclaration declaration = 348 MethodDeclaration declaration =
333 AstFactory.methodDeclaration4(property: Keyword.GET, name: 'm'); 349 AstTestFactory.methodDeclaration4(property: Keyword.GET, name: 'm');
334 expect(declaration.firstTokenAfterCommentAndMetadata, 350 expect(declaration.firstTokenAfterCommentAndMetadata,
335 declaration.propertyKeyword); 351 declaration.propertyKeyword);
336 } 352 }
337 353
338 void test_firstTokenAfterCommentAndMetadata_operator() { 354 void test_firstTokenAfterCommentAndMetadata_operator() {
339 MethodDeclaration declaration = 355 MethodDeclaration declaration =
340 AstFactory.methodDeclaration4(operator: true, name: 'm'); 356 AstTestFactory.methodDeclaration4(operator: true, name: 'm');
341 expect(declaration.firstTokenAfterCommentAndMetadata, 357 expect(declaration.firstTokenAfterCommentAndMetadata,
342 declaration.operatorKeyword); 358 declaration.operatorKeyword);
343 } 359 }
344 } 360 }
345 361
346 @reflectiveTest 362 @reflectiveTest
347 class NodeListTest extends EngineTestCase { 363 class NodeListTest extends EngineTestCase {
348 void test_add() { 364 void test_add() {
349 AstNode parent = AstFactory.argumentList(); 365 AstNode parent = AstTestFactory.argumentList();
350 AstNode firstNode = AstFactory.booleanLiteral(true); 366 AstNode firstNode = AstTestFactory.booleanLiteral(true);
351 AstNode secondNode = AstFactory.booleanLiteral(false); 367 AstNode secondNode = AstTestFactory.booleanLiteral(false);
352 NodeList<AstNode> list = new NodeList<AstNode>(parent); 368 NodeList<AstNode> list = new NodeList<AstNode>(parent);
353 list.insert(0, secondNode); 369 list.insert(0, secondNode);
354 list.insert(0, firstNode); 370 list.insert(0, firstNode);
355 expect(list, hasLength(2)); 371 expect(list, hasLength(2));
356 expect(list[0], same(firstNode)); 372 expect(list[0], same(firstNode));
357 expect(list[1], same(secondNode)); 373 expect(list[1], same(secondNode));
358 expect(firstNode.parent, same(parent)); 374 expect(firstNode.parent, same(parent));
359 expect(secondNode.parent, same(parent)); 375 expect(secondNode.parent, same(parent));
360 AstNode thirdNode = AstFactory.booleanLiteral(false); 376 AstNode thirdNode = AstTestFactory.booleanLiteral(false);
361 list.insert(1, thirdNode); 377 list.insert(1, thirdNode);
362 expect(list, hasLength(3)); 378 expect(list, hasLength(3));
363 expect(list[0], same(firstNode)); 379 expect(list[0], same(firstNode));
364 expect(list[1], same(thirdNode)); 380 expect(list[1], same(thirdNode));
365 expect(list[2], same(secondNode)); 381 expect(list[2], same(secondNode));
366 expect(firstNode.parent, same(parent)); 382 expect(firstNode.parent, same(parent));
367 expect(secondNode.parent, same(parent)); 383 expect(secondNode.parent, same(parent));
368 expect(thirdNode.parent, same(parent)); 384 expect(thirdNode.parent, same(parent));
369 } 385 }
370 386
371 void test_add_negative() { 387 void test_add_negative() {
372 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 388 NodeList<AstNode> list =
389 new NodeList<AstNode>(AstTestFactory.argumentList());
373 try { 390 try {
374 list.insert(-1, AstFactory.booleanLiteral(true)); 391 list.insert(-1, AstTestFactory.booleanLiteral(true));
375 fail("Expected IndexOutOfBoundsException"); 392 fail("Expected IndexOutOfBoundsException");
376 } on RangeError { 393 } on RangeError {
377 // Expected 394 // Expected
378 } 395 }
379 } 396 }
380 397
381 void test_add_tooBig() { 398 void test_add_tooBig() {
382 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 399 NodeList<AstNode> list =
400 new NodeList<AstNode>(AstTestFactory.argumentList());
383 try { 401 try {
384 list.insert(1, AstFactory.booleanLiteral(true)); 402 list.insert(1, AstTestFactory.booleanLiteral(true));
385 fail("Expected IndexOutOfBoundsException"); 403 fail("Expected IndexOutOfBoundsException");
386 } on RangeError { 404 } on RangeError {
387 // Expected 405 // Expected
388 } 406 }
389 } 407 }
390 408
391 void test_addAll() { 409 void test_addAll() {
392 AstNode parent = AstFactory.argumentList(); 410 AstNode parent = AstTestFactory.argumentList();
393 List<AstNode> firstNodes = new List<AstNode>(); 411 List<AstNode> firstNodes = new List<AstNode>();
394 AstNode firstNode = AstFactory.booleanLiteral(true); 412 AstNode firstNode = AstTestFactory.booleanLiteral(true);
395 AstNode secondNode = AstFactory.booleanLiteral(false); 413 AstNode secondNode = AstTestFactory.booleanLiteral(false);
396 firstNodes.add(firstNode); 414 firstNodes.add(firstNode);
397 firstNodes.add(secondNode); 415 firstNodes.add(secondNode);
398 NodeList<AstNode> list = new NodeList<AstNode>(parent); 416 NodeList<AstNode> list = new NodeList<AstNode>(parent);
399 list.addAll(firstNodes); 417 list.addAll(firstNodes);
400 expect(list, hasLength(2)); 418 expect(list, hasLength(2));
401 expect(list[0], same(firstNode)); 419 expect(list[0], same(firstNode));
402 expect(list[1], same(secondNode)); 420 expect(list[1], same(secondNode));
403 expect(firstNode.parent, same(parent)); 421 expect(firstNode.parent, same(parent));
404 expect(secondNode.parent, same(parent)); 422 expect(secondNode.parent, same(parent));
405 List<AstNode> secondNodes = new List<AstNode>(); 423 List<AstNode> secondNodes = new List<AstNode>();
406 AstNode thirdNode = AstFactory.booleanLiteral(true); 424 AstNode thirdNode = AstTestFactory.booleanLiteral(true);
407 AstNode fourthNode = AstFactory.booleanLiteral(false); 425 AstNode fourthNode = AstTestFactory.booleanLiteral(false);
408 secondNodes.add(thirdNode); 426 secondNodes.add(thirdNode);
409 secondNodes.add(fourthNode); 427 secondNodes.add(fourthNode);
410 list.addAll(secondNodes); 428 list.addAll(secondNodes);
411 expect(list, hasLength(4)); 429 expect(list, hasLength(4));
412 expect(list[0], same(firstNode)); 430 expect(list[0], same(firstNode));
413 expect(list[1], same(secondNode)); 431 expect(list[1], same(secondNode));
414 expect(list[2], same(thirdNode)); 432 expect(list[2], same(thirdNode));
415 expect(list[3], same(fourthNode)); 433 expect(list[3], same(fourthNode));
416 expect(firstNode.parent, same(parent)); 434 expect(firstNode.parent, same(parent));
417 expect(secondNode.parent, same(parent)); 435 expect(secondNode.parent, same(parent));
418 expect(thirdNode.parent, same(parent)); 436 expect(thirdNode.parent, same(parent));
419 expect(fourthNode.parent, same(parent)); 437 expect(fourthNode.parent, same(parent));
420 } 438 }
421 439
422 void test_creation() { 440 void test_creation() {
423 AstNode owner = AstFactory.argumentList(); 441 AstNode owner = AstTestFactory.argumentList();
424 NodeList<AstNode> list = new NodeList<AstNode>(owner); 442 NodeList<AstNode> list = new NodeList<AstNode>(owner);
425 expect(list, isNotNull); 443 expect(list, isNotNull);
426 expect(list, hasLength(0)); 444 expect(list, hasLength(0));
427 expect(list.owner, same(owner)); 445 expect(list.owner, same(owner));
428 } 446 }
429 447
430 void test_get_negative() { 448 void test_get_negative() {
431 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 449 NodeList<AstNode> list =
450 new NodeList<AstNode>(AstTestFactory.argumentList());
432 try { 451 try {
433 list[-1]; 452 list[-1];
434 fail("Expected IndexOutOfBoundsException"); 453 fail("Expected IndexOutOfBoundsException");
435 } on RangeError { 454 } on RangeError {
436 // Expected 455 // Expected
437 } 456 }
438 } 457 }
439 458
440 void test_get_tooBig() { 459 void test_get_tooBig() {
441 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 460 NodeList<AstNode> list =
461 new NodeList<AstNode>(AstTestFactory.argumentList());
442 try { 462 try {
443 list[1]; 463 list[1];
444 fail("Expected IndexOutOfBoundsException"); 464 fail("Expected IndexOutOfBoundsException");
445 } on RangeError { 465 } on RangeError {
446 // Expected 466 // Expected
447 } 467 }
448 } 468 }
449 469
450 void test_getBeginToken_empty() { 470 void test_getBeginToken_empty() {
451 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 471 NodeList<AstNode> list =
472 new NodeList<AstNode>(AstTestFactory.argumentList());
452 expect(list.beginToken, isNull); 473 expect(list.beginToken, isNull);
453 } 474 }
454 475
455 void test_getBeginToken_nonEmpty() { 476 void test_getBeginToken_nonEmpty() {
456 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 477 NodeList<AstNode> list =
457 AstNode node = 478 new NodeList<AstNode>(AstTestFactory.argumentList());
458 AstFactory.parenthesizedExpression(AstFactory.booleanLiteral(true)); 479 AstNode node = AstTestFactory
480 .parenthesizedExpression(AstTestFactory.booleanLiteral(true));
459 list.add(node); 481 list.add(node);
460 expect(list.beginToken, same(node.beginToken)); 482 expect(list.beginToken, same(node.beginToken));
461 } 483 }
462 484
463 void test_getEndToken_empty() { 485 void test_getEndToken_empty() {
464 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 486 NodeList<AstNode> list =
487 new NodeList<AstNode>(AstTestFactory.argumentList());
465 expect(list.endToken, isNull); 488 expect(list.endToken, isNull);
466 } 489 }
467 490
468 void test_getEndToken_nonEmpty() { 491 void test_getEndToken_nonEmpty() {
469 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 492 NodeList<AstNode> list =
470 AstNode node = 493 new NodeList<AstNode>(AstTestFactory.argumentList());
471 AstFactory.parenthesizedExpression(AstFactory.booleanLiteral(true)); 494 AstNode node = AstTestFactory
495 .parenthesizedExpression(AstTestFactory.booleanLiteral(true));
472 list.add(node); 496 list.add(node);
473 expect(list.endToken, same(node.endToken)); 497 expect(list.endToken, same(node.endToken));
474 } 498 }
475 499
476 void test_indexOf() { 500 void test_indexOf() {
477 List<AstNode> nodes = new List<AstNode>(); 501 List<AstNode> nodes = new List<AstNode>();
478 AstNode firstNode = AstFactory.booleanLiteral(true); 502 AstNode firstNode = AstTestFactory.booleanLiteral(true);
479 AstNode secondNode = AstFactory.booleanLiteral(false); 503 AstNode secondNode = AstTestFactory.booleanLiteral(false);
480 AstNode thirdNode = AstFactory.booleanLiteral(true); 504 AstNode thirdNode = AstTestFactory.booleanLiteral(true);
481 AstNode fourthNode = AstFactory.booleanLiteral(false); 505 AstNode fourthNode = AstTestFactory.booleanLiteral(false);
482 nodes.add(firstNode); 506 nodes.add(firstNode);
483 nodes.add(secondNode); 507 nodes.add(secondNode);
484 nodes.add(thirdNode); 508 nodes.add(thirdNode);
485 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 509 NodeList<AstNode> list =
510 new NodeList<AstNode>(AstTestFactory.argumentList());
486 list.addAll(nodes); 511 list.addAll(nodes);
487 expect(list, hasLength(3)); 512 expect(list, hasLength(3));
488 expect(list.indexOf(firstNode), 0); 513 expect(list.indexOf(firstNode), 0);
489 expect(list.indexOf(secondNode), 1); 514 expect(list.indexOf(secondNode), 1);
490 expect(list.indexOf(thirdNode), 2); 515 expect(list.indexOf(thirdNode), 2);
491 expect(list.indexOf(fourthNode), -1); 516 expect(list.indexOf(fourthNode), -1);
492 expect(list.indexOf(null), -1); 517 expect(list.indexOf(null), -1);
493 } 518 }
494 519
495 void test_remove() { 520 void test_remove() {
496 List<AstNode> nodes = new List<AstNode>(); 521 List<AstNode> nodes = new List<AstNode>();
497 AstNode firstNode = AstFactory.booleanLiteral(true); 522 AstNode firstNode = AstTestFactory.booleanLiteral(true);
498 AstNode secondNode = AstFactory.booleanLiteral(false); 523 AstNode secondNode = AstTestFactory.booleanLiteral(false);
499 AstNode thirdNode = AstFactory.booleanLiteral(true); 524 AstNode thirdNode = AstTestFactory.booleanLiteral(true);
500 nodes.add(firstNode); 525 nodes.add(firstNode);
501 nodes.add(secondNode); 526 nodes.add(secondNode);
502 nodes.add(thirdNode); 527 nodes.add(thirdNode);
503 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 528 NodeList<AstNode> list =
529 new NodeList<AstNode>(AstTestFactory.argumentList());
504 list.addAll(nodes); 530 list.addAll(nodes);
505 expect(list, hasLength(3)); 531 expect(list, hasLength(3));
506 expect(list.removeAt(1), same(secondNode)); 532 expect(list.removeAt(1), same(secondNode));
507 expect(list, hasLength(2)); 533 expect(list, hasLength(2));
508 expect(list[0], same(firstNode)); 534 expect(list[0], same(firstNode));
509 expect(list[1], same(thirdNode)); 535 expect(list[1], same(thirdNode));
510 } 536 }
511 537
512 void test_remove_negative() { 538 void test_remove_negative() {
513 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 539 NodeList<AstNode> list =
540 new NodeList<AstNode>(AstTestFactory.argumentList());
514 try { 541 try {
515 list.removeAt(-1); 542 list.removeAt(-1);
516 fail("Expected IndexOutOfBoundsException"); 543 fail("Expected IndexOutOfBoundsException");
517 } on RangeError { 544 } on RangeError {
518 // Expected 545 // Expected
519 } 546 }
520 } 547 }
521 548
522 void test_remove_tooBig() { 549 void test_remove_tooBig() {
523 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 550 NodeList<AstNode> list =
551 new NodeList<AstNode>(AstTestFactory.argumentList());
524 try { 552 try {
525 list.removeAt(1); 553 list.removeAt(1);
526 fail("Expected IndexOutOfBoundsException"); 554 fail("Expected IndexOutOfBoundsException");
527 } on RangeError { 555 } on RangeError {
528 // Expected 556 // Expected
529 } 557 }
530 } 558 }
531 559
532 void test_set() { 560 void test_set() {
533 List<AstNode> nodes = new List<AstNode>(); 561 List<AstNode> nodes = new List<AstNode>();
534 AstNode firstNode = AstFactory.booleanLiteral(true); 562 AstNode firstNode = AstTestFactory.booleanLiteral(true);
535 AstNode secondNode = AstFactory.booleanLiteral(false); 563 AstNode secondNode = AstTestFactory.booleanLiteral(false);
536 AstNode thirdNode = AstFactory.booleanLiteral(true); 564 AstNode thirdNode = AstTestFactory.booleanLiteral(true);
537 nodes.add(firstNode); 565 nodes.add(firstNode);
538 nodes.add(secondNode); 566 nodes.add(secondNode);
539 nodes.add(thirdNode); 567 nodes.add(thirdNode);
540 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 568 NodeList<AstNode> list =
569 new NodeList<AstNode>(AstTestFactory.argumentList());
541 list.addAll(nodes); 570 list.addAll(nodes);
542 expect(list, hasLength(3)); 571 expect(list, hasLength(3));
543 AstNode fourthNode = AstFactory.integer(0); 572 AstNode fourthNode = AstTestFactory.integer(0);
544 list[1] = fourthNode; 573 list[1] = fourthNode;
545 expect(list, hasLength(3)); 574 expect(list, hasLength(3));
546 expect(list[0], same(firstNode)); 575 expect(list[0], same(firstNode));
547 expect(list[1], same(fourthNode)); 576 expect(list[1], same(fourthNode));
548 expect(list[2], same(thirdNode)); 577 expect(list[2], same(thirdNode));
549 } 578 }
550 579
551 void test_set_negative() { 580 void test_set_negative() {
552 AstNode node = AstFactory.booleanLiteral(true); 581 AstNode node = AstTestFactory.booleanLiteral(true);
553 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 582 NodeList<AstNode> list =
583 new NodeList<AstNode>(AstTestFactory.argumentList());
554 try { 584 try {
555 list[-1] = node; 585 list[-1] = node;
556 fail("Expected IndexOutOfBoundsException"); 586 fail("Expected IndexOutOfBoundsException");
557 } on RangeError { 587 } on RangeError {
558 // Expected 588 // Expected
559 } 589 }
560 } 590 }
561 591
562 void test_set_tooBig() { 592 void test_set_tooBig() {
563 AstNode node = AstFactory.booleanLiteral(true); 593 AstNode node = AstTestFactory.booleanLiteral(true);
564 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList()); 594 NodeList<AstNode> list =
595 new NodeList<AstNode>(AstTestFactory.argumentList());
565 try { 596 try {
566 list[1] = node; 597 list[1] = node;
567 fail("Expected IndexOutOfBoundsException"); 598 fail("Expected IndexOutOfBoundsException");
568 } on RangeError { 599 } on RangeError {
569 // Expected 600 // Expected
570 } 601 }
571 } 602 }
572 } 603 }
573 604
574 @reflectiveTest 605 @reflectiveTest
(...skipping 11 matching lines...) Expand all
586 } else { 617 } else {
587 if (!identifier.inGetterContext()) { 618 if (!identifier.inGetterContext()) {
588 fail("Expected ${_topMostNode(identifier).toSource()} to be true"); 619 fail("Expected ${_topMostNode(identifier).toSource()} to be true");
589 } 620 }
590 } 621 }
591 } 622 }
592 } 623 }
593 } 624 }
594 625
595 void test_inGetterContext_constructorFieldInitializer() { 626 void test_inGetterContext_constructorFieldInitializer() {
596 ConstructorFieldInitializer initializer = AstFactory 627 ConstructorFieldInitializer initializer = AstTestFactory
597 .constructorFieldInitializer(false, 'f', AstFactory.integer(0)); 628 .constructorFieldInitializer(false, 'f', AstTestFactory.integer(0));
598 SimpleIdentifier identifier = initializer.fieldName; 629 SimpleIdentifier identifier = initializer.fieldName;
599 expect(identifier.inGetterContext(), isFalse); 630 expect(identifier.inGetterContext(), isFalse);
600 } 631 }
601 632
602 void test_inGetterContext_forEachLoop() { 633 void test_inGetterContext_forEachLoop() {
603 SimpleIdentifier identifier = AstFactory.identifier3("a"); 634 SimpleIdentifier identifier = AstTestFactory.identifier3("a");
604 Expression iterator = AstFactory.listLiteral(); 635 Expression iterator = AstTestFactory.listLiteral();
605 Statement body = AstFactory.block(); 636 Statement body = AstTestFactory.block();
606 AstFactory.forEachStatement2(identifier, iterator, body); 637 AstTestFactory.forEachStatement2(identifier, iterator, body);
607 expect(identifier.inGetterContext(), isFalse); 638 expect(identifier.inGetterContext(), isFalse);
608 } 639 }
609 640
610 void test_inReferenceContext() { 641 void test_inReferenceContext() {
611 SimpleIdentifier identifier = AstFactory.identifier3("id"); 642 SimpleIdentifier identifier = AstTestFactory.identifier3("id");
612 AstFactory.namedExpression( 643 AstTestFactory.namedExpression(
613 AstFactory.label(identifier), AstFactory.identifier3("_")); 644 AstTestFactory.label(identifier), AstTestFactory.identifier3("_"));
614 expect(identifier.inGetterContext(), isFalse); 645 expect(identifier.inGetterContext(), isFalse);
615 expect(identifier.inSetterContext(), isFalse); 646 expect(identifier.inSetterContext(), isFalse);
616 } 647 }
617 648
618 void test_inSetterContext() { 649 void test_inSetterContext() {
619 for (_WrapperKind wrapper in _WrapperKind.values) { 650 for (_WrapperKind wrapper in _WrapperKind.values) {
620 for (_AssignmentKind assignment in _AssignmentKind.values) { 651 for (_AssignmentKind assignment in _AssignmentKind.values) {
621 SimpleIdentifier identifier = _createIdentifier(wrapper, assignment); 652 SimpleIdentifier identifier = _createIdentifier(wrapper, assignment);
622 if (wrapper == _WrapperKind.PREFIXED_LEFT || 653 if (wrapper == _WrapperKind.PREFIXED_LEFT ||
623 wrapper == _WrapperKind.PROPERTY_LEFT || 654 wrapper == _WrapperKind.PROPERTY_LEFT ||
624 assignment == _AssignmentKind.BINARY || 655 assignment == _AssignmentKind.BINARY ||
625 assignment == _AssignmentKind.COMPOUND_RIGHT || 656 assignment == _AssignmentKind.COMPOUND_RIGHT ||
626 assignment == _AssignmentKind.PREFIX_NOT || 657 assignment == _AssignmentKind.PREFIX_NOT ||
627 assignment == _AssignmentKind.SIMPLE_RIGHT || 658 assignment == _AssignmentKind.SIMPLE_RIGHT ||
628 assignment == _AssignmentKind.NONE) { 659 assignment == _AssignmentKind.NONE) {
629 if (identifier.inSetterContext()) { 660 if (identifier.inSetterContext()) {
630 fail("Expected ${_topMostNode(identifier).toSource()} to be false"); 661 fail("Expected ${_topMostNode(identifier).toSource()} to be false");
631 } 662 }
632 } else { 663 } else {
633 if (!identifier.inSetterContext()) { 664 if (!identifier.inSetterContext()) {
634 fail("Expected ${_topMostNode(identifier).toSource()} to be true"); 665 fail("Expected ${_topMostNode(identifier).toSource()} to be true");
635 } 666 }
636 } 667 }
637 } 668 }
638 } 669 }
639 } 670 }
640 671
641 void test_inSetterContext_forEachLoop() { 672 void test_inSetterContext_forEachLoop() {
642 SimpleIdentifier identifier = AstFactory.identifier3("a"); 673 SimpleIdentifier identifier = AstTestFactory.identifier3("a");
643 Expression iterator = AstFactory.listLiteral(); 674 Expression iterator = AstTestFactory.listLiteral();
644 Statement body = AstFactory.block(); 675 Statement body = AstTestFactory.block();
645 AstFactory.forEachStatement2(identifier, iterator, body); 676 AstTestFactory.forEachStatement2(identifier, iterator, body);
646 expect(identifier.inSetterContext(), isTrue); 677 expect(identifier.inSetterContext(), isTrue);
647 } 678 }
648 679
649 void test_isQualified_inMethodInvocation_noTarget() { 680 void test_isQualified_inMethodInvocation_noTarget() {
650 MethodInvocation invocation = 681 MethodInvocation invocation = AstTestFactory
651 AstFactory.methodInvocation2("test", [AstFactory.identifier3("arg0")]); 682 .methodInvocation2("test", [AstTestFactory.identifier3("arg0")]);
652 SimpleIdentifier identifier = invocation.methodName; 683 SimpleIdentifier identifier = invocation.methodName;
653 expect(identifier.isQualified, isFalse); 684 expect(identifier.isQualified, isFalse);
654 } 685 }
655 686
656 void test_isQualified_inMethodInvocation_withTarget() { 687 void test_isQualified_inMethodInvocation_withTarget() {
657 MethodInvocation invocation = AstFactory.methodInvocation( 688 MethodInvocation invocation = AstTestFactory.methodInvocation(
658 AstFactory.identifier3("target"), 689 AstTestFactory.identifier3("target"),
659 "test", 690 "test",
660 [AstFactory.identifier3("arg0")]); 691 [AstTestFactory.identifier3("arg0")]);
661 SimpleIdentifier identifier = invocation.methodName; 692 SimpleIdentifier identifier = invocation.methodName;
662 expect(identifier.isQualified, isTrue); 693 expect(identifier.isQualified, isTrue);
663 } 694 }
664 695
665 void test_isQualified_inPrefixedIdentifier_name() { 696 void test_isQualified_inPrefixedIdentifier_name() {
666 SimpleIdentifier identifier = AstFactory.identifier3("test"); 697 SimpleIdentifier identifier = AstTestFactory.identifier3("test");
667 AstFactory.identifier4("prefix", identifier); 698 AstTestFactory.identifier4("prefix", identifier);
668 expect(identifier.isQualified, isTrue); 699 expect(identifier.isQualified, isTrue);
669 } 700 }
670 701
671 void test_isQualified_inPrefixedIdentifier_prefix() { 702 void test_isQualified_inPrefixedIdentifier_prefix() {
672 SimpleIdentifier identifier = AstFactory.identifier3("test"); 703 SimpleIdentifier identifier = AstTestFactory.identifier3("test");
673 AstFactory.identifier(identifier, AstFactory.identifier3("name")); 704 AstTestFactory.identifier(identifier, AstTestFactory.identifier3("name"));
674 expect(identifier.isQualified, isFalse); 705 expect(identifier.isQualified, isFalse);
675 } 706 }
676 707
677 void test_isQualified_inPropertyAccess_name() { 708 void test_isQualified_inPropertyAccess_name() {
678 SimpleIdentifier identifier = AstFactory.identifier3("test"); 709 SimpleIdentifier identifier = AstTestFactory.identifier3("test");
679 AstFactory.propertyAccess(AstFactory.identifier3("target"), identifier); 710 AstTestFactory.propertyAccess(
711 AstTestFactory.identifier3("target"), identifier);
680 expect(identifier.isQualified, isTrue); 712 expect(identifier.isQualified, isTrue);
681 } 713 }
682 714
683 void test_isQualified_inPropertyAccess_target() { 715 void test_isQualified_inPropertyAccess_target() {
684 SimpleIdentifier identifier = AstFactory.identifier3("test"); 716 SimpleIdentifier identifier = AstTestFactory.identifier3("test");
685 AstFactory.propertyAccess(identifier, AstFactory.identifier3("name")); 717 AstTestFactory.propertyAccess(
718 identifier, AstTestFactory.identifier3("name"));
686 expect(identifier.isQualified, isFalse); 719 expect(identifier.isQualified, isFalse);
687 } 720 }
688 721
689 void test_isQualified_inReturnStatement() { 722 void test_isQualified_inReturnStatement() {
690 SimpleIdentifier identifier = AstFactory.identifier3("test"); 723 SimpleIdentifier identifier = AstTestFactory.identifier3("test");
691 AstFactory.returnStatement2(identifier); 724 AstTestFactory.returnStatement2(identifier);
692 expect(identifier.isQualified, isFalse); 725 expect(identifier.isQualified, isFalse);
693 } 726 }
694 727
695 SimpleIdentifier _createIdentifier( 728 SimpleIdentifier _createIdentifier(
696 _WrapperKind wrapper, _AssignmentKind assignment) { 729 _WrapperKind wrapper, _AssignmentKind assignment) {
697 SimpleIdentifier identifier = AstFactory.identifier3("a"); 730 SimpleIdentifier identifier = AstTestFactory.identifier3("a");
698 Expression expression = identifier; 731 Expression expression = identifier;
699 while (true) { 732 while (true) {
700 if (wrapper == _WrapperKind.PREFIXED_LEFT) { 733 if (wrapper == _WrapperKind.PREFIXED_LEFT) {
701 expression = 734 expression = AstTestFactory.identifier(
702 AstFactory.identifier(identifier, AstFactory.identifier3("_")); 735 identifier, AstTestFactory.identifier3("_"));
703 } else if (wrapper == _WrapperKind.PREFIXED_RIGHT) { 736 } else if (wrapper == _WrapperKind.PREFIXED_RIGHT) {
704 expression = 737 expression = AstTestFactory.identifier(
705 AstFactory.identifier(AstFactory.identifier3("_"), identifier); 738 AstTestFactory.identifier3("_"), identifier);
706 } else if (wrapper == _WrapperKind.PROPERTY_LEFT) { 739 } else if (wrapper == _WrapperKind.PROPERTY_LEFT) {
707 expression = AstFactory.propertyAccess2(expression, "_"); 740 expression = AstTestFactory.propertyAccess2(expression, "_");
708 } else if (wrapper == _WrapperKind.PROPERTY_RIGHT) { 741 } else if (wrapper == _WrapperKind.PROPERTY_RIGHT) {
709 expression = 742 expression = AstTestFactory.propertyAccess(
710 AstFactory.propertyAccess(AstFactory.identifier3("_"), identifier); 743 AstTestFactory.identifier3("_"), identifier);
711 } else if (wrapper == _WrapperKind.NONE) {} 744 } else if (wrapper == _WrapperKind.NONE) {}
712 break; 745 break;
713 } 746 }
714 while (true) { 747 while (true) {
715 if (assignment == _AssignmentKind.BINARY) { 748 if (assignment == _AssignmentKind.BINARY) {
716 AstFactory.binaryExpression( 749 AstTestFactory.binaryExpression(
717 expression, TokenType.PLUS, AstFactory.identifier3("_")); 750 expression, TokenType.PLUS, AstTestFactory.identifier3("_"));
718 } else if (assignment == _AssignmentKind.COMPOUND_LEFT) { 751 } else if (assignment == _AssignmentKind.COMPOUND_LEFT) {
719 AstFactory.assignmentExpression( 752 AstTestFactory.assignmentExpression(
720 expression, TokenType.PLUS_EQ, AstFactory.identifier3("_")); 753 expression, TokenType.PLUS_EQ, AstTestFactory.identifier3("_"));
721 } else if (assignment == _AssignmentKind.COMPOUND_RIGHT) { 754 } else if (assignment == _AssignmentKind.COMPOUND_RIGHT) {
722 AstFactory.assignmentExpression( 755 AstTestFactory.assignmentExpression(
723 AstFactory.identifier3("_"), TokenType.PLUS_EQ, expression); 756 AstTestFactory.identifier3("_"), TokenType.PLUS_EQ, expression);
724 } else if (assignment == _AssignmentKind.POSTFIX_INC) { 757 } else if (assignment == _AssignmentKind.POSTFIX_INC) {
725 AstFactory.postfixExpression(expression, TokenType.PLUS_PLUS); 758 AstTestFactory.postfixExpression(expression, TokenType.PLUS_PLUS);
726 } else if (assignment == _AssignmentKind.PREFIX_DEC) { 759 } else if (assignment == _AssignmentKind.PREFIX_DEC) {
727 AstFactory.prefixExpression(TokenType.MINUS_MINUS, expression); 760 AstTestFactory.prefixExpression(TokenType.MINUS_MINUS, expression);
728 } else if (assignment == _AssignmentKind.PREFIX_INC) { 761 } else if (assignment == _AssignmentKind.PREFIX_INC) {
729 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); 762 AstTestFactory.prefixExpression(TokenType.PLUS_PLUS, expression);
730 } else if (assignment == _AssignmentKind.PREFIX_NOT) { 763 } else if (assignment == _AssignmentKind.PREFIX_NOT) {
731 AstFactory.prefixExpression(TokenType.BANG, expression); 764 AstTestFactory.prefixExpression(TokenType.BANG, expression);
732 } else if (assignment == _AssignmentKind.SIMPLE_LEFT) { 765 } else if (assignment == _AssignmentKind.SIMPLE_LEFT) {
733 AstFactory.assignmentExpression( 766 AstTestFactory.assignmentExpression(
734 expression, TokenType.EQ, AstFactory.identifier3("_")); 767 expression, TokenType.EQ, AstTestFactory.identifier3("_"));
735 } else if (assignment == _AssignmentKind.SIMPLE_RIGHT) { 768 } else if (assignment == _AssignmentKind.SIMPLE_RIGHT) {
736 AstFactory.assignmentExpression( 769 AstTestFactory.assignmentExpression(
737 AstFactory.identifier3("_"), TokenType.EQ, expression); 770 AstTestFactory.identifier3("_"), TokenType.EQ, expression);
738 } else if (assignment == _AssignmentKind.NONE) {} 771 } else if (assignment == _AssignmentKind.NONE) {}
739 break; 772 break;
740 } 773 }
741 return identifier; 774 return identifier;
742 } 775 }
743 776
744 /** 777 /**
745 * Return the top-most node in the AST structure containing the given identifi er. 778 * Return the top-most node in the AST structure containing the given identifi er.
746 * 779 *
747 * @param identifier the identifier in the AST structure being traversed 780 * @param identifier the identifier in the AST structure being traversed
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 expect(stringLiteral.literal, same(token)); 1022 expect(stringLiteral.literal, same(token));
990 expect(stringLiteral.beginToken, same(token)); 1023 expect(stringLiteral.beginToken, same(token));
991 expect(stringLiteral.endToken, same(token)); 1024 expect(stringLiteral.endToken, same(token));
992 expect(stringLiteral.value, "value"); 1025 expect(stringLiteral.value, "value");
993 } 1026 }
994 } 1027 }
995 1028
996 @reflectiveTest 1029 @reflectiveTest
997 class StringInterpolationTest extends ParserTestCase { 1030 class StringInterpolationTest extends ParserTestCase {
998 void test_contentsOffsetEnd() { 1031 void test_contentsOffsetEnd() {
999 AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1032 AstTestFactory.interpolationExpression(AstTestFactory.identifier3('bb'));
1000 // 'a${bb}ccc' 1033 // 'a${bb}ccc'
1001 { 1034 {
1002 var ae = AstFactory.interpolationString("'a", "a"); 1035 var ae = AstTestFactory.interpolationString("'a", "a");
1003 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); 1036 var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
1004 var cElement = new InterpolationString(cToken, 'ccc'); 1037 var cElement = new InterpolationString(cToken, 'ccc');
1005 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1038 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
1006 expect(node.contentsOffset, 1); 1039 expect(node.contentsOffset, 1);
1007 expect(node.contentsEnd, 10 + 4 - 1); 1040 expect(node.contentsEnd, 10 + 4 - 1);
1008 } 1041 }
1009 // '''a${bb}ccc''' 1042 // '''a${bb}ccc'''
1010 { 1043 {
1011 var ae = AstFactory.interpolationString("'''a", "a"); 1044 var ae = AstTestFactory.interpolationString("'''a", "a");
1012 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); 1045 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
1013 var cElement = new InterpolationString(cToken, 'ccc'); 1046 var cElement = new InterpolationString(cToken, 'ccc');
1014 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1047 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
1015 expect(node.contentsOffset, 3); 1048 expect(node.contentsOffset, 3);
1016 expect(node.contentsEnd, 10 + 4 - 1); 1049 expect(node.contentsEnd, 10 + 4 - 1);
1017 } 1050 }
1018 // """a${bb}ccc""" 1051 // """a${bb}ccc"""
1019 { 1052 {
1020 var ae = AstFactory.interpolationString('"""a', "a"); 1053 var ae = AstTestFactory.interpolationString('"""a', "a");
1021 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); 1054 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
1022 var cElement = new InterpolationString(cToken, 'ccc'); 1055 var cElement = new InterpolationString(cToken, 'ccc');
1023 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1056 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
1024 expect(node.contentsOffset, 3); 1057 expect(node.contentsOffset, 3);
1025 expect(node.contentsEnd, 10 + 4 - 1); 1058 expect(node.contentsEnd, 10 + 4 - 1);
1026 } 1059 }
1027 // r'a${bb}ccc' 1060 // r'a${bb}ccc'
1028 { 1061 {
1029 var ae = AstFactory.interpolationString("r'a", "a"); 1062 var ae = AstTestFactory.interpolationString("r'a", "a");
1030 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); 1063 var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
1031 var cElement = new InterpolationString(cToken, 'ccc'); 1064 var cElement = new InterpolationString(cToken, 'ccc');
1032 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1065 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
1033 expect(node.contentsOffset, 2); 1066 expect(node.contentsOffset, 2);
1034 expect(node.contentsEnd, 10 + 4 - 1); 1067 expect(node.contentsEnd, 10 + 4 - 1);
1035 } 1068 }
1036 // r'''a${bb}ccc''' 1069 // r'''a${bb}ccc'''
1037 { 1070 {
1038 var ae = AstFactory.interpolationString("r'''a", "a"); 1071 var ae = AstTestFactory.interpolationString("r'''a", "a");
1039 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); 1072 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
1040 var cElement = new InterpolationString(cToken, 'ccc'); 1073 var cElement = new InterpolationString(cToken, 'ccc');
1041 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1074 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
1042 expect(node.contentsOffset, 4); 1075 expect(node.contentsOffset, 4);
1043 expect(node.contentsEnd, 10 + 4 - 1); 1076 expect(node.contentsEnd, 10 + 4 - 1);
1044 } 1077 }
1045 // r"""a${bb}ccc""" 1078 // r"""a${bb}ccc"""
1046 { 1079 {
1047 var ae = AstFactory.interpolationString('r"""a', "a"); 1080 var ae = AstTestFactory.interpolationString('r"""a', "a");
1048 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); 1081 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
1049 var cElement = new InterpolationString(cToken, 'ccc'); 1082 var cElement = new InterpolationString(cToken, 'ccc');
1050 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1083 StringInterpolation node = AstTestFactory.string([ae, ae, cElement]);
1051 expect(node.contentsOffset, 4); 1084 expect(node.contentsOffset, 4);
1052 expect(node.contentsEnd, 10 + 4 - 1); 1085 expect(node.contentsEnd, 10 + 4 - 1);
1053 } 1086 }
1054 } 1087 }
1055 1088
1056 void test_isMultiline() { 1089 void test_isMultiline() {
1057 var b = AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1090 var b = AstTestFactory
1091 .interpolationExpression(AstTestFactory.identifier3('bb'));
1058 // ' 1092 // '
1059 { 1093 {
1060 var a = AstFactory.interpolationString("'a", "a"); 1094 var a = AstTestFactory.interpolationString("'a", "a");
1061 var c = AstFactory.interpolationString("ccc'", "ccc"); 1095 var c = AstTestFactory.interpolationString("ccc'", "ccc");
1062 StringInterpolation node = AstFactory.string([a, b, c]); 1096 StringInterpolation node = AstTestFactory.string([a, b, c]);
1063 expect(node.isMultiline, isFalse); 1097 expect(node.isMultiline, isFalse);
1064 } 1098 }
1065 // ''' 1099 // '''
1066 { 1100 {
1067 var a = AstFactory.interpolationString("'''a", "a"); 1101 var a = AstTestFactory.interpolationString("'''a", "a");
1068 var c = AstFactory.interpolationString("ccc'''", "ccc"); 1102 var c = AstTestFactory.interpolationString("ccc'''", "ccc");
1069 StringInterpolation node = AstFactory.string([a, b, c]); 1103 StringInterpolation node = AstTestFactory.string([a, b, c]);
1070 expect(node.isMultiline, isTrue); 1104 expect(node.isMultiline, isTrue);
1071 } 1105 }
1072 // " 1106 // "
1073 { 1107 {
1074 var a = AstFactory.interpolationString('"a', "a"); 1108 var a = AstTestFactory.interpolationString('"a', "a");
1075 var c = AstFactory.interpolationString('ccc"', "ccc"); 1109 var c = AstTestFactory.interpolationString('ccc"', "ccc");
1076 StringInterpolation node = AstFactory.string([a, b, c]); 1110 StringInterpolation node = AstTestFactory.string([a, b, c]);
1077 expect(node.isMultiline, isFalse); 1111 expect(node.isMultiline, isFalse);
1078 } 1112 }
1079 // """ 1113 // """
1080 { 1114 {
1081 var a = AstFactory.interpolationString('"""a', "a"); 1115 var a = AstTestFactory.interpolationString('"""a', "a");
1082 var c = AstFactory.interpolationString('ccc"""', "ccc"); 1116 var c = AstTestFactory.interpolationString('ccc"""', "ccc");
1083 StringInterpolation node = AstFactory.string([a, b, c]); 1117 StringInterpolation node = AstTestFactory.string([a, b, c]);
1084 expect(node.isMultiline, isTrue); 1118 expect(node.isMultiline, isTrue);
1085 } 1119 }
1086 } 1120 }
1087 1121
1088 void test_isRaw() { 1122 void test_isRaw() {
1089 StringInterpolation node = AstFactory.string(); 1123 StringInterpolation node = AstTestFactory.string();
1090 expect(node.isRaw, isFalse); 1124 expect(node.isRaw, isFalse);
1091 } 1125 }
1092 1126
1093 void test_isSingleQuoted() { 1127 void test_isSingleQuoted() {
1094 var b = AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1128 var b = AstTestFactory
1129 .interpolationExpression(AstTestFactory.identifier3('bb'));
1095 // " 1130 // "
1096 { 1131 {
1097 var a = AstFactory.interpolationString('"a', "a"); 1132 var a = AstTestFactory.interpolationString('"a', "a");
1098 var c = AstFactory.interpolationString('ccc"', "ccc"); 1133 var c = AstTestFactory.interpolationString('ccc"', "ccc");
1099 StringInterpolation node = AstFactory.string([a, b, c]); 1134 StringInterpolation node = AstTestFactory.string([a, b, c]);
1100 expect(node.isSingleQuoted, isFalse); 1135 expect(node.isSingleQuoted, isFalse);
1101 } 1136 }
1102 // """ 1137 // """
1103 { 1138 {
1104 var a = AstFactory.interpolationString('"""a', "a"); 1139 var a = AstTestFactory.interpolationString('"""a', "a");
1105 var c = AstFactory.interpolationString('ccc"""', "ccc"); 1140 var c = AstTestFactory.interpolationString('ccc"""', "ccc");
1106 StringInterpolation node = AstFactory.string([a, b, c]); 1141 StringInterpolation node = AstTestFactory.string([a, b, c]);
1107 expect(node.isSingleQuoted, isFalse); 1142 expect(node.isSingleQuoted, isFalse);
1108 } 1143 }
1109 // ' 1144 // '
1110 { 1145 {
1111 var a = AstFactory.interpolationString("'a", "a"); 1146 var a = AstTestFactory.interpolationString("'a", "a");
1112 var c = AstFactory.interpolationString("ccc'", "ccc"); 1147 var c = AstTestFactory.interpolationString("ccc'", "ccc");
1113 StringInterpolation node = AstFactory.string([a, b, c]); 1148 StringInterpolation node = AstTestFactory.string([a, b, c]);
1114 expect(node.isSingleQuoted, isTrue); 1149 expect(node.isSingleQuoted, isTrue);
1115 } 1150 }
1116 // ''' 1151 // '''
1117 { 1152 {
1118 var a = AstFactory.interpolationString("'''a", "a"); 1153 var a = AstTestFactory.interpolationString("'''a", "a");
1119 var c = AstFactory.interpolationString("ccc'''", "ccc"); 1154 var c = AstTestFactory.interpolationString("ccc'''", "ccc");
1120 StringInterpolation node = AstFactory.string([a, b, c]); 1155 StringInterpolation node = AstTestFactory.string([a, b, c]);
1121 expect(node.isSingleQuoted, isTrue); 1156 expect(node.isSingleQuoted, isTrue);
1122 } 1157 }
1123 } 1158 }
1124 } 1159 }
1125 1160
1126 @reflectiveTest 1161 @reflectiveTest
1127 class VariableDeclarationTest extends ParserTestCase { 1162 class VariableDeclarationTest extends ParserTestCase {
1128 void test_getDocumentationComment_onGrandParent() { 1163 void test_getDocumentationComment_onGrandParent() {
1129 VariableDeclaration varDecl = AstFactory.variableDeclaration("a"); 1164 VariableDeclaration varDecl = AstTestFactory.variableDeclaration("a");
1130 TopLevelVariableDeclaration decl = 1165 TopLevelVariableDeclaration decl =
1131 AstFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]); 1166 AstTestFactory.topLevelVariableDeclaration2(Keyword.VAR, [varDecl]);
1132 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 1167 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
1133 expect(varDecl.documentationComment, isNull); 1168 expect(varDecl.documentationComment, isNull);
1134 decl.documentationComment = comment; 1169 decl.documentationComment = comment;
1135 expect(varDecl.documentationComment, isNotNull); 1170 expect(varDecl.documentationComment, isNotNull);
1136 expect(decl.documentationComment, isNotNull); 1171 expect(decl.documentationComment, isNotNull);
1137 } 1172 }
1138 1173
1139 void test_getDocumentationComment_onNode() { 1174 void test_getDocumentationComment_onNode() {
1140 VariableDeclaration decl = AstFactory.variableDeclaration("a"); 1175 VariableDeclaration decl = AstTestFactory.variableDeclaration("a");
1141 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 1176 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
1142 decl.documentationComment = comment; 1177 decl.documentationComment = comment;
1143 expect(decl.documentationComment, isNotNull); 1178 expect(decl.documentationComment, isNotNull);
1144 } 1179 }
1145 } 1180 }
1146 1181
1147 class _AssignmentKind { 1182 class _AssignmentKind {
1148 static const _AssignmentKind BINARY = const _AssignmentKind('BINARY', 0); 1183 static const _AssignmentKind BINARY = const _AssignmentKind('BINARY', 0);
1149 1184
1150 static const _AssignmentKind COMPOUND_LEFT = 1185 static const _AssignmentKind COMPOUND_LEFT =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 final int ordinal; 1262 final int ordinal;
1228 1263
1229 const _WrapperKind(this.name, this.ordinal); 1264 const _WrapperKind(this.name, this.ordinal);
1230 1265
1231 int get hashCode => ordinal; 1266 int get hashCode => ordinal;
1232 1267
1233 int compareTo(_WrapperKind other) => ordinal - other.ordinal; 1268 int compareTo(_WrapperKind other) => ordinal - other.ordinal;
1234 1269
1235 String toString() => name; 1270 String toString() => name;
1236 } 1271 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | pkg/analyzer/test/dart/element/builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698