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

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

Issue 1017573004: Rewrite constants evaluation and checks to avoid using 'is double'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.ast_test; 8 library engine.ast_test;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 258
259 void test_binary_bitXor() { 259 void test_binary_bitXor() {
260 Object value = _getConstantValue("74 ^ 42"); 260 Object value = _getConstantValue("74 ^ 42");
261 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 261 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
262 expect(value as int, 74 ^ 42); 262 expect(value as int, 74 ^ 42);
263 } 263 }
264 264
265 void test_binary_divide_double() { 265 void test_binary_divide_double() {
266 Object value = _getConstantValue("3.2 / 2.3"); 266 Object value = _getConstantValue("3.2 / 2.3");
267 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 267 expect(value, 3.2 / 2.3);
268 expect(value as double, 3.2 / 2.3);
269 } 268 }
270 269
271 void test_binary_divide_integer() { 270 void test_binary_divide_integer() {
272 Object value = _getConstantValue("3 / 2"); 271 Object value = _getConstantValue("3 / 2");
273 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 272 expect(value, 1.5);
274 expect(value as int, 1);
275 } 273 }
276 274
277 void test_binary_equal_boolean() { 275 void test_binary_equal_boolean() {
278 Object value = _getConstantValue("true == false"); 276 Object value = _getConstantValue("true == false");
279 expect(value, false); 277 expect(value, false);
280 } 278 }
281 279
282 void test_binary_equal_integer() { 280 void test_binary_equal_integer() {
283 Object value = _getConstantValue("2 == 3"); 281 Object value = _getConstantValue("2 == 3");
284 expect(value, false); 282 expect(value, false);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 expect(value, false); 328 expect(value, false);
331 } 329 }
332 330
333 void test_binary_logicalOr() { 331 void test_binary_logicalOr() {
334 Object value = _getConstantValue("true || false"); 332 Object value = _getConstantValue("true || false");
335 expect(value, true); 333 expect(value, true);
336 } 334 }
337 335
338 void test_binary_minus_double() { 336 void test_binary_minus_double() {
339 Object value = _getConstantValue("3.2 - 2.3"); 337 Object value = _getConstantValue("3.2 - 2.3");
340 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 338 expect(value, 3.2 - 2.3);
341 expect(value as double, 3.2 - 2.3);
342 } 339 }
343 340
344 void test_binary_minus_integer() { 341 void test_binary_minus_integer() {
345 Object value = _getConstantValue("3 - 2"); 342 Object value = _getConstantValue("3 - 2");
346 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 343 expect(value, 1);
347 expect(value as int, 1);
348 } 344 }
349 345
350 void test_binary_notEqual_boolean() { 346 void test_binary_notEqual_boolean() {
351 Object value = _getConstantValue("true != false"); 347 Object value = _getConstantValue("true != false");
352 expect(value, true); 348 expect(value, true);
353 } 349 }
354 350
355 void test_binary_notEqual_integer() { 351 void test_binary_notEqual_integer() {
356 Object value = _getConstantValue("2 != 3"); 352 Object value = _getConstantValue("2 != 3");
357 expect(value, true); 353 expect(value, true);
358 } 354 }
359 355
360 void test_binary_notEqual_invalidLeft() { 356 void test_binary_notEqual_invalidLeft() {
361 Object value = _getConstantValue("a != 3"); 357 Object value = _getConstantValue("a != 3");
362 expect(value, ConstantEvaluator.NOT_A_CONSTANT); 358 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
363 } 359 }
364 360
365 void test_binary_notEqual_invalidRight() { 361 void test_binary_notEqual_invalidRight() {
366 Object value = _getConstantValue("2 != a"); 362 Object value = _getConstantValue("2 != a");
367 expect(value, ConstantEvaluator.NOT_A_CONSTANT); 363 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
368 } 364 }
369 365
370 void test_binary_notEqual_string() { 366 void test_binary_notEqual_string() {
371 Object value = _getConstantValue("'a' != 'b'"); 367 Object value = _getConstantValue("'a' != 'b'");
372 expect(value, true); 368 expect(value, true);
373 } 369 }
374 370
375 void test_binary_plus_double() { 371 void test_binary_plus_double() {
376 Object value = _getConstantValue("2.3 + 3.2"); 372 Object value = _getConstantValue("2.3 + 3.2");
377 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 373 expect(value, 2.3 + 3.2);
378 expect(value as double, 2.3 + 3.2);
379 } 374 }
380 375
381 void test_binary_plus_integer() { 376 void test_binary_plus_integer() {
382 Object value = _getConstantValue("2 + 3"); 377 Object value = _getConstantValue("2 + 3");
383 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 378 expect(value, 5);
384 expect(value as int, 5);
385 } 379 }
386 380
387 void test_binary_remainder_double() { 381 void test_binary_remainder_double() {
388 Object value = _getConstantValue("3.2 % 2.3"); 382 Object value = _getConstantValue("3.2 % 2.3");
389 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 383 expect(value, 3.2 % 2.3);
390 expect(value as double, 3.2 % 2.3);
391 } 384 }
392 385
393 void test_binary_remainder_integer() { 386 void test_binary_remainder_integer() {
394 Object value = _getConstantValue("8 % 3"); 387 Object value = _getConstantValue("8 % 3");
395 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 388 expect(value, 2);
396 expect(value as int, 2);
397 } 389 }
398 390
399 void test_binary_rightShift() { 391 void test_binary_rightShift() {
400 Object value = _getConstantValue("64 >> 2"); 392 Object value = _getConstantValue("64 >> 2");
401 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 393 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
402 expect(value as int, 16); 394 expect(value as int, 16);
403 } 395 }
404 396
405 void test_binary_times_double() { 397 void test_binary_times_double() {
406 Object value = _getConstantValue("2.3 * 3.2"); 398 Object value = _getConstantValue("2.3 * 3.2");
407 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 399 expect(value, 2.3 * 3.2);
408 expect(value as double, 2.3 * 3.2);
409 } 400 }
410 401
411 void test_binary_times_integer() { 402 void test_binary_times_integer() {
412 Object value = _getConstantValue("2 * 3"); 403 Object value = _getConstantValue("2 * 3");
413 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 404 expect(value, 6);
414 expect(value as int, 6);
415 } 405 }
416 406
417 void test_binary_truncatingDivide_double() { 407 void test_binary_truncatingDivide_double() {
418 Object value = _getConstantValue("3.2 ~/ 2.3"); 408 Object value = _getConstantValue("3.2 ~/ 2.3");
419 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 409 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value);
420 expect(value as int, 1); 410 expect(value as int, 1);
421 } 411 }
422 412
423 void test_binary_truncatingDivide_integer() { 413 void test_binary_truncatingDivide_integer() {
424 Object value = _getConstantValue("10 ~/ 3"); 414 Object value = _getConstantValue("10 ~/ 3");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 expect(map["c"], "o"); 446 expect(map["c"], "o");
457 } 447 }
458 448
459 void test_literal_null() { 449 void test_literal_null() {
460 Object value = _getConstantValue("null"); 450 Object value = _getConstantValue("null");
461 expect(value, null); 451 expect(value, null);
462 } 452 }
463 453
464 void test_literal_number_double() { 454 void test_literal_number_double() {
465 Object value = _getConstantValue("3.45"); 455 Object value = _getConstantValue("3.45");
466 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 456 expect(value, 3.45);
467 expect(value as double, 3.45);
468 } 457 }
469 458
470 void test_literal_number_integer() { 459 void test_literal_number_integer() {
471 Object value = _getConstantValue("42"); 460 Object value = _getConstantValue("42");
472 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 461 expect(value, 42);
473 expect(value as int, 42);
474 } 462 }
475 463
476 void test_literal_string_adjacent() { 464 void test_literal_string_adjacent() {
477 Object value = _getConstantValue("'abc' 'def'"); 465 Object value = _getConstantValue("'abc' 'def'");
478 expect(value, "abcdef"); 466 expect(value, "abcdef");
479 } 467 }
480 468
481 void test_literal_string_interpolation_invalid() { 469 void test_literal_string_interpolation_invalid() {
482 Object value = _getConstantValue("'a\${f()}c'"); 470 Object value = _getConstantValue("'a\${f()}c'");
483 expect(value, ConstantEvaluator.NOT_A_CONSTANT); 471 expect(value, ConstantEvaluator.NOT_A_CONSTANT);
(...skipping 20 matching lines...) Expand all
504 expect(value as int, ~42); 492 expect(value as int, ~42);
505 } 493 }
506 494
507 void test_unary_logicalNot() { 495 void test_unary_logicalNot() {
508 Object value = _getConstantValue("!true"); 496 Object value = _getConstantValue("!true");
509 expect(value, false); 497 expect(value, false);
510 } 498 }
511 499
512 void test_unary_negated_double() { 500 void test_unary_negated_double() {
513 Object value = _getConstantValue("-42.3"); 501 Object value = _getConstantValue("-42.3");
514 EngineTestCase.assertInstanceOf((obj) => obj is double, double, value); 502 expect(value, -42.3);
515 expect(value as double, -42.3);
516 } 503 }
517 504
518 void test_unary_negated_integer() { 505 void test_unary_negated_integer() {
519 Object value = _getConstantValue("-42"); 506 Object value = _getConstantValue("-42");
520 EngineTestCase.assertInstanceOf((obj) => obj is int, int, value); 507 expect(value, -42);
521 expect(value as int, -42);
522 } 508 }
523 509
524 Object _getConstantValue(String source) => 510 Object _getConstantValue(String source) =>
525 parseExpression(source).accept(new ConstantEvaluator()); 511 parseExpression(source).accept(new ConstantEvaluator());
526 } 512 }
527 513
528 @reflectiveTest 514 @reflectiveTest
529 class ConstructorDeclarationTest extends EngineTestCase { 515 class ConstructorDeclarationTest extends EngineTestCase {
530 void test_firstTokenAfterCommentAndMetadata_all_inverted() { 516 void test_firstTokenAfterCommentAndMetadata_all_inverted() {
531 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL); 517 Token externalKeyword = TokenFactory.tokenFromKeyword(Keyword.EXTERNAL);
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 1151
1166 void test_isQualified_inMethodInvocation_noTarget() { 1152 void test_isQualified_inMethodInvocation_noTarget() {
1167 MethodInvocation invocation = 1153 MethodInvocation invocation =
1168 AstFactory.methodInvocation2("test", [AstFactory.identifier3("arg0")]); 1154 AstFactory.methodInvocation2("test", [AstFactory.identifier3("arg0")]);
1169 SimpleIdentifier identifier = invocation.methodName; 1155 SimpleIdentifier identifier = invocation.methodName;
1170 expect(identifier.isQualified, isFalse); 1156 expect(identifier.isQualified, isFalse);
1171 } 1157 }
1172 1158
1173 void test_isQualified_inMethodInvocation_withTarget() { 1159 void test_isQualified_inMethodInvocation_withTarget() {
1174 MethodInvocation invocation = AstFactory.methodInvocation( 1160 MethodInvocation invocation = AstFactory.methodInvocation(
1175 AstFactory.identifier3("target"), "test", [ 1161 AstFactory.identifier3("target"), "test",
1176 AstFactory.identifier3("arg0") 1162 [AstFactory.identifier3("arg0")]);
1177 ]);
1178 SimpleIdentifier identifier = invocation.methodName; 1163 SimpleIdentifier identifier = invocation.methodName;
1179 expect(identifier.isQualified, isTrue); 1164 expect(identifier.isQualified, isTrue);
1180 } 1165 }
1181 1166
1182 void test_isQualified_inPrefixedIdentifier_name() { 1167 void test_isQualified_inPrefixedIdentifier_name() {
1183 SimpleIdentifier identifier = AstFactory.identifier3("test"); 1168 SimpleIdentifier identifier = AstFactory.identifier3("test");
1184 AstFactory.identifier4("prefix", identifier); 1169 AstFactory.identifier4("prefix", identifier);
1185 expect(identifier.isQualified, isTrue); 1170 expect(identifier.isQualified, isTrue);
1186 } 1171 }
1187 1172
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1858 Keyword.VAR, [AstFactory.variableDeclaration("a")])
1874 ])); 1859 ]));
1875 } 1860 }
1876 1861
1877 void test_visitCompilationUnit_directive() { 1862 void test_visitCompilationUnit_directive() {
1878 _assertSource("library l;", 1863 _assertSource("library l;",
1879 AstFactory.compilationUnit3([AstFactory.libraryDirective2("l")])); 1864 AstFactory.compilationUnit3([AstFactory.libraryDirective2("l")]));
1880 } 1865 }
1881 1866
1882 void test_visitCompilationUnit_directive_declaration() { 1867 void test_visitCompilationUnit_directive_declaration() {
1883 _assertSource("library l; var a;", AstFactory.compilationUnit4([ 1868 _assertSource("library l; var a;", AstFactory.compilationUnit4(
1884 AstFactory.libraryDirective2("l") 1869 [AstFactory.libraryDirective2("l")], [
1885 ], [
1886 AstFactory.topLevelVariableDeclaration2( 1870 AstFactory.topLevelVariableDeclaration2(
1887 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1871 Keyword.VAR, [AstFactory.variableDeclaration("a")])
1888 ])); 1872 ]));
1889 } 1873 }
1890 1874
1891 void test_visitCompilationUnit_empty() { 1875 void test_visitCompilationUnit_empty() {
1892 _assertSource("", AstFactory.compilationUnit()); 1876 _assertSource("", AstFactory.compilationUnit());
1893 } 1877 }
1894 1878
1895 void test_visitCompilationUnit_script() { 1879 void test_visitCompilationUnit_script() {
1896 _assertSource( 1880 _assertSource(
1897 "!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm")); 1881 "!#/bin/dartvm", AstFactory.compilationUnit5("!#/bin/dartvm"));
1898 } 1882 }
1899 1883
1900 void test_visitCompilationUnit_script_declaration() { 1884 void test_visitCompilationUnit_script_declaration() {
1901 _assertSource("!#/bin/dartvm var a;", AstFactory.compilationUnit6( 1885 _assertSource("!#/bin/dartvm var a;", AstFactory.compilationUnit6(
1902 "!#/bin/dartvm", [ 1886 "!#/bin/dartvm", [
1903 AstFactory.topLevelVariableDeclaration2( 1887 AstFactory.topLevelVariableDeclaration2(
1904 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1888 Keyword.VAR, [AstFactory.variableDeclaration("a")])
1905 ])); 1889 ]));
1906 } 1890 }
1907 1891
1908 void test_visitCompilationUnit_script_directive() { 1892 void test_visitCompilationUnit_script_directive() {
1909 _assertSource("!#/bin/dartvm library l;", AstFactory.compilationUnit7( 1893 _assertSource("!#/bin/dartvm library l;", AstFactory.compilationUnit7(
1910 "!#/bin/dartvm", [AstFactory.libraryDirective2("l")])); 1894 "!#/bin/dartvm", [AstFactory.libraryDirective2("l")]));
1911 } 1895 }
1912 1896
1913 void test_visitCompilationUnit_script_directives_declarations() { 1897 void test_visitCompilationUnit_script_directives_declarations() {
1914 _assertSource("!#/bin/dartvm library l; var a;", AstFactory 1898 _assertSource("!#/bin/dartvm library l; var a;", AstFactory
1915 .compilationUnit8("!#/bin/dartvm", [ 1899 .compilationUnit8("!#/bin/dartvm", [AstFactory.libraryDirective2("l")],
1916 AstFactory.libraryDirective2("l") 1900 [
1917 ], [
1918 AstFactory.topLevelVariableDeclaration2( 1901 AstFactory.topLevelVariableDeclaration2(
1919 Keyword.VAR, [AstFactory.variableDeclaration("a")]) 1902 Keyword.VAR, [AstFactory.variableDeclaration("a")])
1920 ])); 1903 ]));
1921 } 1904 }
1922 1905
1923 void test_visitConditionalExpression() { 1906 void test_visitConditionalExpression() {
1924 _assertSource("a ? b : c", AstFactory.conditionalExpression( 1907 _assertSource("a ? b : c", AstFactory.conditionalExpression(
1925 AstFactory.identifier3("a"), AstFactory.identifier3("b"), 1908 AstFactory.identifier3("a"), AstFactory.identifier3("b"),
1926 AstFactory.identifier3("c"))); 1909 AstFactory.identifier3("c")));
1927 } 1910 }
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 ])); 2284 ]));
2302 } 2285 }
2303 2286
2304 void test_visitForStatement_c() { 2287 void test_visitForStatement_c() {
2305 _assertSource("for (; c;) {}", AstFactory.forStatement( 2288 _assertSource("for (; c;) {}", AstFactory.forStatement(
2306 null, AstFactory.identifier3("c"), null, AstFactory.block())); 2289 null, AstFactory.identifier3("c"), null, AstFactory.block()));
2307 } 2290 }
2308 2291
2309 void test_visitForStatement_cu() { 2292 void test_visitForStatement_cu() {
2310 _assertSource("for (; c; u) {}", AstFactory.forStatement(null, 2293 _assertSource("for (; c; u) {}", AstFactory.forStatement(null,
2311 AstFactory.identifier3("c"), [ 2294 AstFactory.identifier3("c"), [AstFactory.identifier3("u")],
2312 AstFactory.identifier3("u") 2295 AstFactory.block()));
2313 ], AstFactory.block()));
2314 } 2296 }
2315 2297
2316 void test_visitForStatement_e() { 2298 void test_visitForStatement_e() {
2317 _assertSource("for (e;;) {}", AstFactory.forStatement( 2299 _assertSource("for (e;;) {}", AstFactory.forStatement(
2318 AstFactory.identifier3("e"), null, null, AstFactory.block())); 2300 AstFactory.identifier3("e"), null, null, AstFactory.block()));
2319 } 2301 }
2320 2302
2321 void test_visitForStatement_ec() { 2303 void test_visitForStatement_ec() {
2322 _assertSource("for (e; c;) {}", AstFactory.forStatement( 2304 _assertSource("for (e; c;) {}", AstFactory.forStatement(
2323 AstFactory.identifier3("e"), AstFactory.identifier3("c"), null, 2305 AstFactory.identifier3("e"), AstFactory.identifier3("c"), null,
2324 AstFactory.block())); 2306 AstFactory.block()));
2325 } 2307 }
2326 2308
2327 void test_visitForStatement_ecu() { 2309 void test_visitForStatement_ecu() {
2328 _assertSource("for (e; c; u) {}", AstFactory.forStatement( 2310 _assertSource("for (e; c; u) {}", AstFactory.forStatement(
2329 AstFactory.identifier3("e"), AstFactory.identifier3("c"), [ 2311 AstFactory.identifier3("e"), AstFactory.identifier3("c"),
2330 AstFactory.identifier3("u") 2312 [AstFactory.identifier3("u")], AstFactory.block()));
2331 ], AstFactory.block()));
2332 } 2313 }
2333 2314
2334 void test_visitForStatement_eu() { 2315 void test_visitForStatement_eu() {
2335 _assertSource("for (e;; u) {}", AstFactory.forStatement( 2316 _assertSource("for (e;; u) {}", AstFactory.forStatement(
2336 AstFactory.identifier3("e"), null, [ 2317 AstFactory.identifier3("e"), null, [AstFactory.identifier3("u")],
2337 AstFactory.identifier3("u") 2318 AstFactory.block()));
2338 ], AstFactory.block()));
2339 } 2319 }
2340 2320
2341 void test_visitForStatement_i() { 2321 void test_visitForStatement_i() {
2342 _assertSource("for (var i;;) {}", AstFactory.forStatement2(AstFactory 2322 _assertSource("for (var i;;) {}", AstFactory.forStatement2(AstFactory
2343 .variableDeclarationList2( 2323 .variableDeclarationList2(
2344 Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, null, 2324 Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, null,
2345 AstFactory.block())); 2325 AstFactory.block()));
2346 } 2326 }
2347 2327
2348 void test_visitForStatement_ic() { 2328 void test_visitForStatement_ic() {
2349 _assertSource("for (var i; c;) {}", AstFactory.forStatement2(AstFactory 2329 _assertSource("for (var i; c;) {}", AstFactory.forStatement2(AstFactory
2350 .variableDeclarationList2(Keyword.VAR, [ 2330 .variableDeclarationList2(
2351 AstFactory.variableDeclaration("i") 2331 Keyword.VAR, [AstFactory.variableDeclaration("i")]),
2352 ]), AstFactory.identifier3("c"), null, AstFactory.block())); 2332 AstFactory.identifier3("c"), null, AstFactory.block()));
2353 } 2333 }
2354 2334
2355 void test_visitForStatement_icu() { 2335 void test_visitForStatement_icu() {
2356 _assertSource("for (var i; c; u) {}", AstFactory.forStatement2(AstFactory 2336 _assertSource("for (var i; c; u) {}", AstFactory.forStatement2(AstFactory
2357 .variableDeclarationList2(Keyword.VAR, [ 2337 .variableDeclarationList2(
2358 AstFactory.variableDeclaration("i") 2338 Keyword.VAR, [AstFactory.variableDeclaration("i")]),
2359 ]), AstFactory.identifier3("c"), [ 2339 AstFactory.identifier3("c"), [AstFactory.identifier3("u")],
2360 AstFactory.identifier3("u") 2340 AstFactory.block()));
2361 ], AstFactory.block()));
2362 } 2341 }
2363 2342
2364 void test_visitForStatement_iu() { 2343 void test_visitForStatement_iu() {
2365 _assertSource("for (var i;; u) {}", AstFactory.forStatement2(AstFactory 2344 _assertSource("for (var i;; u) {}", AstFactory.forStatement2(AstFactory
2366 .variableDeclarationList2( 2345 .variableDeclarationList2(
2367 Keyword.VAR, [AstFactory.variableDeclaration("i")]), null, [ 2346 Keyword.VAR, [AstFactory.variableDeclaration("i")]), null,
2368 AstFactory.identifier3("u") 2347 [AstFactory.identifier3("u")], AstFactory.block()));
2369 ], AstFactory.block()));
2370 } 2348 }
2371 2349
2372 void test_visitForStatement_u() { 2350 void test_visitForStatement_u() {
2373 _assertSource("for (;; u) {}", AstFactory.forStatement( 2351 _assertSource("for (;; u) {}", AstFactory.forStatement(
2374 null, null, [AstFactory.identifier3("u")], AstFactory.block())); 2352 null, null, [AstFactory.identifier3("u")], AstFactory.block()));
2375 } 2353 }
2376 2354
2377 void test_visitFunctionDeclaration_getter() { 2355 void test_visitFunctionDeclaration_getter() {
2378 _assertSource("get f() {}", AstFactory.functionDeclaration( 2356 _assertSource("get f() {}", AstFactory.functionDeclaration(
2379 null, Keyword.GET, "f", AstFactory.functionExpression())); 2357 null, Keyword.GET, "f", AstFactory.functionExpression()));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 [AstFactory.typeName4("A"), AstFactory.typeName4("B")])); 2460 [AstFactory.typeName4("A"), AstFactory.typeName4("B")]));
2483 } 2461 }
2484 2462
2485 void test_visitImplementsClause_single() { 2463 void test_visitImplementsClause_single() {
2486 _assertSource("implements A", 2464 _assertSource("implements A",
2487 AstFactory.implementsClause([AstFactory.typeName4("A")])); 2465 AstFactory.implementsClause([AstFactory.typeName4("A")]));
2488 } 2466 }
2489 2467
2490 void test_visitImportDirective_combinator() { 2468 void test_visitImportDirective_combinator() {
2491 _assertSource("import 'a.dart' show A;", AstFactory.importDirective3( 2469 _assertSource("import 'a.dart' show A;", AstFactory.importDirective3(
2492 "a.dart", null, [ 2470 "a.dart", null,
2493 AstFactory.showCombinator([AstFactory.identifier3("A")]) 2471 [AstFactory.showCombinator([AstFactory.identifier3("A")])]));
2494 ]));
2495 } 2472 }
2496 2473
2497 void test_visitImportDirective_combinators() { 2474 void test_visitImportDirective_combinators() {
2498 _assertSource("import 'a.dart' show A hide B;", AstFactory.importDirective3( 2475 _assertSource("import 'a.dart' show A hide B;", AstFactory.importDirective3(
2499 "a.dart", null, [ 2476 "a.dart", null, [
2500 AstFactory.showCombinator([AstFactory.identifier3("A")]), 2477 AstFactory.showCombinator([AstFactory.identifier3("A")]),
2501 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 2478 AstFactory.hideCombinator([AstFactory.identifier3("B")])
2502 ])); 2479 ]));
2503 } 2480 }
2504 2481
2505 void test_visitImportDirective_deferred() { 2482 void test_visitImportDirective_deferred() {
2506 _assertSource("import 'a.dart' deferred as p;", 2483 _assertSource("import 'a.dart' deferred as p;",
2507 AstFactory.importDirective2("a.dart", true, "p")); 2484 AstFactory.importDirective2("a.dart", true, "p"));
2508 } 2485 }
2509 2486
2510 void test_visitImportDirective_minimal() { 2487 void test_visitImportDirective_minimal() {
2511 _assertSource( 2488 _assertSource(
2512 "import 'a.dart';", AstFactory.importDirective3("a.dart", null)); 2489 "import 'a.dart';", AstFactory.importDirective3("a.dart", null));
2513 } 2490 }
2514 2491
2515 void test_visitImportDirective_prefix() { 2492 void test_visitImportDirective_prefix() {
2516 _assertSource( 2493 _assertSource(
2517 "import 'a.dart' as p;", AstFactory.importDirective3("a.dart", "p")); 2494 "import 'a.dart' as p;", AstFactory.importDirective3("a.dart", "p"));
2518 } 2495 }
2519 2496
2520 void test_visitImportDirective_prefix_combinator() { 2497 void test_visitImportDirective_prefix_combinator() {
2521 _assertSource("import 'a.dart' as p show A;", AstFactory.importDirective3( 2498 _assertSource("import 'a.dart' as p show A;", AstFactory.importDirective3(
2522 "a.dart", "p", [ 2499 "a.dart", "p",
2523 AstFactory.showCombinator([AstFactory.identifier3("A")]) 2500 [AstFactory.showCombinator([AstFactory.identifier3("A")])]));
2524 ]));
2525 } 2501 }
2526 2502
2527 void test_visitImportDirective_prefix_combinators() { 2503 void test_visitImportDirective_prefix_combinators() {
2528 _assertSource("import 'a.dart' as p show A hide B;", AstFactory 2504 _assertSource("import 'a.dart' as p show A hide B;", AstFactory
2529 .importDirective3("a.dart", "p", [ 2505 .importDirective3("a.dart", "p", [
2530 AstFactory.showCombinator([AstFactory.identifier3("A")]), 2506 AstFactory.showCombinator([AstFactory.identifier3("A")]),
2531 AstFactory.hideCombinator([AstFactory.identifier3("B")]) 2507 AstFactory.hideCombinator([AstFactory.identifier3("B")])
2532 ])); 2508 ]));
2533 } 2509 }
2534 2510
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 _assertSource("case a: {} {}", AstFactory.switchCase( 2921 _assertSource("case a: {} {}", AstFactory.switchCase(
2946 AstFactory.identifier3("a"), [AstFactory.block(), AstFactory.block()])); 2922 AstFactory.identifier3("a"), [AstFactory.block(), AstFactory.block()]));
2947 } 2923 }
2948 2924
2949 void test_visitSwitchCase_noLabels() { 2925 void test_visitSwitchCase_noLabels() {
2950 _assertSource("case a: {}", AstFactory.switchCase( 2926 _assertSource("case a: {}", AstFactory.switchCase(
2951 AstFactory.identifier3("a"), [AstFactory.block()])); 2927 AstFactory.identifier3("a"), [AstFactory.block()]));
2952 } 2928 }
2953 2929
2954 void test_visitSwitchCase_singleLabel() { 2930 void test_visitSwitchCase_singleLabel() {
2955 _assertSource("l1: case a: {}", AstFactory.switchCase2([ 2931 _assertSource("l1: case a: {}", AstFactory.switchCase2(
2956 AstFactory.label2("l1") 2932 [AstFactory.label2("l1")], AstFactory.identifier3("a"),
2957 ], AstFactory.identifier3("a"), [AstFactory.block()])); 2933 [AstFactory.block()]));
2958 } 2934 }
2959 2935
2960 void test_visitSwitchDefault_multipleLabels() { 2936 void test_visitSwitchDefault_multipleLabels() {
2961 _assertSource("l1: l2: default: {}", AstFactory.switchDefault([ 2937 _assertSource("l1: l2: default: {}", AstFactory.switchDefault([
2962 AstFactory.label2("l1"), 2938 AstFactory.label2("l1"),
2963 AstFactory.label2("l2") 2939 AstFactory.label2("l2")
2964 ], [AstFactory.block()])); 2940 ], [AstFactory.block()]));
2965 } 2941 }
2966 2942
2967 void test_visitSwitchDefault_multipleStatements() { 2943 void test_visitSwitchDefault_multipleStatements() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 void test_visitTryStatement_catches() { 3001 void test_visitTryStatement_catches() {
3026 _assertSource("try {} on E {} on F {}", AstFactory.tryStatement2( 3002 _assertSource("try {} on E {} on F {}", AstFactory.tryStatement2(
3027 AstFactory.block(), [ 3003 AstFactory.block(), [
3028 AstFactory.catchClause3(AstFactory.typeName4("E")), 3004 AstFactory.catchClause3(AstFactory.typeName4("E")),
3029 AstFactory.catchClause3(AstFactory.typeName4("F")) 3005 AstFactory.catchClause3(AstFactory.typeName4("F"))
3030 ])); 3006 ]));
3031 } 3007 }
3032 3008
3033 void test_visitTryStatement_catchFinally() { 3009 void test_visitTryStatement_catchFinally() {
3034 _assertSource("try {} on E {} finally {}", AstFactory.tryStatement3( 3010 _assertSource("try {} on E {} finally {}", AstFactory.tryStatement3(
3035 AstFactory.block(), [ 3011 AstFactory.block(),
3036 AstFactory.catchClause3(AstFactory.typeName4("E")) 3012 [AstFactory.catchClause3(AstFactory.typeName4("E"))],
3037 ], AstFactory.block())); 3013 AstFactory.block()));
3038 } 3014 }
3039 3015
3040 void test_visitTryStatement_finally() { 3016 void test_visitTryStatement_finally() {
3041 _assertSource("try {} finally {}", 3017 _assertSource("try {} finally {}",
3042 AstFactory.tryStatement(AstFactory.block(), AstFactory.block())); 3018 AstFactory.tryStatement(AstFactory.block(), AstFactory.block()));
3043 } 3019 }
3044 3020
3045 void test_visitTypeArgumentList_multiple() { 3021 void test_visitTypeArgumentList_multiple() {
3046 _assertSource("<E, F>", AstFactory.typeArgumentList( 3022 _assertSource("<E, F>", AstFactory.typeArgumentList(
3047 [AstFactory.typeName4("E"), AstFactory.typeName4("F")])); 3023 [AstFactory.typeName4("E"), AstFactory.typeName4("F")]));
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 static const List<WrapperKind> values = const [ 3215 static const List<WrapperKind> values = const [
3240 PREFIXED_LEFT, 3216 PREFIXED_LEFT,
3241 PREFIXED_RIGHT, 3217 PREFIXED_RIGHT,
3242 PROPERTY_LEFT, 3218 PROPERTY_LEFT,
3243 PROPERTY_RIGHT, 3219 PROPERTY_RIGHT,
3244 NONE 3220 NONE
3245 ]; 3221 ];
3246 3222
3247 const WrapperKind(String name, int ordinal) : super(name, ordinal); 3223 const WrapperKind(String name, int ordinal) : super(name, ordinal);
3248 } 3224 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698