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

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

Issue 685573002: Inline JUnitTestCase 'assert' methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.ast_test; 8 library engine.ast_test;
9 9
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
11 import 'package:analyzer/src/generated/java_engine.dart'; 11 import 'package:analyzer/src/generated/java_engine.dart';
12 import 'package:analyzer/src/generated/java_junit.dart';
13 import 'package:analyzer/src/generated/java_engine.dart' show Predicate; 12 import 'package:analyzer/src/generated/java_engine.dart' show Predicate;
14 import 'package:analyzer/src/generated/scanner.dart'; 13 import 'package:analyzer/src/generated/scanner.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 14 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:unittest/unittest.dart' as _ut; 15 import 'package:unittest/unittest.dart';
17 import 'parser_test.dart' show ParserTestCase; 16 import 'parser_test.dart' show ParserTestCase;
18 import 'test_support.dart'; 17 import 'test_support.dart';
19 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 18 import 'package:analyzer/src/generated/testing/ast_factory.dart';
20 import 'package:analyzer/src/generated/testing/token_factory.dart'; 19 import 'package:analyzer/src/generated/testing/token_factory.dart';
21 20
22 import '../reflective_tests.dart'; 21 import '../reflective_tests.dart';
23 22
24 23
25 class AssignmentKind extends Enum<AssignmentKind> { 24 class AssignmentKind extends Enum<AssignmentKind> {
26 static const AssignmentKind BINARY = const AssignmentKind('BINARY', 0); 25 static const AssignmentKind BINARY = const AssignmentKind('BINARY', 0);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 104 }
106 } 105 }
107 106
108 class ClassDeclarationTest extends ParserTestCase { 107 class ClassDeclarationTest extends ParserTestCase {
109 void test_getConstructor() { 108 void test_getConstructor() {
110 List<ConstructorInitializer> initializers = new List<ConstructorInitializer> (); 109 List<ConstructorInitializer> initializers = new List<ConstructorInitializer> ();
111 ConstructorDeclaration defaultConstructor = AstFactory.constructorDeclaratio n(AstFactory.identifier3("Test"), null, AstFactory.formalParameterList([]), init ializers); 110 ConstructorDeclaration defaultConstructor = AstFactory.constructorDeclaratio n(AstFactory.identifier3("Test"), null, AstFactory.formalParameterList([]), init ializers);
112 ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration(AstF actory.identifier3("Test"), "a", AstFactory.formalParameterList([]), initializer s); 111 ConstructorDeclaration aConstructor = AstFactory.constructorDeclaration(AstF actory.identifier3("Test"), "a", AstFactory.formalParameterList([]), initializer s);
113 ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration(AstF actory.identifier3("Test"), "b", AstFactory.formalParameterList([]), initializer s); 112 ConstructorDeclaration bConstructor = AstFactory.constructorDeclaration(AstF actory.identifier3("Test"), "b", AstFactory.formalParameterList([]), initializer s);
114 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul l, null, null, [defaultConstructor, aConstructor, bConstructor]); 113 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul l, null, null, [defaultConstructor, aConstructor, bConstructor]);
115 JUnitTestCase.assertSame(defaultConstructor, clazz.getConstructor(null)); 114 expect(clazz.getConstructor(null), same(defaultConstructor));
116 JUnitTestCase.assertSame(aConstructor, clazz.getConstructor("a")); 115 expect(clazz.getConstructor("a"), same(aConstructor));
117 JUnitTestCase.assertSame(bConstructor, clazz.getConstructor("b")); 116 expect(clazz.getConstructor("b"), same(bConstructor));
118 JUnitTestCase.assertSame(null, clazz.getConstructor("noSuchConstructor")); 117 expect(clazz.getConstructor("noSuchConstructor"), same(null));
119 } 118 }
120 119
121 void test_getField() { 120 void test_getField() {
122 VariableDeclaration aVar = AstFactory.variableDeclaration("a"); 121 VariableDeclaration aVar = AstFactory.variableDeclaration("a");
123 VariableDeclaration bVar = AstFactory.variableDeclaration("b"); 122 VariableDeclaration bVar = AstFactory.variableDeclaration("b");
124 VariableDeclaration cVar = AstFactory.variableDeclaration("c"); 123 VariableDeclaration cVar = AstFactory.variableDeclaration("c");
125 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul l, null, null, [ 124 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul l, null, null, [
126 AstFactory.fieldDeclaration2(false, null, [aVar]), 125 AstFactory.fieldDeclaration2(false, null, [aVar]),
127 AstFactory.fieldDeclaration2(false, null, [bVar, cVar])]); 126 AstFactory.fieldDeclaration2(false, null, [bVar, cVar])]);
128 JUnitTestCase.assertSame(aVar, clazz.getField("a")); 127 expect(clazz.getField("a"), same(aVar));
129 JUnitTestCase.assertSame(bVar, clazz.getField("b")); 128 expect(clazz.getField("b"), same(bVar));
130 JUnitTestCase.assertSame(cVar, clazz.getField("c")); 129 expect(clazz.getField("c"), same(cVar));
131 JUnitTestCase.assertSame(null, clazz.getField("noSuchField")); 130 expect(clazz.getField("noSuchField"), same(null));
132 } 131 }
133 132
134 void test_getMethod() { 133 void test_getMethod() {
135 MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null, n ull, AstFactory.identifier3("a"), AstFactory.formalParameterList([])); 134 MethodDeclaration aMethod = AstFactory.methodDeclaration(null, null, null, n ull, AstFactory.identifier3("a"), AstFactory.formalParameterList([]));
136 MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null, n ull, AstFactory.identifier3("b"), AstFactory.formalParameterList([])); 135 MethodDeclaration bMethod = AstFactory.methodDeclaration(null, null, null, n ull, AstFactory.identifier3("b"), AstFactory.formalParameterList([]));
137 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul l, null, null, [aMethod, bMethod]); 136 ClassDeclaration clazz = AstFactory.classDeclaration(null, "Test", null, nul l, null, null, [aMethod, bMethod]);
138 JUnitTestCase.assertSame(aMethod, clazz.getMethod("a")); 137 expect(clazz.getMethod("a"), same(aMethod));
139 JUnitTestCase.assertSame(bMethod, clazz.getMethod("b")); 138 expect(clazz.getMethod("b"), same(bMethod));
140 JUnitTestCase.assertSame(null, clazz.getMethod("noSuchMethod")); 139 expect(clazz.getMethod("noSuchMethod"), same(null));
141 } 140 }
142 141
143 void test_isAbstract() { 142 void test_isAbstract() {
144 JUnitTestCase.assertFalse(AstFactory.classDeclaration(null, "A", null, null, null, null, []).isAbstract); 143 expect(AstFactory.classDeclaration(null, "A", null, null, null, null, []).is Abstract, isFalse);
145 JUnitTestCase.assertTrue(AstFactory.classDeclaration(Keyword.ABSTRACT, "B", null, null, null, null, []).isAbstract); 144 expect(AstFactory.classDeclaration(Keyword.ABSTRACT, "B", null, null, null, null, []).isAbstract, isTrue);
146 } 145 }
147 } 146 }
148 147
149 class ClassTypeAliasTest extends ParserTestCase { 148 class ClassTypeAliasTest extends ParserTestCase {
150 void test_isAbstract() { 149 void test_isAbstract() {
151 JUnitTestCase.assertFalse(AstFactory.classTypeAlias("A", null, null, null, n ull, null).isAbstract); 150 expect(AstFactory.classTypeAlias("A", null, null, null, null, null).isAbstra ct, isFalse);
152 JUnitTestCase.assertTrue(AstFactory.classTypeAlias("B", null, Keyword.ABSTRA CT, null, null, null).isAbstract); 151 expect(AstFactory.classTypeAlias("B", null, Keyword.ABSTRACT, null, null, nu ll).isAbstract, isTrue);
153 } 152 }
154 } 153 }
155 154
156 class ConstantEvaluatorTest extends ParserTestCase { 155 class ConstantEvaluatorTest extends ParserTestCase {
157 void fail_constructor() { 156 void fail_constructor() {
158 Object value = _getConstantValue("?"); 157 Object value = _getConstantValue("?");
159 JUnitTestCase.assertEquals(null, value); 158 expect(value, null);
160 } 159 }
161 160
162 void fail_identifier_class() { 161 void fail_identifier_class() {
163 Object value = _getConstantValue("?"); 162 Object value = _getConstantValue("?");
164 JUnitTestCase.assertEquals(null, value); 163 expect(value, null);
165 } 164 }
166 165
167 void fail_identifier_function() { 166 void fail_identifier_function() {
168 Object value = _getConstantValue("?"); 167 Object value = _getConstantValue("?");
169 JUnitTestCase.assertEquals(null, value); 168 expect(value, null);
170 } 169 }
171 170
172 void fail_identifier_static() { 171 void fail_identifier_static() {
173 Object value = _getConstantValue("?"); 172 Object value = _getConstantValue("?");
174 JUnitTestCase.assertEquals(null, value); 173 expect(value, null);
175 } 174 }
176 175
177 void fail_identifier_staticMethod() { 176 void fail_identifier_staticMethod() {
178 Object value = _getConstantValue("?"); 177 Object value = _getConstantValue("?");
179 JUnitTestCase.assertEquals(null, value); 178 expect(value, null);
180 } 179 }
181 180
182 void fail_identifier_topLevel() { 181 void fail_identifier_topLevel() {
183 Object value = _getConstantValue("?"); 182 Object value = _getConstantValue("?");
184 JUnitTestCase.assertEquals(null, value); 183 expect(value, null);
185 } 184 }
186 185
187 void fail_identifier_typeParameter() { 186 void fail_identifier_typeParameter() {
188 Object value = _getConstantValue("?"); 187 Object value = _getConstantValue("?");
189 JUnitTestCase.assertEquals(null, value); 188 expect(value, null);
190 } 189 }
191 190
192 void test_binary_bitAnd() { 191 void test_binary_bitAnd() {
193 Object value = _getConstantValue("74 & 42"); 192 Object value = _getConstantValue("74 & 42");
194 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 193 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
195 JUnitTestCase.assertEquals(74 & 42, value as int); 194 expect(value as int, 74 & 42);
196 } 195 }
197 196
198 void test_binary_bitOr() { 197 void test_binary_bitOr() {
199 Object value = _getConstantValue("74 | 42"); 198 Object value = _getConstantValue("74 | 42");
200 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 199 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
201 JUnitTestCase.assertEquals(74 | 42, value as int); 200 expect(value as int, 74 | 42);
202 } 201 }
203 202
204 void test_binary_bitXor() { 203 void test_binary_bitXor() {
205 Object value = _getConstantValue("74 ^ 42"); 204 Object value = _getConstantValue("74 ^ 42");
206 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 205 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
207 JUnitTestCase.assertEquals(74 ^ 42, value as int); 206 expect(value as int, 74 ^ 42);
208 } 207 }
209 208
210 void test_binary_divide_double() { 209 void test_binary_divide_double() {
211 Object value = _getConstantValue("3.2 / 2.3"); 210 Object value = _getConstantValue("3.2 / 2.3");
212 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 211 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
213 JUnitTestCase.assertEquals(3.2 / 2.3, value as double); 212 expect(value as double, 3.2 / 2.3);
214 } 213 }
215 214
216 void test_binary_divide_integer() { 215 void test_binary_divide_integer() {
217 Object value = _getConstantValue("3 / 2"); 216 Object value = _getConstantValue("3 / 2");
218 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 217 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
219 JUnitTestCase.assertEquals(1, value as int); 218 expect(value as int, 1);
220 } 219 }
221 220
222 void test_binary_equal_boolean() { 221 void test_binary_equal_boolean() {
223 Object value = _getConstantValue("true == false"); 222 Object value = _getConstantValue("true == false");
224 JUnitTestCase.assertEquals(false, value); 223 expect(value, false);
225 } 224 }
226 225
227 void test_binary_equal_integer() { 226 void test_binary_equal_integer() {
228 Object value = _getConstantValue("2 == 3"); 227 Object value = _getConstantValue("2 == 3");
229 JUnitTestCase.assertEquals(false, value); 228 expect(value, false);
230 } 229 }
231 230
232 void test_binary_equal_invalidLeft() { 231 void test_binary_equal_invalidLeft() {
233 Object value = _getConstantValue("a == 3"); 232 Object value = _getConstantValue("a == 3");
234 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); 233 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
235 } 234 }
236 235
237 void test_binary_equal_invalidRight() { 236 void test_binary_equal_invalidRight() {
238 Object value = _getConstantValue("2 == a"); 237 Object value = _getConstantValue("2 == a");
239 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); 238 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
240 } 239 }
241 240
242 void test_binary_equal_string() { 241 void test_binary_equal_string() {
243 Object value = _getConstantValue("'a' == 'b'"); 242 Object value = _getConstantValue("'a' == 'b'");
244 JUnitTestCase.assertEquals(false, value); 243 expect(value, false);
245 } 244 }
246 245
247 void test_binary_greaterThan() { 246 void test_binary_greaterThan() {
248 Object value = _getConstantValue("2 > 3"); 247 Object value = _getConstantValue("2 > 3");
249 JUnitTestCase.assertEquals(false, value); 248 expect(value, false);
250 } 249 }
251 250
252 void test_binary_greaterThanOrEqual() { 251 void test_binary_greaterThanOrEqual() {
253 Object value = _getConstantValue("2 >= 3"); 252 Object value = _getConstantValue("2 >= 3");
254 JUnitTestCase.assertEquals(false, value); 253 expect(value, false);
255 } 254 }
256 255
257 void test_binary_leftShift() { 256 void test_binary_leftShift() {
258 Object value = _getConstantValue("16 << 2"); 257 Object value = _getConstantValue("16 << 2");
259 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 258 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
260 JUnitTestCase.assertEquals(64, value as int); 259 expect(value as int, 64);
261 } 260 }
262 261
263 void test_binary_lessThan() { 262 void test_binary_lessThan() {
264 Object value = _getConstantValue("2 < 3"); 263 Object value = _getConstantValue("2 < 3");
265 JUnitTestCase.assertEquals(true, value); 264 expect(value, true);
266 } 265 }
267 266
268 void test_binary_lessThanOrEqual() { 267 void test_binary_lessThanOrEqual() {
269 Object value = _getConstantValue("2 <= 3"); 268 Object value = _getConstantValue("2 <= 3");
270 JUnitTestCase.assertEquals(true, value); 269 expect(value, true);
271 } 270 }
272 271
273 void test_binary_logicalAnd() { 272 void test_binary_logicalAnd() {
274 Object value = _getConstantValue("true && false"); 273 Object value = _getConstantValue("true && false");
275 JUnitTestCase.assertEquals(false, value); 274 expect(value, false);
276 } 275 }
277 276
278 void test_binary_logicalOr() { 277 void test_binary_logicalOr() {
279 Object value = _getConstantValue("true || false"); 278 Object value = _getConstantValue("true || false");
280 JUnitTestCase.assertEquals(true, value); 279 expect(value, true);
281 } 280 }
282 281
283 void test_binary_minus_double() { 282 void test_binary_minus_double() {
284 Object value = _getConstantValue("3.2 - 2.3"); 283 Object value = _getConstantValue("3.2 - 2.3");
285 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 284 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
286 JUnitTestCase.assertEquals(3.2 - 2.3, value as double); 285 expect(value as double, 3.2 - 2.3);
287 } 286 }
288 287
289 void test_binary_minus_integer() { 288 void test_binary_minus_integer() {
290 Object value = _getConstantValue("3 - 2"); 289 Object value = _getConstantValue("3 - 2");
291 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 290 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
292 JUnitTestCase.assertEquals(1, value as int); 291 expect(value as int, 1);
293 } 292 }
294 293
295 void test_binary_notEqual_boolean() { 294 void test_binary_notEqual_boolean() {
296 Object value = _getConstantValue("true != false"); 295 Object value = _getConstantValue("true != false");
297 JUnitTestCase.assertEquals(true, value); 296 expect(value, true);
298 } 297 }
299 298
300 void test_binary_notEqual_integer() { 299 void test_binary_notEqual_integer() {
301 Object value = _getConstantValue("2 != 3"); 300 Object value = _getConstantValue("2 != 3");
302 JUnitTestCase.assertEquals(true, value); 301 expect(value, true);
303 } 302 }
304 303
305 void test_binary_notEqual_invalidLeft() { 304 void test_binary_notEqual_invalidLeft() {
306 Object value = _getConstantValue("a != 3"); 305 Object value = _getConstantValue("a != 3");
307 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); 306 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
308 } 307 }
309 308
310 void test_binary_notEqual_invalidRight() { 309 void test_binary_notEqual_invalidRight() {
311 Object value = _getConstantValue("2 != a"); 310 Object value = _getConstantValue("2 != a");
312 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); 311 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
313 } 312 }
314 313
315 void test_binary_notEqual_string() { 314 void test_binary_notEqual_string() {
316 Object value = _getConstantValue("'a' != 'b'"); 315 Object value = _getConstantValue("'a' != 'b'");
317 JUnitTestCase.assertEquals(true, value); 316 expect(value, true);
318 } 317 }
319 318
320 void test_binary_plus_double() { 319 void test_binary_plus_double() {
321 Object value = _getConstantValue("2.3 + 3.2"); 320 Object value = _getConstantValue("2.3 + 3.2");
322 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 321 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
323 JUnitTestCase.assertEquals(2.3 + 3.2, value as double); 322 expect(value as double, 2.3 + 3.2);
324 } 323 }
325 324
326 void test_binary_plus_integer() { 325 void test_binary_plus_integer() {
327 Object value = _getConstantValue("2 + 3"); 326 Object value = _getConstantValue("2 + 3");
328 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 327 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
329 JUnitTestCase.assertEquals(5, value as int); 328 expect(value as int, 5);
330 } 329 }
331 330
332 void test_binary_remainder_double() { 331 void test_binary_remainder_double() {
333 Object value = _getConstantValue("3.2 % 2.3"); 332 Object value = _getConstantValue("3.2 % 2.3");
334 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 333 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
335 JUnitTestCase.assertEquals(3.2 % 2.3, value as double); 334 expect(value as double, 3.2 % 2.3);
336 } 335 }
337 336
338 void test_binary_remainder_integer() { 337 void test_binary_remainder_integer() {
339 Object value = _getConstantValue("8 % 3"); 338 Object value = _getConstantValue("8 % 3");
340 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 339 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
341 JUnitTestCase.assertEquals(2, value as int); 340 expect(value as int, 2);
342 } 341 }
343 342
344 void test_binary_rightShift() { 343 void test_binary_rightShift() {
345 Object value = _getConstantValue("64 >> 2"); 344 Object value = _getConstantValue("64 >> 2");
346 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 345 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
347 JUnitTestCase.assertEquals(16, value as int); 346 expect(value as int, 16);
348 } 347 }
349 348
350 void test_binary_times_double() { 349 void test_binary_times_double() {
351 Object value = _getConstantValue("2.3 * 3.2"); 350 Object value = _getConstantValue("2.3 * 3.2");
352 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 351 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
353 JUnitTestCase.assertEquals(2.3 * 3.2, value as double); 352 expect(value as double, 2.3 * 3.2);
354 } 353 }
355 354
356 void test_binary_times_integer() { 355 void test_binary_times_integer() {
357 Object value = _getConstantValue("2 * 3"); 356 Object value = _getConstantValue("2 * 3");
358 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 357 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
359 JUnitTestCase.assertEquals(6, value as int); 358 expect(value as int, 6);
360 } 359 }
361 360
362 void test_binary_truncatingDivide_double() { 361 void test_binary_truncatingDivide_double() {
363 Object value = _getConstantValue("3.2 ~/ 2.3"); 362 Object value = _getConstantValue("3.2 ~/ 2.3");
364 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 363 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
365 JUnitTestCase.assertEquals(1, value as int); 364 expect(value as int, 1);
366 } 365 }
367 366
368 void test_binary_truncatingDivide_integer() { 367 void test_binary_truncatingDivide_integer() {
369 Object value = _getConstantValue("10 ~/ 3"); 368 Object value = _getConstantValue("10 ~/ 3");
370 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 369 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
371 JUnitTestCase.assertEquals(3, value as int); 370 expect(value as int, 3);
372 } 371 }
373 372
374 void test_literal_boolean_false() { 373 void test_literal_boolean_false() {
375 Object value = _getConstantValue("false"); 374 Object value = _getConstantValue("false");
376 JUnitTestCase.assertEquals(false, value); 375 expect(value, false);
377 } 376 }
378 377
379 void test_literal_boolean_true() { 378 void test_literal_boolean_true() {
380 Object value = _getConstantValue("true"); 379 Object value = _getConstantValue("true");
381 JUnitTestCase.assertEquals(true, value); 380 expect(value, true);
382 } 381 }
383 382
384 void test_literal_list() { 383 void test_literal_list() {
385 Object value = _getConstantValue("['a', 'b', 'c']"); 384 Object value = _getConstantValue("['a', 'b', 'c']");
386 EngineTestCase.assertInstanceOf((obj) => obj is List, List, value); 385 EngineTestCase.assertInstanceOf((obj) => obj is List, List, value);
387 List list = value as List; 386 List list = value as List;
388 JUnitTestCase.assertEquals(3, list.length); 387 expect(list.length, 3);
389 JUnitTestCase.assertEquals("a", list[0]); 388 expect(list[0], "a");
390 JUnitTestCase.assertEquals("b", list[1]); 389 expect(list[1], "b");
391 JUnitTestCase.assertEquals("c", list[2]); 390 expect(list[2], "c");
392 } 391 }
393 392
394 void test_literal_map() { 393 void test_literal_map() {
395 Object value = _getConstantValue("{'a' : 'm', 'b' : 'n', 'c' : 'o'}"); 394 Object value = _getConstantValue("{'a' : 'm', 'b' : 'n', 'c' : 'o'}");
396 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, value); 395 EngineTestCase.assertInstanceOf((obj) => obj is Map, Map, value);
397 Map map = value as Map; 396 Map map = value as Map;
398 JUnitTestCase.assertEquals(3, map.length); 397 expect(map.length, 3);
399 JUnitTestCase.assertEquals("m", map["a"]); 398 expect(map["a"], "m");
400 JUnitTestCase.assertEquals("n", map["b"]); 399 expect(map["b"], "n");
401 JUnitTestCase.assertEquals("o", map["c"]); 400 expect(map["c"], "o");
402 } 401 }
403 402
404 void test_literal_null() { 403 void test_literal_null() {
405 Object value = _getConstantValue("null"); 404 Object value = _getConstantValue("null");
406 JUnitTestCase.assertEquals(null, value); 405 expect(value, null);
407 } 406 }
408 407
409 void test_literal_number_double() { 408 void test_literal_number_double() {
410 Object value = _getConstantValue("3.45"); 409 Object value = _getConstantValue("3.45");
411 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 410 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
412 JUnitTestCase.assertEquals(3.45, value as double); 411 expect(value as double, 3.45);
413 } 412 }
414 413
415 void test_literal_number_integer() { 414 void test_literal_number_integer() {
416 Object value = _getConstantValue("42"); 415 Object value = _getConstantValue("42");
417 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 416 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
418 JUnitTestCase.assertEquals(42, value as int); 417 expect(value as int, 42);
419 } 418 }
420 419
421 void test_literal_string_adjacent() { 420 void test_literal_string_adjacent() {
422 Object value = _getConstantValue("'abc' 'def'"); 421 Object value = _getConstantValue("'abc' 'def'");
423 JUnitTestCase.assertEquals("abcdef", value); 422 expect(value, "abcdef");
424 } 423 }
425 424
426 void test_literal_string_interpolation_invalid() { 425 void test_literal_string_interpolation_invalid() {
427 Object value = _getConstantValue("'a\${f()}c'"); 426 Object value = _getConstantValue("'a\${f()}c'");
428 JUnitTestCase.assertEquals(ConstantEvaluator.NOT_A_CONSTANT, value); 427 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
429 } 428 }
430 429
431 void test_literal_string_interpolation_valid() { 430 void test_literal_string_interpolation_valid() {
432 Object value = _getConstantValue("'a\${3}c'"); 431 Object value = _getConstantValue("'a\${3}c'");
433 JUnitTestCase.assertEquals("a3c", value); 432 expect(value, "a3c");
434 } 433 }
435 434
436 void test_literal_string_simple() { 435 void test_literal_string_simple() {
437 Object value = _getConstantValue("'abc'"); 436 Object value = _getConstantValue("'abc'");
438 JUnitTestCase.assertEquals("abc", value); 437 expect(value, "abc");
439 } 438 }
440 439
441 void test_parenthesizedExpression() { 440 void test_parenthesizedExpression() {
442 Object value = _getConstantValue("('a')"); 441 Object value = _getConstantValue("('a')");
443 JUnitTestCase.assertEquals("a", value); 442 expect(value, "a");
444 } 443 }
445 444
446 void test_unary_bitNot() { 445 void test_unary_bitNot() {
447 Object value = _getConstantValue("~42"); 446 Object value = _getConstantValue("~42");
448 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 447 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
449 JUnitTestCase.assertEquals(~42, value as int); 448 expect(value as int, ~42);
450 } 449 }
451 450
452 void test_unary_logicalNot() { 451 void test_unary_logicalNot() {
453 Object value = _getConstantValue("!true"); 452 Object value = _getConstantValue("!true");
454 JUnitTestCase.assertEquals(false, value); 453 expect(value, false);
455 } 454 }
456 455
457 void test_unary_negated_double() { 456 void test_unary_negated_double() {
458 Object value = _getConstantValue("-42.3"); 457 Object value = _getConstantValue("-42.3");
459 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 458 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value);
460 JUnitTestCase.assertEquals(-42.3, value as double); 459 expect(value as double, -42.3);
461 } 460 }
462 461
463 void test_unary_negated_integer() { 462 void test_unary_negated_integer() {
464 Object value = _getConstantValue("-42"); 463 Object value = _getConstantValue("-42");
465 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 464 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
466 JUnitTestCase.assertEquals(-42, value as int); 465 expect(value as int, -42);
467 } 466 }
468 467
469 Object _getConstantValue(String source) => ParserTestCase.parseExpression(sour ce, []).accept(new ConstantEvaluator()); 468 Object _getConstantValue(String source) => ParserTestCase.parseExpression(sour ce, []).accept(new ConstantEvaluator());
470 } 469 }
471 470
472 class IndexExpressionTest extends EngineTestCase { 471 class IndexExpressionTest extends EngineTestCase {
473 void test_inGetterContext_assignment_compound_left() { 472 void test_inGetterContext_assignment_compound_left() {
474 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 473 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
475 // a[b] += c 474 // a[b] += c
476 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id entifier3("c")); 475 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id entifier3("c"));
477 JUnitTestCase.assertTrue(expression.inGetterContext()); 476 expect(expression.inGetterContext(), isTrue);
478 } 477 }
479 478
480 void test_inGetterContext_assignment_simple_left() { 479 void test_inGetterContext_assignment_simple_left() {
481 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 480 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
482 // a[b] = c 481 // a[b] = c
483 AstFactory.assignmentExpression(expression, TokenType.EQ, AstFactory.identif ier3("c")); 482 AstFactory.assignmentExpression(expression, TokenType.EQ, AstFactory.identif ier3("c"));
484 JUnitTestCase.assertFalse(expression.inGetterContext()); 483 expect(expression.inGetterContext(), isFalse);
485 } 484 }
486 485
487 void test_inGetterContext_nonAssignment() { 486 void test_inGetterContext_nonAssignment() {
488 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 487 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
489 // a[b] + c 488 // a[b] + c
490 AstFactory.binaryExpression(expression, TokenType.PLUS, AstFactory.identifie r3("c")); 489 AstFactory.binaryExpression(expression, TokenType.PLUS, AstFactory.identifie r3("c"));
491 JUnitTestCase.assertTrue(expression.inGetterContext()); 490 expect(expression.inGetterContext(), isTrue);
492 } 491 }
493 492
494 void test_inSetterContext_assignment_compound_left() { 493 void test_inSetterContext_assignment_compound_left() {
495 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 494 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
496 // a[b] += c 495 // a[b] += c
497 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id entifier3("c")); 496 AstFactory.assignmentExpression(expression, TokenType.PLUS_EQ, AstFactory.id entifier3("c"));
498 JUnitTestCase.assertTrue(expression.inSetterContext()); 497 expect(expression.inSetterContext(), isTrue);
499 } 498 }
500 499
501 void test_inSetterContext_assignment_compound_right() { 500 void test_inSetterContext_assignment_compound_right() {
502 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 501 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
503 // c += a[b] 502 // c += a[b]
504 AstFactory.assignmentExpression(AstFactory.identifier3("c"), TokenType.PLUS_ EQ, expression); 503 AstFactory.assignmentExpression(AstFactory.identifier3("c"), TokenType.PLUS_ EQ, expression);
505 JUnitTestCase.assertFalse(expression.inSetterContext()); 504 expect(expression.inSetterContext(), isFalse);
506 } 505 }
507 506
508 void test_inSetterContext_assignment_simple_left() { 507 void test_inSetterContext_assignment_simple_left() {
509 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 508 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
510 // a[b] = c 509 // a[b] = c
511 AstFactory.assignmentExpression(expression, TokenType.EQ, AstFactory.identif ier3("c")); 510 AstFactory.assignmentExpression(expression, TokenType.EQ, AstFactory.identif ier3("c"));
512 JUnitTestCase.assertTrue(expression.inSetterContext()); 511 expect(expression.inSetterContext(), isTrue);
513 } 512 }
514 513
515 void test_inSetterContext_assignment_simple_right() { 514 void test_inSetterContext_assignment_simple_right() {
516 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 515 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
517 // c = a[b] 516 // c = a[b]
518 AstFactory.assignmentExpression(AstFactory.identifier3("c"), TokenType.EQ, e xpression); 517 AstFactory.assignmentExpression(AstFactory.identifier3("c"), TokenType.EQ, e xpression);
519 JUnitTestCase.assertFalse(expression.inSetterContext()); 518 expect(expression.inSetterContext(), isFalse);
520 } 519 }
521 520
522 void test_inSetterContext_nonAssignment() { 521 void test_inSetterContext_nonAssignment() {
523 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 522 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
524 AstFactory.binaryExpression(expression, TokenType.PLUS, AstFactory.identifie r3("c")); 523 AstFactory.binaryExpression(expression, TokenType.PLUS, AstFactory.identifie r3("c"));
525 // a[b] + cc 524 // a[b] + cc
526 JUnitTestCase.assertFalse(expression.inSetterContext()); 525 expect(expression.inSetterContext(), isFalse);
527 } 526 }
528 527
529 void test_inSetterContext_postfix() { 528 void test_inSetterContext_postfix() {
530 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 529 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
531 AstFactory.postfixExpression(expression, TokenType.PLUS_PLUS); 530 AstFactory.postfixExpression(expression, TokenType.PLUS_PLUS);
532 // a[b]++ 531 // a[b]++
533 JUnitTestCase.assertTrue(expression.inSetterContext()); 532 expect(expression.inSetterContext(), isTrue);
534 } 533 }
535 534
536 void test_inSetterContext_prefix_bang() { 535 void test_inSetterContext_prefix_bang() {
537 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 536 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
538 // !a[b] 537 // !a[b]
539 AstFactory.prefixExpression(TokenType.BANG, expression); 538 AstFactory.prefixExpression(TokenType.BANG, expression);
540 JUnitTestCase.assertFalse(expression.inSetterContext()); 539 expect(expression.inSetterContext(), isFalse);
541 } 540 }
542 541
543 void test_inSetterContext_prefix_minusMinus() { 542 void test_inSetterContext_prefix_minusMinus() {
544 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 543 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
545 // --a[b] 544 // --a[b]
546 AstFactory.prefixExpression(TokenType.MINUS_MINUS, expression); 545 AstFactory.prefixExpression(TokenType.MINUS_MINUS, expression);
547 JUnitTestCase.assertTrue(expression.inSetterContext()); 546 expect(expression.inSetterContext(), isTrue);
548 } 547 }
549 548
550 void test_inSetterContext_prefix_plusPlus() { 549 void test_inSetterContext_prefix_plusPlus() {
551 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b")); 550 IndexExpression expression = AstFactory.indexExpression(AstFactory.identifie r3("a"), AstFactory.identifier3("b"));
552 // ++a[b] 551 // ++a[b]
553 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression); 552 AstFactory.prefixExpression(TokenType.PLUS_PLUS, expression);
554 JUnitTestCase.assertTrue(expression.inSetterContext()); 553 expect(expression.inSetterContext(), isTrue);
555 } 554 }
556 } 555 }
557 556
558 class NodeListTest extends EngineTestCase { 557 class NodeListTest extends EngineTestCase {
559 void test_add() { 558 void test_add() {
560 AstNode parent = AstFactory.argumentList([]); 559 AstNode parent = AstFactory.argumentList([]);
561 AstNode firstNode = AstFactory.booleanLiteral(true); 560 AstNode firstNode = AstFactory.booleanLiteral(true);
562 AstNode secondNode = AstFactory.booleanLiteral(false); 561 AstNode secondNode = AstFactory.booleanLiteral(false);
563 NodeList<AstNode> list = new NodeList<AstNode>(parent); 562 NodeList<AstNode> list = new NodeList<AstNode>(parent);
564 list.insert(0, secondNode); 563 list.insert(0, secondNode);
565 list.insert(0, firstNode); 564 list.insert(0, firstNode);
566 EngineTestCase.assertSizeOfList(2, list); 565 EngineTestCase.assertSizeOfList(2, list);
567 JUnitTestCase.assertSame(firstNode, list[0]); 566 expect(list[0], same(firstNode));
568 JUnitTestCase.assertSame(secondNode, list[1]); 567 expect(list[1], same(secondNode));
569 JUnitTestCase.assertSame(parent, firstNode.parent); 568 expect(firstNode.parent, same(parent));
570 JUnitTestCase.assertSame(parent, secondNode.parent); 569 expect(secondNode.parent, same(parent));
571 AstNode thirdNode = AstFactory.booleanLiteral(false); 570 AstNode thirdNode = AstFactory.booleanLiteral(false);
572 list.insert(1, thirdNode); 571 list.insert(1, thirdNode);
573 EngineTestCase.assertSizeOfList(3, list); 572 EngineTestCase.assertSizeOfList(3, list);
574 JUnitTestCase.assertSame(firstNode, list[0]); 573 expect(list[0], same(firstNode));
575 JUnitTestCase.assertSame(thirdNode, list[1]); 574 expect(list[1], same(thirdNode));
576 JUnitTestCase.assertSame(secondNode, list[2]); 575 expect(list[2], same(secondNode));
577 JUnitTestCase.assertSame(parent, firstNode.parent); 576 expect(firstNode.parent, same(parent));
578 JUnitTestCase.assertSame(parent, secondNode.parent); 577 expect(secondNode.parent, same(parent));
579 JUnitTestCase.assertSame(parent, thirdNode.parent); 578 expect(thirdNode.parent, same(parent));
580 } 579 }
581 580
582 void test_add_negative() { 581 void test_add_negative() {
583 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 582 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
584 try { 583 try {
585 list.insert(-1, AstFactory.booleanLiteral(true)); 584 list.insert(-1, AstFactory.booleanLiteral(true));
586 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 585 fail("Expected IndexOutOfBoundsException");
587 } on RangeError catch (exception) { 586 } on RangeError catch (exception) {
588 // Expected 587 // Expected
589 } 588 }
590 } 589 }
591 590
592 void test_add_tooBig() { 591 void test_add_tooBig() {
593 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 592 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
594 try { 593 try {
595 list.insert(1, AstFactory.booleanLiteral(true)); 594 list.insert(1, AstFactory.booleanLiteral(true));
596 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 595 fail("Expected IndexOutOfBoundsException");
597 } on RangeError catch (exception) { 596 } on RangeError catch (exception) {
598 // Expected 597 // Expected
599 } 598 }
600 } 599 }
601 600
602 void test_addAll() { 601 void test_addAll() {
603 AstNode parent = AstFactory.argumentList([]); 602 AstNode parent = AstFactory.argumentList([]);
604 List<AstNode> firstNodes = new List<AstNode>(); 603 List<AstNode> firstNodes = new List<AstNode>();
605 AstNode firstNode = AstFactory.booleanLiteral(true); 604 AstNode firstNode = AstFactory.booleanLiteral(true);
606 AstNode secondNode = AstFactory.booleanLiteral(false); 605 AstNode secondNode = AstFactory.booleanLiteral(false);
607 firstNodes.add(firstNode); 606 firstNodes.add(firstNode);
608 firstNodes.add(secondNode); 607 firstNodes.add(secondNode);
609 NodeList<AstNode> list = new NodeList<AstNode>(parent); 608 NodeList<AstNode> list = new NodeList<AstNode>(parent);
610 list.addAll(firstNodes); 609 list.addAll(firstNodes);
611 EngineTestCase.assertSizeOfList(2, list); 610 EngineTestCase.assertSizeOfList(2, list);
612 JUnitTestCase.assertSame(firstNode, list[0]); 611 expect(list[0], same(firstNode));
613 JUnitTestCase.assertSame(secondNode, list[1]); 612 expect(list[1], same(secondNode));
614 JUnitTestCase.assertSame(parent, firstNode.parent); 613 expect(firstNode.parent, same(parent));
615 JUnitTestCase.assertSame(parent, secondNode.parent); 614 expect(secondNode.parent, same(parent));
616 List<AstNode> secondNodes = new List<AstNode>(); 615 List<AstNode> secondNodes = new List<AstNode>();
617 AstNode thirdNode = AstFactory.booleanLiteral(true); 616 AstNode thirdNode = AstFactory.booleanLiteral(true);
618 AstNode fourthNode = AstFactory.booleanLiteral(false); 617 AstNode fourthNode = AstFactory.booleanLiteral(false);
619 secondNodes.add(thirdNode); 618 secondNodes.add(thirdNode);
620 secondNodes.add(fourthNode); 619 secondNodes.add(fourthNode);
621 list.addAll(secondNodes); 620 list.addAll(secondNodes);
622 EngineTestCase.assertSizeOfList(4, list); 621 EngineTestCase.assertSizeOfList(4, list);
623 JUnitTestCase.assertSame(firstNode, list[0]); 622 expect(list[0], same(firstNode));
624 JUnitTestCase.assertSame(secondNode, list[1]); 623 expect(list[1], same(secondNode));
625 JUnitTestCase.assertSame(thirdNode, list[2]); 624 expect(list[2], same(thirdNode));
626 JUnitTestCase.assertSame(fourthNode, list[3]); 625 expect(list[3], same(fourthNode));
627 JUnitTestCase.assertSame(parent, firstNode.parent); 626 expect(firstNode.parent, same(parent));
628 JUnitTestCase.assertSame(parent, secondNode.parent); 627 expect(secondNode.parent, same(parent));
629 JUnitTestCase.assertSame(parent, thirdNode.parent); 628 expect(thirdNode.parent, same(parent));
630 JUnitTestCase.assertSame(parent, fourthNode.parent); 629 expect(fourthNode.parent, same(parent));
631 } 630 }
632 631
633 void test_create() { 632 void test_create() {
634 AstNode owner = AstFactory.argumentList([]); 633 AstNode owner = AstFactory.argumentList([]);
635 NodeList<AstNode> list = NodeList.create(owner); 634 NodeList<AstNode> list = NodeList.create(owner);
636 JUnitTestCase.assertNotNull(list); 635 expect(list, isNotNull);
637 EngineTestCase.assertSizeOfList(0, list); 636 EngineTestCase.assertSizeOfList(0, list);
638 JUnitTestCase.assertSame(owner, list.owner); 637 expect(list.owner, same(owner));
639 } 638 }
640 639
641 void test_creation() { 640 void test_creation() {
642 AstNode owner = AstFactory.argumentList([]); 641 AstNode owner = AstFactory.argumentList([]);
643 NodeList<AstNode> list = new NodeList<AstNode>(owner); 642 NodeList<AstNode> list = new NodeList<AstNode>(owner);
644 JUnitTestCase.assertNotNull(list); 643 expect(list, isNotNull);
645 EngineTestCase.assertSizeOfList(0, list); 644 EngineTestCase.assertSizeOfList(0, list);
646 JUnitTestCase.assertSame(owner, list.owner); 645 expect(list.owner, same(owner));
647 } 646 }
648 647
649 void test_get_negative() { 648 void test_get_negative() {
650 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 649 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
651 try { 650 try {
652 list[-1]; 651 list[-1];
653 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 652 fail("Expected IndexOutOfBoundsException");
654 } on RangeError catch (exception) { 653 } on RangeError catch (exception) {
655 // Expected 654 // Expected
656 } 655 }
657 } 656 }
658 657
659 void test_get_tooBig() { 658 void test_get_tooBig() {
660 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 659 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
661 try { 660 try {
662 list[1]; 661 list[1];
663 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 662 fail("Expected IndexOutOfBoundsException");
664 } on RangeError catch (exception) { 663 } on RangeError catch (exception) {
665 // Expected 664 // Expected
666 } 665 }
667 } 666 }
668 667
669 void test_getBeginToken_empty() { 668 void test_getBeginToken_empty() {
670 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 669 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
671 JUnitTestCase.assertNull(list.beginToken); 670 expect(list.beginToken, isNull);
672 } 671 }
673 672
674 void test_getBeginToken_nonEmpty() { 673 void test_getBeginToken_nonEmpty() {
675 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 674 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
676 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral( true)); 675 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral( true));
677 list.add(node); 676 list.add(node);
678 JUnitTestCase.assertSame(node.beginToken, list.beginToken); 677 expect(list.beginToken, same(node.beginToken));
679 } 678 }
680 679
681 void test_getEndToken_empty() { 680 void test_getEndToken_empty() {
682 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 681 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
683 JUnitTestCase.assertNull(list.endToken); 682 expect(list.endToken, isNull);
684 } 683 }
685 684
686 void test_getEndToken_nonEmpty() { 685 void test_getEndToken_nonEmpty() {
687 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 686 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
688 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral( true)); 687 AstNode node = AstFactory.parenthesizedExpression(AstFactory.booleanLiteral( true));
689 list.add(node); 688 list.add(node);
690 JUnitTestCase.assertSame(node.endToken, list.endToken); 689 expect(list.endToken, same(node.endToken));
691 } 690 }
692 691
693 void test_indexOf() { 692 void test_indexOf() {
694 List<AstNode> nodes = new List<AstNode>(); 693 List<AstNode> nodes = new List<AstNode>();
695 AstNode firstNode = AstFactory.booleanLiteral(true); 694 AstNode firstNode = AstFactory.booleanLiteral(true);
696 AstNode secondNode = AstFactory.booleanLiteral(false); 695 AstNode secondNode = AstFactory.booleanLiteral(false);
697 AstNode thirdNode = AstFactory.booleanLiteral(true); 696 AstNode thirdNode = AstFactory.booleanLiteral(true);
698 AstNode fourthNode = AstFactory.booleanLiteral(false); 697 AstNode fourthNode = AstFactory.booleanLiteral(false);
699 nodes.add(firstNode); 698 nodes.add(firstNode);
700 nodes.add(secondNode); 699 nodes.add(secondNode);
701 nodes.add(thirdNode); 700 nodes.add(thirdNode);
702 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 701 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
703 list.addAll(nodes); 702 list.addAll(nodes);
704 EngineTestCase.assertSizeOfList(3, list); 703 EngineTestCase.assertSizeOfList(3, list);
705 JUnitTestCase.assertEquals(0, list.indexOf(firstNode)); 704 expect(list.indexOf(firstNode), 0);
706 JUnitTestCase.assertEquals(1, list.indexOf(secondNode)); 705 expect(list.indexOf(secondNode), 1);
707 JUnitTestCase.assertEquals(2, list.indexOf(thirdNode)); 706 expect(list.indexOf(thirdNode), 2);
708 JUnitTestCase.assertEquals(-1, list.indexOf(fourthNode)); 707 expect(list.indexOf(fourthNode), -1);
709 JUnitTestCase.assertEquals(-1, list.indexOf(null)); 708 expect(list.indexOf(null), -1);
710 } 709 }
711 710
712 void test_remove() { 711 void test_remove() {
713 List<AstNode> nodes = new List<AstNode>(); 712 List<AstNode> nodes = new List<AstNode>();
714 AstNode firstNode = AstFactory.booleanLiteral(true); 713 AstNode firstNode = AstFactory.booleanLiteral(true);
715 AstNode secondNode = AstFactory.booleanLiteral(false); 714 AstNode secondNode = AstFactory.booleanLiteral(false);
716 AstNode thirdNode = AstFactory.booleanLiteral(true); 715 AstNode thirdNode = AstFactory.booleanLiteral(true);
717 nodes.add(firstNode); 716 nodes.add(firstNode);
718 nodes.add(secondNode); 717 nodes.add(secondNode);
719 nodes.add(thirdNode); 718 nodes.add(thirdNode);
720 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 719 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
721 list.addAll(nodes); 720 list.addAll(nodes);
722 EngineTestCase.assertSizeOfList(3, list); 721 EngineTestCase.assertSizeOfList(3, list);
723 JUnitTestCase.assertSame(secondNode, list.removeAt(1)); 722 expect(list.removeAt(1), same(secondNode));
724 EngineTestCase.assertSizeOfList(2, list); 723 EngineTestCase.assertSizeOfList(2, list);
725 JUnitTestCase.assertSame(firstNode, list[0]); 724 expect(list[0], same(firstNode));
726 JUnitTestCase.assertSame(thirdNode, list[1]); 725 expect(list[1], same(thirdNode));
727 } 726 }
728 727
729 void test_remove_negative() { 728 void test_remove_negative() {
730 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 729 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
731 try { 730 try {
732 list.removeAt(-1); 731 list.removeAt(-1);
733 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 732 fail("Expected IndexOutOfBoundsException");
734 } on RangeError catch (exception) { 733 } on RangeError catch (exception) {
735 // Expected 734 // Expected
736 } 735 }
737 } 736 }
738 737
739 void test_remove_tooBig() { 738 void test_remove_tooBig() {
740 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 739 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
741 try { 740 try {
742 list.removeAt(1); 741 list.removeAt(1);
743 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 742 fail("Expected IndexOutOfBoundsException");
744 } on RangeError catch (exception) { 743 } on RangeError catch (exception) {
745 // Expected 744 // Expected
746 } 745 }
747 } 746 }
748 747
749 void test_set() { 748 void test_set() {
750 List<AstNode> nodes = new List<AstNode>(); 749 List<AstNode> nodes = new List<AstNode>();
751 AstNode firstNode = AstFactory.booleanLiteral(true); 750 AstNode firstNode = AstFactory.booleanLiteral(true);
752 AstNode secondNode = AstFactory.booleanLiteral(false); 751 AstNode secondNode = AstFactory.booleanLiteral(false);
753 AstNode thirdNode = AstFactory.booleanLiteral(true); 752 AstNode thirdNode = AstFactory.booleanLiteral(true);
754 nodes.add(firstNode); 753 nodes.add(firstNode);
755 nodes.add(secondNode); 754 nodes.add(secondNode);
756 nodes.add(thirdNode); 755 nodes.add(thirdNode);
757 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 756 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
758 list.addAll(nodes); 757 list.addAll(nodes);
759 EngineTestCase.assertSizeOfList(3, list); 758 EngineTestCase.assertSizeOfList(3, list);
760 AstNode fourthNode = AstFactory.integer(0); 759 AstNode fourthNode = AstFactory.integer(0);
761 JUnitTestCase.assertSame(secondNode, javaListSet(list, 1, fourthNode)); 760 expect(javaListSet(list, 1, fourthNode), same(secondNode));
762 EngineTestCase.assertSizeOfList(3, list); 761 EngineTestCase.assertSizeOfList(3, list);
763 JUnitTestCase.assertSame(firstNode, list[0]); 762 expect(list[0], same(firstNode));
764 JUnitTestCase.assertSame(fourthNode, list[1]); 763 expect(list[1], same(fourthNode));
765 JUnitTestCase.assertSame(thirdNode, list[2]); 764 expect(list[2], same(thirdNode));
766 } 765 }
767 766
768 void test_set_negative() { 767 void test_set_negative() {
769 AstNode node = AstFactory.booleanLiteral(true); 768 AstNode node = AstFactory.booleanLiteral(true);
770 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 769 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
771 try { 770 try {
772 javaListSet(list, -1, node); 771 javaListSet(list, -1, node);
773 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 772 fail("Expected IndexOutOfBoundsException");
774 } on RangeError catch (exception) { 773 } on RangeError catch (exception) {
775 // Expected 774 // Expected
776 } 775 }
777 } 776 }
778 777
779 void test_set_tooBig() { 778 void test_set_tooBig() {
780 AstNode node = AstFactory.booleanLiteral(true); 779 AstNode node = AstFactory.booleanLiteral(true);
781 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([])); 780 NodeList<AstNode> list = new NodeList<AstNode>(AstFactory.argumentList([]));
782 try { 781 try {
783 javaListSet(list, 1, node); 782 javaListSet(list, 1, node);
784 JUnitTestCase.fail("Expected IndexOutOfBoundsException"); 783 fail("Expected IndexOutOfBoundsException");
785 } on RangeError catch (exception) { 784 } on RangeError catch (exception) {
786 // Expected 785 // Expected
787 } 786 }
788 } 787 }
789 } 788 }
790 789
791 class NodeLocatorTest extends ParserTestCase { 790 class NodeLocatorTest extends ParserTestCase {
792 void test_range() { 791 void test_range() {
793 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []); 792 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []);
794 _assertLocate(unit, 4, 10, (node) => node is LibraryDirective, LibraryDirect ive); 793 _assertLocate(unit, 4, 10, (node) => node is LibraryDirective, LibraryDirect ive);
795 } 794 }
796 795
797 void test_searchWithin_null() { 796 void test_searchWithin_null() {
798 NodeLocator locator = new NodeLocator.con2(0, 0); 797 NodeLocator locator = new NodeLocator.con2(0, 0);
799 JUnitTestCase.assertNull(locator.searchWithin(null)); 798 expect(locator.searchWithin(null), isNull);
800 } 799 }
801 800
802 void test_searchWithin_offset() { 801 void test_searchWithin_offset() {
803 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []); 802 CompilationUnit unit = ParserTestCase.parseCompilationUnit("library myLib;", []);
804 _assertLocate(unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdenti fier); 803 _assertLocate(unit, 10, 10, (node) => node is SimpleIdentifier, SimpleIdenti fier);
805 } 804 }
806 805
807 void test_searchWithin_offsetAfterNode() { 806 void test_searchWithin_offsetAfterNode() {
808 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 807 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
809 class A {} 808 class A {}
810 class B {}''', []); 809 class B {}''', []);
811 NodeLocator locator = new NodeLocator.con2(1024, 1024); 810 NodeLocator locator = new NodeLocator.con2(1024, 1024);
812 AstNode node = locator.searchWithin(unit.declarations[0]); 811 AstNode node = locator.searchWithin(unit.declarations[0]);
813 JUnitTestCase.assertNull(node); 812 expect(node, isNull);
814 } 813 }
815 814
816 void test_searchWithin_offsetBeforeNode() { 815 void test_searchWithin_offsetBeforeNode() {
817 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 816 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
818 class A {} 817 class A {}
819 class B {}''', []); 818 class B {}''', []);
820 NodeLocator locator = new NodeLocator.con2(0, 0); 819 NodeLocator locator = new NodeLocator.con2(0, 0);
821 AstNode node = locator.searchWithin(unit.declarations[1]); 820 AstNode node = locator.searchWithin(unit.declarations[1]);
822 JUnitTestCase.assertNull(node); 821 expect(node, isNull);
823 } 822 }
824 823
825 void _assertLocate(CompilationUnit unit, int start, int end, Predicate<AstNode > predicate, Type expectedClass) { 824 void _assertLocate(CompilationUnit unit, int start, int end, Predicate<AstNode > predicate, Type expectedClass) {
826 NodeLocator locator = new NodeLocator.con2(start, end); 825 NodeLocator locator = new NodeLocator.con2(start, end);
827 AstNode node = locator.searchWithin(unit); 826 AstNode node = locator.searchWithin(unit);
828 JUnitTestCase.assertNotNull(node); 827 expect(node, isNotNull);
829 JUnitTestCase.assertSame(node, locator.foundNode); 828 expect(locator.foundNode, same(node));
830 JUnitTestCase.assertTrueMsg("Node starts after range", node.offset <= start) ; 829 expect(node.offset <= start, isTrue, reason: "Node starts after range");
831 JUnitTestCase.assertTrueMsg("Node ends before range", node.offset + node.len gth > end); 830 expect(node.offset + node.length > end, isTrue, reason: "Node ends before ra nge");
832 EngineTestCase.assertInstanceOf(predicate, expectedClass, node); 831 EngineTestCase.assertInstanceOf(predicate, expectedClass, node);
833 } 832 }
834 } 833 }
835 834
836 class SimpleIdentifierTest extends ParserTestCase { 835 class SimpleIdentifierTest extends ParserTestCase {
837 void test_inDeclarationContext_catch_exception() { 836 void test_inDeclarationContext_catch_exception() {
838 SimpleIdentifier identifier = AstFactory.catchClause("e", []).exceptionParam eter; 837 SimpleIdentifier identifier = AstFactory.catchClause("e", []).exceptionParam eter;
839 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 838 expect(identifier.inDeclarationContext(), isTrue);
840 } 839 }
841 840
842 void test_inDeclarationContext_catch_stack() { 841 void test_inDeclarationContext_catch_stack() {
843 SimpleIdentifier identifier = AstFactory.catchClause2("e", "s", []).stackTra ceParameter; 842 SimpleIdentifier identifier = AstFactory.catchClause2("e", "s", []).stackTra ceParameter;
844 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 843 expect(identifier.inDeclarationContext(), isTrue);
845 } 844 }
846 845
847 void test_inDeclarationContext_classDeclaration() { 846 void test_inDeclarationContext_classDeclaration() {
848 SimpleIdentifier identifier = AstFactory.classDeclaration(null, "C", null, n ull, null, null, []).name; 847 SimpleIdentifier identifier = AstFactory.classDeclaration(null, "C", null, n ull, null, null, []).name;
849 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 848 expect(identifier.inDeclarationContext(), isTrue);
850 } 849 }
851 850
852 void test_inDeclarationContext_classTypeAlias() { 851 void test_inDeclarationContext_classTypeAlias() {
853 SimpleIdentifier identifier = AstFactory.classTypeAlias("C", null, null, nul l, null, null).name; 852 SimpleIdentifier identifier = AstFactory.classTypeAlias("C", null, null, nul l, null, null).name;
854 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 853 expect(identifier.inDeclarationContext(), isTrue);
855 } 854 }
856 855
857 void test_inDeclarationContext_constructorDeclaration() { 856 void test_inDeclarationContext_constructorDeclaration() {
858 SimpleIdentifier identifier = AstFactory.constructorDeclaration(AstFactory.i dentifier3("C"), "c", null, null).name; 857 SimpleIdentifier identifier = AstFactory.constructorDeclaration(AstFactory.i dentifier3("C"), "c", null, null).name;
859 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 858 expect(identifier.inDeclarationContext(), isTrue);
860 } 859 }
861 860
862 void test_inDeclarationContext_declaredIdentifier() { 861 void test_inDeclarationContext_declaredIdentifier() {
863 DeclaredIdentifier declaredIdentifier = AstFactory.declaredIdentifier3("v"); 862 DeclaredIdentifier declaredIdentifier = AstFactory.declaredIdentifier3("v");
864 SimpleIdentifier identifier = declaredIdentifier.identifier; 863 SimpleIdentifier identifier = declaredIdentifier.identifier;
865 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 864 expect(identifier.inDeclarationContext(), isTrue);
866 } 865 }
867 866
868 void test_inDeclarationContext_enumConstantDeclaration() { 867 void test_inDeclarationContext_enumConstantDeclaration() {
869 EnumDeclaration enumDeclaration = AstFactory.enumDeclaration2('MyEnum', ['CO NST']); 868 EnumDeclaration enumDeclaration = AstFactory.enumDeclaration2('MyEnum', ['CO NST']);
870 SimpleIdentifier identifier = enumDeclaration.constants[0].name; 869 SimpleIdentifier identifier = enumDeclaration.constants[0].name;
871 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 870 expect(identifier.inDeclarationContext(), isTrue);
872 } 871 }
873 872
874 void test_inDeclarationContext_enumDeclaration() { 873 void test_inDeclarationContext_enumDeclaration() {
875 EnumDeclaration enumDeclaration = AstFactory.enumDeclaration2('MyEnum', ['A' , 'B', 'C']); 874 EnumDeclaration enumDeclaration = AstFactory.enumDeclaration2('MyEnum', ['A' , 'B', 'C']);
876 SimpleIdentifier identifier = enumDeclaration.name; 875 SimpleIdentifier identifier = enumDeclaration.name;
877 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 876 expect(identifier.inDeclarationContext(), isTrue);
878 } 877 }
879 878
880 void test_inDeclarationContext_fieldFormalParameter() { 879 void test_inDeclarationContext_fieldFormalParameter() {
881 SimpleIdentifier identifier = AstFactory.fieldFormalParameter2("p").identifi er; 880 SimpleIdentifier identifier = AstFactory.fieldFormalParameter2("p").identifi er;
882 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); 881 expect(identifier.inDeclarationContext(), isFalse);
883 } 882 }
884 883
885 void test_inDeclarationContext_functionDeclaration() { 884 void test_inDeclarationContext_functionDeclaration() {
886 SimpleIdentifier identifier = AstFactory.functionDeclaration(null, null, "f" , null).name; 885 SimpleIdentifier identifier = AstFactory.functionDeclaration(null, null, "f" , null).name;
887 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 886 expect(identifier.inDeclarationContext(), isTrue);
888 } 887 }
889 888
890 void test_inDeclarationContext_functionTypeAlias() { 889 void test_inDeclarationContext_functionTypeAlias() {
891 SimpleIdentifier identifier = AstFactory.typeAlias(null, "F", null, null).na me; 890 SimpleIdentifier identifier = AstFactory.typeAlias(null, "F", null, null).na me;
892 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 891 expect(identifier.inDeclarationContext(), isTrue);
893 } 892 }
894 893
895 void test_inDeclarationContext_label_false() { 894 void test_inDeclarationContext_label_false() {
896 SimpleIdentifier identifier = AstFactory.namedExpression2("l", AstFactory.in teger(0)).name.label; 895 SimpleIdentifier identifier = AstFactory.namedExpression2("l", AstFactory.in teger(0)).name.label;
897 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); 896 expect(identifier.inDeclarationContext(), isFalse);
898 } 897 }
899 898
900 void test_inDeclarationContext_label_true() { 899 void test_inDeclarationContext_label_true() {
901 Label label = AstFactory.label2("l"); 900 Label label = AstFactory.label2("l");
902 SimpleIdentifier identifier = label.label; 901 SimpleIdentifier identifier = label.label;
903 AstFactory.labeledStatement(AstFactory.list([label]), AstFactory.emptyStatem ent()); 902 AstFactory.labeledStatement(AstFactory.list([label]), AstFactory.emptyStatem ent());
904 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 903 expect(identifier.inDeclarationContext(), isTrue);
905 } 904 }
906 905
907 void test_inDeclarationContext_methodDeclaration() { 906 void test_inDeclarationContext_methodDeclaration() {
908 SimpleIdentifier identifier = AstFactory.identifier3("m"); 907 SimpleIdentifier identifier = AstFactory.identifier3("m");
909 AstFactory.methodDeclaration2(null, null, null, null, identifier, null, null ); 908 AstFactory.methodDeclaration2(null, null, null, null, identifier, null, null );
910 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 909 expect(identifier.inDeclarationContext(), isTrue);
911 } 910 }
912 911
913 void test_inDeclarationContext_prefix() { 912 void test_inDeclarationContext_prefix() {
914 SimpleIdentifier identifier = AstFactory.importDirective3("uri", "pref", []) .prefix; 913 SimpleIdentifier identifier = AstFactory.importDirective3("uri", "pref", []) .prefix;
915 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 914 expect(identifier.inDeclarationContext(), isTrue);
916 } 915 }
917 916
918 void test_inDeclarationContext_simpleFormalParameter() { 917 void test_inDeclarationContext_simpleFormalParameter() {
919 SimpleIdentifier identifier = AstFactory.simpleFormalParameter3("p").identif ier; 918 SimpleIdentifier identifier = AstFactory.simpleFormalParameter3("p").identif ier;
920 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 919 expect(identifier.inDeclarationContext(), isTrue);
921 } 920 }
922 921
923 void test_inDeclarationContext_typeParameter_bound() { 922 void test_inDeclarationContext_typeParameter_bound() {
924 TypeName bound = AstFactory.typeName4("A", []); 923 TypeName bound = AstFactory.typeName4("A", []);
925 SimpleIdentifier identifier = bound.name as SimpleIdentifier; 924 SimpleIdentifier identifier = bound.name as SimpleIdentifier;
926 AstFactory.typeParameter2("E", bound); 925 AstFactory.typeParameter2("E", bound);
927 JUnitTestCase.assertFalse(identifier.inDeclarationContext()); 926 expect(identifier.inDeclarationContext(), isFalse);
928 } 927 }
929 928
930 void test_inDeclarationContext_typeParameter_name() { 929 void test_inDeclarationContext_typeParameter_name() {
931 SimpleIdentifier identifier = AstFactory.typeParameter("E").name; 930 SimpleIdentifier identifier = AstFactory.typeParameter("E").name;
932 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 931 expect(identifier.inDeclarationContext(), isTrue);
933 } 932 }
934 933
935 void test_inDeclarationContext_variableDeclaration() { 934 void test_inDeclarationContext_variableDeclaration() {
936 SimpleIdentifier identifier = AstFactory.variableDeclaration("v").name; 935 SimpleIdentifier identifier = AstFactory.variableDeclaration("v").name;
937 JUnitTestCase.assertTrue(identifier.inDeclarationContext()); 936 expect(identifier.inDeclarationContext(), isTrue);
938 } 937 }
939 938
940 void test_inGetterContext() { 939 void test_inGetterContext() {
941 for (WrapperKind wrapper in WrapperKind.values) { 940 for (WrapperKind wrapper in WrapperKind.values) {
942 for (AssignmentKind assignment in AssignmentKind.values) { 941 for (AssignmentKind assignment in AssignmentKind.values) {
943 SimpleIdentifier identifier = _createIdentifier(wrapper, assignment); 942 SimpleIdentifier identifier = _createIdentifier(wrapper, assignment);
944 if (assignment == AssignmentKind.SIMPLE_LEFT && wrapper != WrapperKind.P REFIXED_LEFT && wrapper != WrapperKind.PROPERTY_LEFT) { 943 if (assignment == AssignmentKind.SIMPLE_LEFT && wrapper != WrapperKind.P REFIXED_LEFT && wrapper != WrapperKind.PROPERTY_LEFT) {
945 if (identifier.inGetterContext()) { 944 if (identifier.inGetterContext()) {
946 JUnitTestCase.fail("Expected ${_topMostNode(identifier).toSource()} to be false"); 945 fail("Expected ${_topMostNode(identifier).toSource()} to be false");
947 } 946 }
948 } else { 947 } else {
949 if (!identifier.inGetterContext()) { 948 if (!identifier.inGetterContext()) {
950 JUnitTestCase.fail("Expected ${_topMostNode(identifier).toSource()} to be true"); 949 fail("Expected ${_topMostNode(identifier).toSource()} to be true");
951 } 950 }
952 } 951 }
953 } 952 }
954 } 953 }
955 } 954 }
956 955
957 void test_inReferenceContext() { 956 void test_inReferenceContext() {
958 SimpleIdentifier identifier = AstFactory.identifier3("id"); 957 SimpleIdentifier identifier = AstFactory.identifier3("id");
959 AstFactory.namedExpression(AstFactory.label(identifier), AstFactory.identifi er3("_")); 958 AstFactory.namedExpression(AstFactory.label(identifier), AstFactory.identifi er3("_"));
960 JUnitTestCase.assertFalse(identifier.inGetterContext()); 959 expect(identifier.inGetterContext(), isFalse);
961 JUnitTestCase.assertFalse(identifier.inSetterContext()); 960 expect(identifier.inSetterContext(), isFalse);
962 } 961 }
963 962
964 void test_inSetterContext() { 963 void test_inSetterContext() {
965 for (WrapperKind wrapper in WrapperKind.values) { 964 for (WrapperKind wrapper in WrapperKind.values) {
966 for (AssignmentKind assignment in AssignmentKind.values) { 965 for (AssignmentKind assignment in AssignmentKind.values) {
967 SimpleIdentifier identifier = _createIdentifier(wrapper, assignment); 966 SimpleIdentifier identifier = _createIdentifier(wrapper, assignment);
968 if (wrapper == WrapperKind.PREFIXED_LEFT || wrapper == WrapperKind.PROPE RTY_LEFT || assignment == AssignmentKind.BINARY || assignment == AssignmentKind. COMPOUND_RIGHT || assignment == AssignmentKind.PREFIX_NOT || assignment == Assig nmentKind.SIMPLE_RIGHT || assignment == AssignmentKind.NONE) { 967 if (wrapper == WrapperKind.PREFIXED_LEFT || wrapper == WrapperKind.PROPE RTY_LEFT || assignment == AssignmentKind.BINARY || assignment == AssignmentKind. COMPOUND_RIGHT || assignment == AssignmentKind.PREFIX_NOT || assignment == Assig nmentKind.SIMPLE_RIGHT || assignment == AssignmentKind.NONE) {
969 if (identifier.inSetterContext()) { 968 if (identifier.inSetterContext()) {
970 JUnitTestCase.fail("Expected ${_topMostNode(identifier).toSource()} to be false"); 969 fail("Expected ${_topMostNode(identifier).toSource()} to be false");
971 } 970 }
972 } else { 971 } else {
973 if (!identifier.inSetterContext()) { 972 if (!identifier.inSetterContext()) {
974 JUnitTestCase.fail("Expected ${_topMostNode(identifier).toSource()} to be true"); 973 fail("Expected ${_topMostNode(identifier).toSource()} to be true");
975 } 974 }
976 } 975 }
977 } 976 }
978 } 977 }
979 } 978 }
980 979
981 void test_isQualified_inMethodInvocation_noTarget() { 980 void test_isQualified_inMethodInvocation_noTarget() {
982 MethodInvocation invocation = AstFactory.methodInvocation2("test", [AstFacto ry.identifier3("arg0")]); 981 MethodInvocation invocation = AstFactory.methodInvocation2("test", [AstFacto ry.identifier3("arg0")]);
983 SimpleIdentifier identifier = invocation.methodName; 982 SimpleIdentifier identifier = invocation.methodName;
984 JUnitTestCase.assertFalse(identifier.isQualified); 983 expect(identifier.isQualified, isFalse);
985 } 984 }
986 985
987 void test_isQualified_inMethodInvocation_withTarget() { 986 void test_isQualified_inMethodInvocation_withTarget() {
988 MethodInvocation invocation = AstFactory.methodInvocation(AstFactory.identif ier3("target"), "test", [AstFactory.identifier3("arg0")]); 987 MethodInvocation invocation = AstFactory.methodInvocation(AstFactory.identif ier3("target"), "test", [AstFactory.identifier3("arg0")]);
989 SimpleIdentifier identifier = invocation.methodName; 988 SimpleIdentifier identifier = invocation.methodName;
990 JUnitTestCase.assertTrue(identifier.isQualified); 989 expect(identifier.isQualified, isTrue);
991 } 990 }
992 991
993 void test_isQualified_inPrefixedIdentifier_name() { 992 void test_isQualified_inPrefixedIdentifier_name() {
994 SimpleIdentifier identifier = AstFactory.identifier3("test"); 993 SimpleIdentifier identifier = AstFactory.identifier3("test");
995 AstFactory.identifier4("prefix", identifier); 994 AstFactory.identifier4("prefix", identifier);
996 JUnitTestCase.assertTrue(identifier.isQualified); 995 expect(identifier.isQualified, isTrue);
997 } 996 }
998 997
999 void test_isQualified_inPrefixedIdentifier_prefix() { 998 void test_isQualified_inPrefixedIdentifier_prefix() {
1000 SimpleIdentifier identifier = AstFactory.identifier3("test"); 999 SimpleIdentifier identifier = AstFactory.identifier3("test");
1001 AstFactory.identifier(identifier, AstFactory.identifier3("name")); 1000 AstFactory.identifier(identifier, AstFactory.identifier3("name"));
1002 JUnitTestCase.assertFalse(identifier.isQualified); 1001 expect(identifier.isQualified, isFalse);
1003 } 1002 }
1004 1003
1005 void test_isQualified_inPropertyAccess_name() { 1004 void test_isQualified_inPropertyAccess_name() {
1006 SimpleIdentifier identifier = AstFactory.identifier3("test"); 1005 SimpleIdentifier identifier = AstFactory.identifier3("test");
1007 AstFactory.propertyAccess(AstFactory.identifier3("target"), identifier); 1006 AstFactory.propertyAccess(AstFactory.identifier3("target"), identifier);
1008 JUnitTestCase.assertTrue(identifier.isQualified); 1007 expect(identifier.isQualified, isTrue);
1009 } 1008 }
1010 1009
1011 void test_isQualified_inPropertyAccess_target() { 1010 void test_isQualified_inPropertyAccess_target() {
1012 SimpleIdentifier identifier = AstFactory.identifier3("test"); 1011 SimpleIdentifier identifier = AstFactory.identifier3("test");
1013 AstFactory.propertyAccess(identifier, AstFactory.identifier3("name")); 1012 AstFactory.propertyAccess(identifier, AstFactory.identifier3("name"));
1014 JUnitTestCase.assertFalse(identifier.isQualified); 1013 expect(identifier.isQualified, isFalse);
1015 } 1014 }
1016 1015
1017 void test_isQualified_inReturnStatement() { 1016 void test_isQualified_inReturnStatement() {
1018 SimpleIdentifier identifier = AstFactory.identifier3("test"); 1017 SimpleIdentifier identifier = AstFactory.identifier3("test");
1019 AstFactory.returnStatement2(identifier); 1018 AstFactory.returnStatement2(identifier);
1020 JUnitTestCase.assertFalse(identifier.isQualified); 1019 expect(identifier.isQualified, isFalse);
1021 } 1020 }
1022 1021
1023 SimpleIdentifier _createIdentifier(WrapperKind wrapper, AssignmentKind assignm ent) { 1022 SimpleIdentifier _createIdentifier(WrapperKind wrapper, AssignmentKind assignm ent) {
1024 SimpleIdentifier identifier = AstFactory.identifier3("a"); 1023 SimpleIdentifier identifier = AstFactory.identifier3("a");
1025 Expression expression = identifier; 1024 Expression expression = identifier;
1026 while (true) { 1025 while (true) {
1027 if (wrapper == WrapperKind.PREFIXED_LEFT) { 1026 if (wrapper == WrapperKind.PREFIXED_LEFT) {
1028 expression = AstFactory.identifier(identifier, AstFactory.identifier3("_ ")); 1027 expression = AstFactory.identifier(identifier, AstFactory.identifier3("_ "));
1029 } else if (wrapper == WrapperKind.PREFIXED_RIGHT) { 1028 } else if (wrapper == WrapperKind.PREFIXED_RIGHT) {
1030 expression = AstFactory.identifier(AstFactory.identifier3("_"), identifi er); 1029 expression = AstFactory.identifier(AstFactory.identifier3("_"), identifi er);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 while (parent != null) { 1073 while (parent != null) {
1075 child = parent; 1074 child = parent;
1076 parent = parent.parent; 1075 parent = parent.parent;
1077 } 1076 }
1078 return child; 1077 return child;
1079 } 1078 }
1080 } 1079 }
1081 1080
1082 class SimpleStringLiteralTest extends ParserTestCase { 1081 class SimpleStringLiteralTest extends ParserTestCase {
1083 void test_contentsOffset() { 1082 void test_contentsOffset() {
1084 JUnitTestCase.assertEquals(1, new SimpleStringLiteral(TokenFactory.tokenFrom String("'X'"), "X").contentsOffset); 1083 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").con tentsOffset, 1);
1085 JUnitTestCase.assertEquals(1, new SimpleStringLiteral(TokenFactory.tokenFrom String("\"X\""), "X").contentsOffset); 1084 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").c ontentsOffset, 1);
1086 JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFrom String("\"\"\"X\"\"\""), "X").contentsOffset); 1085 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"\"\"X\"\"\"") , "X").contentsOffset, 3);
1087 JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFrom String("'''X'''"), "X").contentsOffset); 1086 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") .contentsOffset, 3);
1088 JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFrom String("r'X'"), "X").contentsOffset); 1087 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").co ntentsOffset, 2);
1089 JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFrom String("r\"X\""), "X").contentsOffset); 1088 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X"). contentsOffset, 2);
1090 JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFrom String("r\"\"\"X\"\"\""), "X").contentsOffset); 1089 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"\"\"X\"\"\"" ), "X").contentsOffset, 4);
1091 JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFrom String("r'''X'''"), "X").contentsOffset); 1090 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X" ).contentsOffset, 4);
1092 } 1091 }
1093 1092
1094 void test_contentsEnd() { 1093 void test_contentsEnd() {
1095 JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFrom String("'X'"), "X").contentsEnd); 1094 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").con tentsEnd, 2);
1096 JUnitTestCase.assertEquals(2, new SimpleStringLiteral(TokenFactory.tokenFrom String("\"X\""), "X").contentsEnd); 1095 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").c ontentsEnd, 2);
1097 JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFrom String("\"\"\"X\"\"\""), "X").contentsEnd); 1096 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"\"\"X\"\"\"") , "X").contentsEnd, 4);
1098 JUnitTestCase.assertEquals(4, new SimpleStringLiteral(TokenFactory.tokenFrom String("'''X'''"), "X").contentsEnd); 1097 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") .contentsEnd, 4);
1099 JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFrom String("r'X'"), "X").contentsEnd); 1098 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").co ntentsEnd, 3);
1100 JUnitTestCase.assertEquals(3, new SimpleStringLiteral(TokenFactory.tokenFrom String("r\"X\""), "X").contentsEnd); 1099 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X"). contentsEnd, 3);
1101 JUnitTestCase.assertEquals(5, new SimpleStringLiteral(TokenFactory.tokenFrom String("r\"\"\"X\"\"\""), "X").contentsEnd); 1100 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"\"\"X\"\"\"" ), "X").contentsEnd, 5);
1102 JUnitTestCase.assertEquals(5, new SimpleStringLiteral(TokenFactory.tokenFrom String("r'''X'''"), "X").contentsEnd); 1101 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X" ).contentsEnd, 5);
1103 } 1102 }
1104 1103
1105 void test_isSingleQuoted() { 1104 void test_isSingleQuoted() {
1106 // ' 1105 // '
1107 { 1106 {
1108 var token = TokenFactory.tokenFromString("'X'"); 1107 var token = TokenFactory.tokenFromString("'X'");
1109 var node = new SimpleStringLiteral(token, null); 1108 var node = new SimpleStringLiteral(token, null);
1110 JUnitTestCase.assertTrue(node.isSingleQuoted); 1109 expect(node.isSingleQuoted, isTrue);
1111 } 1110 }
1112 // ''' 1111 // '''
1113 { 1112 {
1114 var token = TokenFactory.tokenFromString("'''X'''"); 1113 var token = TokenFactory.tokenFromString("'''X'''");
1115 var node = new SimpleStringLiteral(token, null); 1114 var node = new SimpleStringLiteral(token, null);
1116 JUnitTestCase.assertTrue(node.isSingleQuoted); 1115 expect(node.isSingleQuoted, isTrue);
1117 } 1116 }
1118 // " 1117 // "
1119 { 1118 {
1120 var token = TokenFactory.tokenFromString('"X"'); 1119 var token = TokenFactory.tokenFromString('"X"');
1121 var node = new SimpleStringLiteral(token, null); 1120 var node = new SimpleStringLiteral(token, null);
1122 JUnitTestCase.assertFalse(node.isSingleQuoted); 1121 expect(node.isSingleQuoted, isFalse);
1123 } 1122 }
1124 // """ 1123 // """
1125 { 1124 {
1126 var token = TokenFactory.tokenFromString('"""X"""'); 1125 var token = TokenFactory.tokenFromString('"""X"""');
1127 var node = new SimpleStringLiteral(token, null); 1126 var node = new SimpleStringLiteral(token, null);
1128 JUnitTestCase.assertFalse(node.isSingleQuoted); 1127 expect(node.isSingleQuoted, isFalse);
1129 } 1128 }
1130 } 1129 }
1131 1130
1132 void test_isSingleQuoted_raw() { 1131 void test_isSingleQuoted_raw() {
1133 // r' 1132 // r'
1134 { 1133 {
1135 var token = TokenFactory.tokenFromString("r'X'"); 1134 var token = TokenFactory.tokenFromString("r'X'");
1136 var node = new SimpleStringLiteral(token, null); 1135 var node = new SimpleStringLiteral(token, null);
1137 JUnitTestCase.assertTrue(node.isSingleQuoted); 1136 expect(node.isSingleQuoted, isTrue);
1138 } 1137 }
1139 // r''' 1138 // r'''
1140 { 1139 {
1141 var token = TokenFactory.tokenFromString("r'''X'''"); 1140 var token = TokenFactory.tokenFromString("r'''X'''");
1142 var node = new SimpleStringLiteral(token, null); 1141 var node = new SimpleStringLiteral(token, null);
1143 JUnitTestCase.assertTrue(node.isSingleQuoted); 1142 expect(node.isSingleQuoted, isTrue);
1144 } 1143 }
1145 // r" 1144 // r"
1146 { 1145 {
1147 var token = TokenFactory.tokenFromString('r"X"'); 1146 var token = TokenFactory.tokenFromString('r"X"');
1148 var node = new SimpleStringLiteral(token, null); 1147 var node = new SimpleStringLiteral(token, null);
1149 JUnitTestCase.assertFalse(node.isSingleQuoted); 1148 expect(node.isSingleQuoted, isFalse);
1150 } 1149 }
1151 // r""" 1150 // r"""
1152 { 1151 {
1153 var token = TokenFactory.tokenFromString('r"""X"""'); 1152 var token = TokenFactory.tokenFromString('r"""X"""');
1154 var node = new SimpleStringLiteral(token, null); 1153 var node = new SimpleStringLiteral(token, null);
1155 JUnitTestCase.assertFalse(node.isSingleQuoted); 1154 expect(node.isSingleQuoted, isFalse);
1156 } 1155 }
1157 } 1156 }
1158 1157
1159 void test_isMultiline() { 1158 void test_isMultiline() {
1160 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("'X'"), "X").isMultiline); 1159 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isM ultiline, isFalse);
1161 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("r'X'"), "X").isMultiline); 1160 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").is Multiline, isFalse);
1162 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("\"X\""), "X").isMultiline); 1161 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").i sMultiline, isFalse);
1163 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("r\"X\""), "X").isMultiline); 1162 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X"). isMultiline, isFalse);
1164 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("'''X'''"), "X").isMultiline); 1163 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") .isMultiline, isTrue);
1165 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("r'''X'''"), "X").isMultiline); 1164 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X" ).isMultiline, isTrue);
1166 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("\"\"\"X\"\"\""), "X").isMultiline); 1165 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"\"\"X\"\"\"") , "X").isMultiline, isTrue);
1167 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("r\"\"\"X\"\"\""), "X").isMultiline); 1166 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"\"\"X\"\"\"" ), "X").isMultiline, isTrue);
1168 } 1167 }
1169 1168
1170 void test_isRaw() { 1169 void test_isRaw() {
1171 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("'X'"), "X").isRaw); 1170 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'X'"), "X").isR aw, isFalse);
1172 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("\"X\""), "X").isRaw); 1171 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"X\""), "X").i sRaw, isFalse);
1173 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("\"\"\"X\"\"\""), "X").isRaw); 1172 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("\"\"\"X\"\"\"") , "X").isRaw, isFalse);
1174 JUnitTestCase.assertFalse(new SimpleStringLiteral(TokenFactory.tokenFromStri ng("'''X'''"), "X").isRaw); 1173 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("'''X'''"), "X") .isRaw, isFalse);
1175 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("r'X'"), "X").isRaw); 1174 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'X'"), "X").is Raw, isTrue);
1176 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("r\"X\""), "X").isRaw); 1175 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"X\""), "X"). isRaw, isTrue);
1177 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("r\"\"\"X\"\"\""), "X").isRaw); 1176 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r\"\"\"X\"\"\"" ), "X").isRaw, isTrue);
1178 JUnitTestCase.assertTrue(new SimpleStringLiteral(TokenFactory.tokenFromStrin g("r'''X'''"), "X").isRaw); 1177 expect(new SimpleStringLiteral(TokenFactory.tokenFromString("r'''X'''"), "X" ).isRaw, isTrue);
1179 } 1178 }
1180 1179
1181 void test_simple() { 1180 void test_simple() {
1182 Token token = TokenFactory.tokenFromString("'value'"); 1181 Token token = TokenFactory.tokenFromString("'value'");
1183 SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value"); 1182 SimpleStringLiteral stringLiteral = new SimpleStringLiteral(token, "value");
1184 JUnitTestCase.assertSame(token, stringLiteral.literal); 1183 expect(stringLiteral.literal, same(token));
1185 JUnitTestCase.assertSame(token, stringLiteral.beginToken); 1184 expect(stringLiteral.beginToken, same(token));
1186 JUnitTestCase.assertSame(token, stringLiteral.endToken); 1185 expect(stringLiteral.endToken, same(token));
1187 JUnitTestCase.assertEquals("value", stringLiteral.value); 1186 expect(stringLiteral.value, "value");
1188 } 1187 }
1189 } 1188 }
1190 1189
1191 class StringInterpolationTest extends ParserTestCase { 1190 class StringInterpolationTest extends ParserTestCase {
1192 void test_contentsOffsetEnd() { 1191 void test_contentsOffsetEnd() {
1193 var be = AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1192 var be = AstFactory.interpolationExpression(AstFactory.identifier3('bb'));
1194 // 'a${bb}ccc' 1193 // 'a${bb}ccc'
1195 { 1194 {
1196 var ae = AstFactory.interpolationString("'a", "a"); 1195 var ae = AstFactory.interpolationString("'a", "a");
1197 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); 1196 var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
1198 var cElement = new InterpolationString(cToken, 'ccc'); 1197 var cElement = new InterpolationString(cToken, 'ccc');
1199 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1198 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1200 JUnitTestCase.assertEquals(1, node.contentsOffset); 1199 expect(node.contentsOffset, 1);
1201 JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd); 1200 expect(node.contentsEnd, 10 + 4 - 1);
1202 } 1201 }
1203 // '''a${bb}ccc''' 1202 // '''a${bb}ccc'''
1204 { 1203 {
1205 var ae = AstFactory.interpolationString("'''a", "a"); 1204 var ae = AstFactory.interpolationString("'''a", "a");
1206 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); 1205 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
1207 var cElement = new InterpolationString(cToken, 'ccc'); 1206 var cElement = new InterpolationString(cToken, 'ccc');
1208 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1207 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1209 JUnitTestCase.assertEquals(3, node.contentsOffset); 1208 expect(node.contentsOffset, 3);
1210 JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd); 1209 expect(node.contentsEnd, 10 + 4 - 1);
1211 } 1210 }
1212 // """a${bb}ccc""" 1211 // """a${bb}ccc"""
1213 { 1212 {
1214 var ae = AstFactory.interpolationString('"""a', "a"); 1213 var ae = AstFactory.interpolationString('"""a', "a");
1215 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); 1214 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
1216 var cElement = new InterpolationString(cToken, 'ccc'); 1215 var cElement = new InterpolationString(cToken, 'ccc');
1217 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1216 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1218 JUnitTestCase.assertEquals(3, node.contentsOffset); 1217 expect(node.contentsOffset, 3);
1219 JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd); 1218 expect(node.contentsEnd, 10 + 4 - 1);
1220 } 1219 }
1221 // r'a${bb}ccc' 1220 // r'a${bb}ccc'
1222 { 1221 {
1223 var ae = AstFactory.interpolationString("r'a", "a"); 1222 var ae = AstFactory.interpolationString("r'a", "a");
1224 var cToken = new StringToken(TokenType.STRING, "ccc'", 10); 1223 var cToken = new StringToken(TokenType.STRING, "ccc'", 10);
1225 var cElement = new InterpolationString(cToken, 'ccc'); 1224 var cElement = new InterpolationString(cToken, 'ccc');
1226 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1225 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1227 JUnitTestCase.assertEquals(2, node.contentsOffset); 1226 expect(node.contentsOffset, 2);
1228 JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd); 1227 expect(node.contentsEnd, 10 + 4 - 1);
1229 } 1228 }
1230 // r'''a${bb}ccc''' 1229 // r'''a${bb}ccc'''
1231 { 1230 {
1232 var ae = AstFactory.interpolationString("r'''a", "a"); 1231 var ae = AstFactory.interpolationString("r'''a", "a");
1233 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10); 1232 var cToken = new StringToken(TokenType.STRING, "ccc'''", 10);
1234 var cElement = new InterpolationString(cToken, 'ccc'); 1233 var cElement = new InterpolationString(cToken, 'ccc');
1235 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1234 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1236 JUnitTestCase.assertEquals(4, node.contentsOffset); 1235 expect(node.contentsOffset, 4);
1237 JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd); 1236 expect(node.contentsEnd, 10 + 4 - 1);
1238 } 1237 }
1239 // r"""a${bb}ccc""" 1238 // r"""a${bb}ccc"""
1240 { 1239 {
1241 var ae = AstFactory.interpolationString('r"""a', "a"); 1240 var ae = AstFactory.interpolationString('r"""a', "a");
1242 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10); 1241 var cToken = new StringToken(TokenType.STRING, 'ccc"""', 10);
1243 var cElement = new InterpolationString(cToken, 'ccc'); 1242 var cElement = new InterpolationString(cToken, 'ccc');
1244 StringInterpolation node = AstFactory.string([ae, ae, cElement]); 1243 StringInterpolation node = AstFactory.string([ae, ae, cElement]);
1245 JUnitTestCase.assertEquals(4, node.contentsOffset); 1244 expect(node.contentsOffset, 4);
1246 JUnitTestCase.assertEquals(10 + 4 - 1, node.contentsEnd); 1245 expect(node.contentsEnd, 10 + 4 - 1);
1247 } 1246 }
1248 } 1247 }
1249 1248
1250 void test_isMultiline() { 1249 void test_isMultiline() {
1251 var b = AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1250 var b = AstFactory.interpolationExpression(AstFactory.identifier3('bb'));
1252 // ' 1251 // '
1253 { 1252 {
1254 var a = AstFactory.interpolationString("'a", "a"); 1253 var a = AstFactory.interpolationString("'a", "a");
1255 var c = AstFactory.interpolationString("ccc'", "ccc"); 1254 var c = AstFactory.interpolationString("ccc'", "ccc");
1256 StringInterpolation node = AstFactory.string([a, b, c]); 1255 StringInterpolation node = AstFactory.string([a, b, c]);
1257 JUnitTestCase.assertFalse(node.isMultiline); 1256 expect(node.isMultiline, isFalse);
1258 } 1257 }
1259 // ''' 1258 // '''
1260 { 1259 {
1261 var a = AstFactory.interpolationString("'''a", "a"); 1260 var a = AstFactory.interpolationString("'''a", "a");
1262 var c = AstFactory.interpolationString("ccc'''", "ccc"); 1261 var c = AstFactory.interpolationString("ccc'''", "ccc");
1263 StringInterpolation node = AstFactory.string([a, b, c]); 1262 StringInterpolation node = AstFactory.string([a, b, c]);
1264 JUnitTestCase.assertTrue(node.isMultiline); 1263 expect(node.isMultiline, isTrue);
1265 } 1264 }
1266 // " 1265 // "
1267 { 1266 {
1268 var a = AstFactory.interpolationString('"a', "a"); 1267 var a = AstFactory.interpolationString('"a', "a");
1269 var c = AstFactory.interpolationString('ccc"', "ccc"); 1268 var c = AstFactory.interpolationString('ccc"', "ccc");
1270 StringInterpolation node = AstFactory.string([a, b, c]); 1269 StringInterpolation node = AstFactory.string([a, b, c]);
1271 JUnitTestCase.assertFalse(node.isMultiline); 1270 expect(node.isMultiline, isFalse);
1272 } 1271 }
1273 // """ 1272 // """
1274 { 1273 {
1275 var a = AstFactory.interpolationString('"""a', "a"); 1274 var a = AstFactory.interpolationString('"""a', "a");
1276 var c = AstFactory.interpolationString('ccc"""', "ccc"); 1275 var c = AstFactory.interpolationString('ccc"""', "ccc");
1277 StringInterpolation node = AstFactory.string([a, b, c]); 1276 StringInterpolation node = AstFactory.string([a, b, c]);
1278 JUnitTestCase.assertTrue(node.isMultiline); 1277 expect(node.isMultiline, isTrue);
1279 } 1278 }
1280 } 1279 }
1281 1280
1282 void test_isSingleQuoted() { 1281 void test_isSingleQuoted() {
1283 var b = AstFactory.interpolationExpression(AstFactory.identifier3('bb')); 1282 var b = AstFactory.interpolationExpression(AstFactory.identifier3('bb'));
1284 // " 1283 // "
1285 { 1284 {
1286 var a = AstFactory.interpolationString('"a', "a"); 1285 var a = AstFactory.interpolationString('"a', "a");
1287 var c = AstFactory.interpolationString('ccc"', "ccc"); 1286 var c = AstFactory.interpolationString('ccc"', "ccc");
1288 StringInterpolation node = AstFactory.string([a, b, c]); 1287 StringInterpolation node = AstFactory.string([a, b, c]);
1289 JUnitTestCase.assertFalse(node.isSingleQuoted); 1288 expect(node.isSingleQuoted, isFalse);
1290 } 1289 }
1291 // """ 1290 // """
1292 { 1291 {
1293 var a = AstFactory.interpolationString('"""a', "a"); 1292 var a = AstFactory.interpolationString('"""a', "a");
1294 var c = AstFactory.interpolationString('ccc"""', "ccc"); 1293 var c = AstFactory.interpolationString('ccc"""', "ccc");
1295 StringInterpolation node = AstFactory.string([a, b, c]); 1294 StringInterpolation node = AstFactory.string([a, b, c]);
1296 JUnitTestCase.assertFalse(node.isSingleQuoted); 1295 expect(node.isSingleQuoted, isFalse);
1297 } 1296 }
1298 // ' 1297 // '
1299 { 1298 {
1300 var a = AstFactory.interpolationString("'a", "a"); 1299 var a = AstFactory.interpolationString("'a", "a");
1301 var c = AstFactory.interpolationString("ccc'", "ccc"); 1300 var c = AstFactory.interpolationString("ccc'", "ccc");
1302 StringInterpolation node = AstFactory.string([a, b, c]); 1301 StringInterpolation node = AstFactory.string([a, b, c]);
1303 JUnitTestCase.assertTrue(node.isSingleQuoted); 1302 expect(node.isSingleQuoted, isTrue);
1304 } 1303 }
1305 // ''' 1304 // '''
1306 { 1305 {
1307 var a = AstFactory.interpolationString("'''a", "a"); 1306 var a = AstFactory.interpolationString("'''a", "a");
1308 var c = AstFactory.interpolationString("ccc'''", "ccc"); 1307 var c = AstFactory.interpolationString("ccc'''", "ccc");
1309 StringInterpolation node = AstFactory.string([a, b, c]); 1308 StringInterpolation node = AstFactory.string([a, b, c]);
1310 JUnitTestCase.assertTrue(node.isSingleQuoted); 1309 expect(node.isSingleQuoted, isTrue);
1311 } 1310 }
1312 } 1311 }
1313 1312
1314 void test_isRaw() { 1313 void test_isRaw() {
1315 StringInterpolation node = AstFactory.string([]); 1314 StringInterpolation node = AstFactory.string([]);
1316 JUnitTestCase.assertFalse(node.isRaw); 1315 expect(node.isRaw, isFalse);
1317 } 1316 }
1318 } 1317 }
1319 1318
1320 class ToSourceVisitorTest extends EngineTestCase { 1319 class ToSourceVisitorTest extends EngineTestCase {
1321 void test_visitAdjacentStrings() { 1320 void test_visitAdjacentStrings() {
1322 _assertSource("'a' 'b'", AstFactory.adjacentStrings([AstFactory.string2("a") , AstFactory.string2("b")])); 1321 _assertSource("'a' 'b'", AstFactory.adjacentStrings([AstFactory.string2("a") , AstFactory.string2("b")]));
1323 } 1322 }
1324 1323
1325 void test_visitAnnotation_constant() { 1324 void test_visitAnnotation_constant() {
1326 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A"))); 1325 _assertSource("@A", AstFactory.annotation(AstFactory.identifier3("A")));
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 * Assert that a `ToSourceVisitor` will produce the expected source when visit ing the given 2551 * Assert that a `ToSourceVisitor` will produce the expected source when visit ing the given
2553 * node. 2552 * node.
2554 * 2553 *
2555 * @param expectedSource the source string that the visitor is expected to pro duce 2554 * @param expectedSource the source string that the visitor is expected to pro duce
2556 * @param node the AST node being visited to produce the actual source 2555 * @param node the AST node being visited to produce the actual source
2557 * @throws AFE if the visitor does not produce the expected source for the giv en node 2556 * @throws AFE if the visitor does not produce the expected source for the giv en node
2558 */ 2557 */
2559 void _assertSource(String expectedSource, AstNode node) { 2558 void _assertSource(String expectedSource, AstNode node) {
2560 PrintStringWriter writer = new PrintStringWriter(); 2559 PrintStringWriter writer = new PrintStringWriter();
2561 node.accept(new ToSourceVisitor(writer)); 2560 node.accept(new ToSourceVisitor(writer));
2562 JUnitTestCase.assertEquals(expectedSource, writer.toString()); 2561 expect(writer.toString(), expectedSource);
2563 } 2562 }
2564 } 2563 }
2565 2564
2566 class VariableDeclarationTest extends ParserTestCase { 2565 class VariableDeclarationTest extends ParserTestCase {
2567 void test_getDocumentationComment_onGrandParent() { 2566 void test_getDocumentationComment_onGrandParent() {
2568 VariableDeclaration varDecl = AstFactory.variableDeclaration("a"); 2567 VariableDeclaration varDecl = AstFactory.variableDeclaration("a");
2569 TopLevelVariableDeclaration decl = AstFactory.topLevelVariableDeclaration2(K eyword.VAR, [varDecl]); 2568 TopLevelVariableDeclaration decl = AstFactory.topLevelVariableDeclaration2(K eyword.VAR, [varDecl]);
2570 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 2569 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
2571 JUnitTestCase.assertNull(varDecl.documentationComment); 2570 expect(varDecl.documentationComment, isNull);
2572 decl.documentationComment = comment; 2571 decl.documentationComment = comment;
2573 JUnitTestCase.assertNotNull(varDecl.documentationComment); 2572 expect(varDecl.documentationComment, isNotNull);
2574 JUnitTestCase.assertNotNull(decl.documentationComment); 2573 expect(decl.documentationComment, isNotNull);
2575 } 2574 }
2576 2575
2577 void test_getDocumentationComment_onNode() { 2576 void test_getDocumentationComment_onNode() {
2578 VariableDeclaration decl = AstFactory.variableDeclaration("a"); 2577 VariableDeclaration decl = AstFactory.variableDeclaration("a");
2579 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 2578 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
2580 decl.documentationComment = comment; 2579 decl.documentationComment = comment;
2581 JUnitTestCase.assertNotNull(decl.documentationComment); 2580 expect(decl.documentationComment, isNotNull);
2582 } 2581 }
2583 } 2582 }
2584 2583
2585 class WrapperKind extends Enum<WrapperKind> { 2584 class WrapperKind extends Enum<WrapperKind> {
2586 static const WrapperKind PREFIXED_LEFT = const WrapperKind('PREFIXED_LEFT', 0) ; 2585 static const WrapperKind PREFIXED_LEFT = const WrapperKind('PREFIXED_LEFT', 0) ;
2587 2586
2588 static const WrapperKind PREFIXED_RIGHT = const WrapperKind('PREFIXED_RIGHT', 1); 2587 static const WrapperKind PREFIXED_RIGHT = const WrapperKind('PREFIXED_RIGHT', 1);
2589 2588
2590 static const WrapperKind PROPERTY_LEFT = const WrapperKind('PROPERTY_LEFT', 2) ; 2589 static const WrapperKind PROPERTY_LEFT = const WrapperKind('PROPERTY_LEFT', 2) ;
2591 2590
2592 static const WrapperKind PROPERTY_RIGHT = const WrapperKind('PROPERTY_RIGHT', 3); 2591 static const WrapperKind PROPERTY_RIGHT = const WrapperKind('PROPERTY_RIGHT', 3);
2593 2592
2594 static const WrapperKind NONE = const WrapperKind('NONE', 4); 2593 static const WrapperKind NONE = const WrapperKind('NONE', 4);
2595 2594
2596 static const List<WrapperKind> values = const [ 2595 static const List<WrapperKind> values = const [
2597 PREFIXED_LEFT, 2596 PREFIXED_LEFT,
2598 PREFIXED_RIGHT, 2597 PREFIXED_RIGHT,
2599 PROPERTY_LEFT, 2598 PROPERTY_LEFT,
2600 PROPERTY_RIGHT, 2599 PROPERTY_RIGHT,
2601 NONE]; 2600 NONE];
2602 2601
2603 const WrapperKind(String name, int ordinal) : super(name, ordinal); 2602 const WrapperKind(String name, int ordinal) : super(name, ordinal);
2604 } 2603 }
2605 2604
2606 main() { 2605 main() {
2607 _ut.groupSep = ' | '; 2606 groupSep = ' | ';
2608 runReflectiveTests(ConstantEvaluatorTest); 2607 runReflectiveTests(ConstantEvaluatorTest);
2609 runReflectiveTests(NodeLocatorTest); 2608 runReflectiveTests(NodeLocatorTest);
2610 runReflectiveTests(ToSourceVisitorTest); 2609 runReflectiveTests(ToSourceVisitorTest);
2611 runReflectiveTests(BreadthFirstVisitorTest); 2610 runReflectiveTests(BreadthFirstVisitorTest);
2612 runReflectiveTests(ClassDeclarationTest); 2611 runReflectiveTests(ClassDeclarationTest);
2613 runReflectiveTests(ClassTypeAliasTest); 2612 runReflectiveTests(ClassTypeAliasTest);
2614 runReflectiveTests(IndexExpressionTest); 2613 runReflectiveTests(IndexExpressionTest);
2615 runReflectiveTests(NodeListTest); 2614 runReflectiveTests(NodeListTest);
2616 runReflectiveTests(SimpleIdentifierTest); 2615 runReflectiveTests(SimpleIdentifierTest);
2617 runReflectiveTests(SimpleStringLiteralTest); 2616 runReflectiveTests(SimpleStringLiteralTest);
2618 runReflectiveTests(StringInterpolationTest); 2617 runReflectiveTests(StringInterpolationTest);
2619 runReflectiveTests(VariableDeclarationTest); 2618 runReflectiveTests(VariableDeclarationTest);
2620 } 2619 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698