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

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

Issue 950613003: Fix issue 22525 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/parser.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 library engine.parser_test; 5 library engine.parser_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/incremental_scanner.dart'; 10 import 'package:analyzer/src/generated/incremental_scanner.dart';
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 /** 119 /**
120 * The class `ComplexParserTest` defines parser tests that test the parsing of m ore complex 120 * The class `ComplexParserTest` defines parser tests that test the parsing of m ore complex
121 * code fragments or the interactions between multiple parsing methods. For exam ple, tests to ensure 121 * code fragments or the interactions between multiple parsing methods. For exam ple, tests to ensure
122 * that the precedence of operations is being handled correctly should be define d in this class. 122 * that the precedence of operations is being handled correctly should be define d in this class.
123 * 123 *
124 * Simpler tests should be defined in the class [SimpleParserTest]. 124 * Simpler tests should be defined in the class [SimpleParserTest].
125 */ 125 */
126 @reflectiveTest 126 @reflectiveTest
127 class ComplexParserTest extends ParserTestCase { 127 class ComplexParserTest extends ParserTestCase {
128 void test_additiveExpression_normal() {
129 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z");
130 EngineTestCase.assertInstanceOf(
131 (obj) => obj is BinaryExpression,
132 BinaryExpression,
133 expression.leftOperand);
134 }
135
136 void test_additiveExpression_noSpaces() { 128 void test_additiveExpression_noSpaces() {
137 BinaryExpression expression = ParserTestCase.parseExpression("i+1"); 129 BinaryExpression expression = ParserTestCase.parseExpression("i+1");
138 EngineTestCase.assertInstanceOf( 130 EngineTestCase.assertInstanceOf(
139 (obj) => obj is SimpleIdentifier, 131 (obj) => obj is SimpleIdentifier,
140 SimpleIdentifier, 132 SimpleIdentifier,
141 expression.leftOperand); 133 expression.leftOperand);
142 EngineTestCase.assertInstanceOf( 134 EngineTestCase.assertInstanceOf(
143 (obj) => obj is IntegerLiteral, 135 (obj) => obj is IntegerLiteral,
144 IntegerLiteral, 136 IntegerLiteral,
145 expression.rightOperand); 137 expression.rightOperand);
146 } 138 }
147 139
140 void test_additiveExpression_normal() {
141 BinaryExpression expression = ParserTestCase.parseExpression("x + y - z");
142 EngineTestCase.assertInstanceOf(
143 (obj) => obj is BinaryExpression,
144 BinaryExpression,
145 expression.leftOperand);
146 }
147
148 void test_additiveExpression_precedence_multiplicative_left() { 148 void test_additiveExpression_precedence_multiplicative_left() {
149 BinaryExpression expression = ParserTestCase.parseExpression("x * y + z"); 149 BinaryExpression expression = ParserTestCase.parseExpression("x * y + z");
150 EngineTestCase.assertInstanceOf( 150 EngineTestCase.assertInstanceOf(
151 (obj) => obj is BinaryExpression, 151 (obj) => obj is BinaryExpression,
152 BinaryExpression, 152 BinaryExpression,
153 expression.leftOperand); 153 expression.leftOperand);
154 } 154 }
155 155
156 void test_additiveExpression_precedence_multiplicative_left_withSuper() { 156 void test_additiveExpression_precedence_multiplicative_left_withSuper() {
157 BinaryExpression expression = 157 BinaryExpression expression =
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 927 }
928 928
929 void test_constMethod() { 929 void test_constMethod() {
930 ParserTestCase.parse3( 930 ParserTestCase.parse3(
931 "parseClassMember", 931 "parseClassMember",
932 <Object>["C"], 932 <Object>["C"],
933 "const int m() {}", 933 "const int m() {}",
934 [ParserErrorCode.CONST_METHOD]); 934 [ParserErrorCode.CONST_METHOD]);
935 } 935 }
936 936
937 void test_constTypedef() {
938 ParserTestCase.parseCompilationUnit(
939 "const typedef F();",
940 [ParserErrorCode.CONST_TYPEDEF]);
941 }
942
937 void test_constructorWithReturnType() { 943 void test_constructorWithReturnType() {
938 ParserTestCase.parse3( 944 ParserTestCase.parse3(
939 "parseClassMember", 945 "parseClassMember",
940 <Object>["C"], 946 <Object>["C"],
941 "C C() {}", 947 "C C() {}",
942 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); 948 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
943 } 949 }
944 950
945 void test_constructorWithReturnType_var() { 951 void test_constructorWithReturnType_var() {
946 ParserTestCase.parse3( 952 ParserTestCase.parse3(
947 "parseClassMember", 953 "parseClassMember",
948 <Object>["C"], 954 <Object>["C"],
949 "var C() {}", 955 "var C() {}",
950 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); 956 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
951 } 957 }
952 958
953 void test_constTypedef() {
954 ParserTestCase.parseCompilationUnit(
955 "const typedef F();",
956 [ParserErrorCode.CONST_TYPEDEF]);
957 }
958
959 void test_continueOutsideOfLoop_continueInDoStatement() { 959 void test_continueOutsideOfLoop_continueInDoStatement() {
960 ParserTestCase.parse4("parseDoStatement", "do {continue;} while (x);"); 960 ParserTestCase.parse4("parseDoStatement", "do {continue;} while (x);");
961 } 961 }
962 962
963 void test_continueOutsideOfLoop_continueInForStatement() { 963 void test_continueOutsideOfLoop_continueInForStatement() {
964 ParserTestCase.parse4("parseForStatement", "for (; x;) {continue;}"); 964 ParserTestCase.parse4("parseForStatement", "for (; x;) {continue;}");
965 } 965 }
966 966
967 void test_continueOutsideOfLoop_continueInIfStatement() { 967 void test_continueOutsideOfLoop_continueInIfStatement() {
968 ParserTestCase.parse4( 968 ParserTestCase.parse4(
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 expect(unit, isNotNull); 1029 expect(unit, isNotNull);
1030 } 1030 }
1031 1031
1032 void test_directiveAfterDeclaration_classBetweenDirectives() { 1032 void test_directiveAfterDeclaration_classBetweenDirectives() {
1033 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 1033 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
1034 "library l;\nclass Foo{}\npart 'a.dart';", 1034 "library l;\nclass Foo{}\npart 'a.dart';",
1035 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); 1035 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]);
1036 expect(unit, isNotNull); 1036 expect(unit, isNotNull);
1037 } 1037 }
1038 1038
1039 void test_duplicateLabelInSwitchStatement() {
1040 ParserTestCase.parse4(
1041 "parseSwitchStatement",
1042 "switch (e) {l1: case 0: break; l1: case 1: break;}",
1043 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]);
1044 }
1045
1039 void test_duplicatedModifier_const() { 1046 void test_duplicatedModifier_const() {
1040 ParserTestCase.parse3( 1047 ParserTestCase.parse3(
1041 "parseClassMember", 1048 "parseClassMember",
1042 <Object>["C"], 1049 <Object>["C"],
1043 "const const m;", 1050 "const const m;",
1044 [ParserErrorCode.DUPLICATED_MODIFIER]); 1051 [ParserErrorCode.DUPLICATED_MODIFIER]);
1045 } 1052 }
1046 1053
1047 void test_duplicatedModifier_external() { 1054 void test_duplicatedModifier_external() {
1048 ParserTestCase.parse3( 1055 ParserTestCase.parse3(
(...skipping 28 matching lines...) Expand all
1077 } 1084 }
1078 1085
1079 void test_duplicatedModifier_var() { 1086 void test_duplicatedModifier_var() {
1080 ParserTestCase.parse3( 1087 ParserTestCase.parse3(
1081 "parseClassMember", 1088 "parseClassMember",
1082 <Object>["C"], 1089 <Object>["C"],
1083 "var var m;", 1090 "var var m;",
1084 [ParserErrorCode.DUPLICATED_MODIFIER]); 1091 [ParserErrorCode.DUPLICATED_MODIFIER]);
1085 } 1092 }
1086 1093
1087 void test_duplicateLabelInSwitchStatement() {
1088 ParserTestCase.parse4(
1089 "parseSwitchStatement",
1090 "switch (e) {l1: case 0: break; l1: case 1: break;}",
1091 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]);
1092 }
1093
1094 void test_emptyEnumBody() { 1094 void test_emptyEnumBody() {
1095 ParserTestCase.parse3( 1095 ParserTestCase.parse3(
1096 "parseEnumDeclaration", 1096 "parseEnumDeclaration",
1097 <Object>[emptyCommentAndMetadata()], 1097 <Object>[emptyCommentAndMetadata()],
1098 "enum E {}", 1098 "enum E {}",
1099 [ParserErrorCode.EMPTY_ENUM_BODY]); 1099 [ParserErrorCode.EMPTY_ENUM_BODY]);
1100 } 1100 }
1101 1101
1102 void test_equalityCannotBeEqualityOperand_eq_eq() { 1102 void test_equalityCannotBeEqualityOperand_eq_eq() {
1103 ParserTestCase.parseExpression( 1103 ParserTestCase.parseExpression(
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 2341
2342 void test_switchHasMultipleDefaultCases_repeated() { 2342 void test_switchHasMultipleDefaultCases_repeated() {
2343 ParserTestCase.parse4( 2343 ParserTestCase.parse4(
2344 "parseSwitchStatement", 2344 "parseSwitchStatement",
2345 "switch (a) {default: return 0; default: return 1; default: return 2;}", 2345 "switch (a) {default: return 0; default: return 1; default: return 2;}",
2346 [ 2346 [
2347 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, 2347 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES,
2348 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]); 2348 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES]);
2349 } 2349 }
2350 2350
2351 void test_topLevelOperator_withoutType() {
2352 ParserTestCase.parse3(
2353 "parseCompilationUnitMember",
2354 <Object>[emptyCommentAndMetadata()],
2355 "operator +(bool x, bool y) => x | y;",
2356 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
2357 }
2358
2359 void test_topLevelOperator_withType() { 2351 void test_topLevelOperator_withType() {
2360 ParserTestCase.parse3( 2352 ParserTestCase.parse3(
2361 "parseCompilationUnitMember", 2353 "parseCompilationUnitMember",
2362 <Object>[emptyCommentAndMetadata()], 2354 <Object>[emptyCommentAndMetadata()],
2363 "bool operator +(bool x, bool y) => x | y;", 2355 "bool operator +(bool x, bool y) => x | y;",
2364 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 2356 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
2365 } 2357 }
2366 2358
2367 void test_topLevelOperator_withVoid() { 2359 void test_topLevelOperator_withVoid() {
2368 ParserTestCase.parse3( 2360 ParserTestCase.parse3(
2369 "parseCompilationUnitMember", 2361 "parseCompilationUnitMember",
2370 <Object>[emptyCommentAndMetadata()], 2362 <Object>[emptyCommentAndMetadata()],
2371 "void operator +(bool x, bool y) => x | y;", 2363 "void operator +(bool x, bool y) => x | y;",
2372 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 2364 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
2373 } 2365 }
2374 2366
2375 void test_typedefInClass_withoutReturnType() { 2367 void test_topLevelOperator_withoutType() {
2376 ParserTestCase.parseCompilationUnit( 2368 ParserTestCase.parse3(
2377 "class C { typedef F(x); }", 2369 "parseCompilationUnitMember",
2378 [ParserErrorCode.TYPEDEF_IN_CLASS]); 2370 <Object>[emptyCommentAndMetadata()],
2371 "operator +(bool x, bool y) => x | y;",
2372 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
2379 } 2373 }
2380 2374
2381 void test_typedefInClass_withReturnType() { 2375 void test_typedefInClass_withReturnType() {
2382 ParserTestCase.parseCompilationUnit( 2376 ParserTestCase.parseCompilationUnit(
2383 "class C { typedef int F(int x); }", 2377 "class C { typedef int F(int x); }",
2384 [ParserErrorCode.TYPEDEF_IN_CLASS]); 2378 [ParserErrorCode.TYPEDEF_IN_CLASS]);
2385 } 2379 }
2386 2380
2381 void test_typedefInClass_withoutReturnType() {
2382 ParserTestCase.parseCompilationUnit(
2383 "class C { typedef F(x); }",
2384 [ParserErrorCode.TYPEDEF_IN_CLASS]);
2385 }
2386
2387 void test_unexpectedTerminatorForParameterGroup_named() { 2387 void test_unexpectedTerminatorForParameterGroup_named() {
2388 ParserTestCase.parse4( 2388 ParserTestCase.parse4(
2389 "parseFormalParameterList", 2389 "parseFormalParameterList",
2390 "(a, b})", 2390 "(a, b})",
2391 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]); 2391 [ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP]);
2392 } 2392 }
2393 2393
2394 void test_unexpectedTerminatorForParameterGroup_optional() { 2394 void test_unexpectedTerminatorForParameterGroup_optional() {
2395 ParserTestCase.parse4( 2395 ParserTestCase.parse4(
2396 "parseFormalParameterList", 2396 "parseFormalParameterList",
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 } 2496 }
2497 2497
2498 void test_voidVariable_parseClassMember_noInitializer() { 2498 void test_voidVariable_parseClassMember_noInitializer() {
2499 ParserTestCase.parse3( 2499 ParserTestCase.parse3(
2500 "parseClassMember", 2500 "parseClassMember",
2501 <Object>["C"], 2501 <Object>["C"],
2502 "void x;", 2502 "void x;",
2503 [ParserErrorCode.VOID_VARIABLE]); 2503 [ParserErrorCode.VOID_VARIABLE]);
2504 } 2504 }
2505 2505
2506 void test_voidVariable_parseCompilationUnit_initializer() {
2507 ParserTestCase.parseCompilationUnit(
2508 "void x = 0;",
2509 [ParserErrorCode.VOID_VARIABLE]);
2510 }
2511
2512 void test_voidVariable_parseCompilationUnit_noInitializer() {
2513 ParserTestCase.parseCompilationUnit(
2514 "void x;",
2515 [ParserErrorCode.VOID_VARIABLE]);
2516 }
2517
2518 void test_voidVariable_parseCompilationUnitMember_initializer() { 2506 void test_voidVariable_parseCompilationUnitMember_initializer() {
2519 ParserTestCase.parse3( 2507 ParserTestCase.parse3(
2520 "parseCompilationUnitMember", 2508 "parseCompilationUnitMember",
2521 <Object>[emptyCommentAndMetadata()], 2509 <Object>[emptyCommentAndMetadata()],
2522 "void a = 0;", 2510 "void a = 0;",
2523 [ParserErrorCode.VOID_VARIABLE]); 2511 [ParserErrorCode.VOID_VARIABLE]);
2524 } 2512 }
2525 2513
2526 void test_voidVariable_parseCompilationUnitMember_noInitializer() { 2514 void test_voidVariable_parseCompilationUnitMember_noInitializer() {
2527 ParserTestCase.parse3( 2515 ParserTestCase.parse3(
2528 "parseCompilationUnitMember", 2516 "parseCompilationUnitMember",
2529 <Object>[emptyCommentAndMetadata()], 2517 <Object>[emptyCommentAndMetadata()],
2530 "void a;", 2518 "void a;",
2531 [ParserErrorCode.VOID_VARIABLE]); 2519 [ParserErrorCode.VOID_VARIABLE]);
2532 } 2520 }
2533 2521
2522 void test_voidVariable_parseCompilationUnit_initializer() {
2523 ParserTestCase.parseCompilationUnit(
2524 "void x = 0;",
2525 [ParserErrorCode.VOID_VARIABLE]);
2526 }
2527
2528 void test_voidVariable_parseCompilationUnit_noInitializer() {
2529 ParserTestCase.parseCompilationUnit(
2530 "void x;",
2531 [ParserErrorCode.VOID_VARIABLE]);
2532 }
2533
2534 void test_voidVariable_statement_initializer() { 2534 void test_voidVariable_statement_initializer() {
2535 ParserTestCase.parseStatement( 2535 ParserTestCase.parseStatement(
2536 "void x = 0;", 2536 "void x = 0;",
2537 [ 2537 [
2538 ParserErrorCode.VOID_VARIABLE, 2538 ParserErrorCode.VOID_VARIABLE,
2539 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); 2539 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]);
2540 } 2540 }
2541 2541
2542 void test_voidVariable_statement_noInitializer() { 2542 void test_voidVariable_statement_noInitializer() {
2543 ParserTestCase.parseStatement( 2543 ParserTestCase.parseStatement(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 " + 2", 2720 " + 2",
2721 "; } }"); 2721 "; } }");
2722 } 2722 }
2723 2723
2724 void test_insert_period() { 2724 void test_insert_period() {
2725 // "f() => a + b;" 2725 // "f() => a + b;"
2726 // "f() => a + b.;" 2726 // "f() => a + b.;"
2727 _assertParse("f() => a + b", "", ".", ";"); 2727 _assertParse("f() => a + b", "", ".", ";");
2728 } 2728 }
2729 2729
2730 void test_insert_periodAndIdentifier() {
2731 // "f() => a + b;"
2732 // "f() => a + b.x;"
2733 _assertParse("f() => a + b", "", ".x", ";");
2734 }
2735
2730 void test_insert_period_betweenIdentifiers1() { 2736 void test_insert_period_betweenIdentifiers1() {
2731 // "f() => a b;" 2737 // "f() => a b;"
2732 // "f() => a. b;" 2738 // "f() => a. b;"
2733 _assertParse("f() => a", "", ".", " b;"); 2739 _assertParse("f() => a", "", ".", " b;");
2734 } 2740 }
2735 2741
2736 void test_insert_period_betweenIdentifiers2() { 2742 void test_insert_period_betweenIdentifiers2() {
2737 // "f() => a b;" 2743 // "f() => a b;"
2738 // "f() => a .b;" 2744 // "f() => a .b;"
2739 _assertParse("f() => a ", "", ".", "b;"); 2745 _assertParse("f() => a ", "", ".", "b;");
2740 } 2746 }
2741 2747
2742 void test_insert_period_betweenIdentifiers3() { 2748 void test_insert_period_betweenIdentifiers3() {
2743 // "f() => a b;" 2749 // "f() => a b;"
2744 // "f() => a . b;" 2750 // "f() => a . b;"
2745 _assertParse("f() => a ", "", ".", " b;"); 2751 _assertParse("f() => a ", "", ".", " b;");
2746 } 2752 }
2747 2753
2748 void test_insert_period_insideExistingIdentifier() { 2754 void test_insert_period_insideExistingIdentifier() {
2749 // "f() => ab;" 2755 // "f() => ab;"
2750 // "f() => a.b;" 2756 // "f() => a.b;"
2751 _assertParse("f() => a", "", ".", "b;"); 2757 _assertParse("f() => a", "", ".", "b;");
2752 } 2758 }
2753 2759
2754 void test_insert_periodAndIdentifier() {
2755 // "f() => a + b;"
2756 // "f() => a + b.x;"
2757 _assertParse("f() => a + b", "", ".x", ";");
2758 }
2759
2760 void test_insert_simpleToComplexExression() { 2760 void test_insert_simpleToComplexExression() {
2761 // "/** An [A]. */ class A {} class B { m() => 1; }" 2761 // "/** An [A]. */ class A {} class B { m() => 1; }"
2762 // "/** An [A]. */ class A {} class B { m() => 1 + 2; }" 2762 // "/** An [A]. */ class A {} class B { m() => 1 + 2; }"
2763 _assertParse( 2763 _assertParse(
2764 "/** An [A]. */ class A {} class B { m() => 1", 2764 "/** An [A]. */ class A {} class B { m() => 1",
2765 "", 2765 "",
2766 " + 2", 2766 " + 2",
2767 "; }"); 2767 "; }");
2768 } 2768 }
2769 2769
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
3369 void test_additiveExpression_super() { 3369 void test_additiveExpression_super() {
3370 BinaryExpression expression = ParserTestCase.parseExpression( 3370 BinaryExpression expression = ParserTestCase.parseExpression(
3371 "super + +", 3371 "super + +",
3372 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] ); 3372 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.MISSING_IDENTIFIER] );
3373 EngineTestCase.assertInstanceOf( 3373 EngineTestCase.assertInstanceOf(
3374 (obj) => obj is BinaryExpression, 3374 (obj) => obj is BinaryExpression,
3375 BinaryExpression, 3375 BinaryExpression,
3376 expression.leftOperand); 3376 expression.leftOperand);
3377 } 3377 }
3378 3378
3379 void test_assignmentExpression_missing_LHS() {
3380 AssignmentExpression expression =
3381 ParserTestCase.parseExpression("= 0", [ParserErrorCode.MISSING_IDENTIFIE R]);
3382 EngineTestCase.assertInstanceOf(
3383 (obj) => obj is SimpleIdentifier,
3384 SimpleIdentifier,
3385 expression.leftHandSide);
3386 expect(expression.leftHandSide.isSynthetic, isTrue);
3387 }
3388
3389 void test_assignmentExpression_missing_RHS() {
3390 AssignmentExpression expression =
3391 ParserTestCase.parseExpression("x =", [ParserErrorCode.MISSING_IDENTIFIE R]);
3392 EngineTestCase.assertInstanceOf(
3393 (obj) => obj is SimpleIdentifier,
3394 SimpleIdentifier,
3395 expression.leftHandSide);
3396 expect(expression.rightHandSide.isSynthetic, isTrue);
3397 }
3398
3379 void test_assignmentExpression_missing_compound1() { 3399 void test_assignmentExpression_missing_compound1() {
3380 AssignmentExpression expression = ParserTestCase.parseExpression( 3400 AssignmentExpression expression = ParserTestCase.parseExpression(
3381 "= y = 0", 3401 "= y = 0",
3382 [ParserErrorCode.MISSING_IDENTIFIER]); 3402 [ParserErrorCode.MISSING_IDENTIFIER]);
3383 Expression syntheticExpression = expression.leftHandSide; 3403 Expression syntheticExpression = expression.leftHandSide;
3384 EngineTestCase.assertInstanceOf( 3404 EngineTestCase.assertInstanceOf(
3385 (obj) => obj is SimpleIdentifier, 3405 (obj) => obj is SimpleIdentifier,
3386 SimpleIdentifier, 3406 SimpleIdentifier,
3387 syntheticExpression); 3407 syntheticExpression);
3388 expect(syntheticExpression.isSynthetic, isTrue); 3408 expect(syntheticExpression.isSynthetic, isTrue);
(...skipping 18 matching lines...) Expand all
3407 [ParserErrorCode.MISSING_IDENTIFIER]); 3427 [ParserErrorCode.MISSING_IDENTIFIER]);
3408 Expression syntheticExpression = 3428 Expression syntheticExpression =
3409 (expression.rightHandSide as AssignmentExpression).rightHandSide; 3429 (expression.rightHandSide as AssignmentExpression).rightHandSide;
3410 EngineTestCase.assertInstanceOf( 3430 EngineTestCase.assertInstanceOf(
3411 (obj) => obj is SimpleIdentifier, 3431 (obj) => obj is SimpleIdentifier,
3412 SimpleIdentifier, 3432 SimpleIdentifier,
3413 syntheticExpression); 3433 syntheticExpression);
3414 expect(syntheticExpression.isSynthetic, isTrue); 3434 expect(syntheticExpression.isSynthetic, isTrue);
3415 } 3435 }
3416 3436
3417 void test_assignmentExpression_missing_LHS() {
3418 AssignmentExpression expression =
3419 ParserTestCase.parseExpression("= 0", [ParserErrorCode.MISSING_IDENTIFIE R]);
3420 EngineTestCase.assertInstanceOf(
3421 (obj) => obj is SimpleIdentifier,
3422 SimpleIdentifier,
3423 expression.leftHandSide);
3424 expect(expression.leftHandSide.isSynthetic, isTrue);
3425 }
3426
3427 void test_assignmentExpression_missing_RHS() {
3428 AssignmentExpression expression =
3429 ParserTestCase.parseExpression("x =", [ParserErrorCode.MISSING_IDENTIFIE R]);
3430 EngineTestCase.assertInstanceOf(
3431 (obj) => obj is SimpleIdentifier,
3432 SimpleIdentifier,
3433 expression.leftHandSide);
3434 expect(expression.rightHandSide.isSynthetic, isTrue);
3435 }
3436
3437 void test_bitwiseAndExpression_missing_LHS() { 3437 void test_bitwiseAndExpression_missing_LHS() {
3438 BinaryExpression expression = 3438 BinaryExpression expression =
3439 ParserTestCase.parseExpression("& y", [ParserErrorCode.MISSING_IDENTIFIE R]); 3439 ParserTestCase.parseExpression("& y", [ParserErrorCode.MISSING_IDENTIFIE R]);
3440 EngineTestCase.assertInstanceOf( 3440 EngineTestCase.assertInstanceOf(
3441 (obj) => obj is SimpleIdentifier, 3441 (obj) => obj is SimpleIdentifier,
3442 SimpleIdentifier, 3442 SimpleIdentifier,
3443 expression.leftOperand); 3443 expression.leftOperand);
3444 expect(expression.leftOperand.isSynthetic, isTrue); 3444 expect(expression.leftOperand.isSynthetic, isTrue);
3445 } 3445 }
3446 3446
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
3858 expect(vars, hasLength(1)); 3858 expect(vars, hasLength(1));
3859 expect(vars[0].name.name, "v"); 3859 expect(vars[0].name.name, "v");
3860 } 3860 }
3861 3861
3862 void test_functionExpression_named() { 3862 void test_functionExpression_named() {
3863 ParserTestCase.parseExpression( 3863 ParserTestCase.parseExpression(
3864 "m(f() => 0);", 3864 "m(f() => 0);",
3865 [ParserErrorCode.EXPECTED_TOKEN]); 3865 [ParserErrorCode.EXPECTED_TOKEN]);
3866 } 3866 }
3867 3867
3868 void test_incompleteField_const() {
3869 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
3870 class C {
3871 const
3872 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
3873 NodeList<CompilationUnitMember> declarations = unit.declarations;
3874 expect(declarations, hasLength(1));
3875 CompilationUnitMember unitMember = declarations[0];
3876 EngineTestCase.assertInstanceOf(
3877 (obj) => obj is ClassDeclaration,
3878 ClassDeclaration,
3879 unitMember);
3880 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
3881 expect(members, hasLength(1));
3882 ClassMember classMember = members[0];
3883 EngineTestCase.assertInstanceOf(
3884 (obj) => obj is FieldDeclaration,
3885 FieldDeclaration,
3886 classMember);
3887 VariableDeclarationList fieldList =
3888 (classMember as FieldDeclaration).fields;
3889 expect((fieldList.keyword as KeywordToken).keyword, Keyword.CONST);
3890 NodeList<VariableDeclaration> fields = fieldList.variables;
3891 expect(fields, hasLength(1));
3892 VariableDeclaration field = fields[0];
3893 expect(field.name.isSynthetic, isTrue);
3894 }
3895
3896 void test_incompleteField_final() {
3897 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
3898 class C {
3899 final
3900 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
3901 NodeList<CompilationUnitMember> declarations = unit.declarations;
3902 expect(declarations, hasLength(1));
3903 CompilationUnitMember unitMember = declarations[0];
3904 EngineTestCase.assertInstanceOf(
3905 (obj) => obj is ClassDeclaration,
3906 ClassDeclaration,
3907 unitMember);
3908 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
3909 expect(members, hasLength(1));
3910 ClassMember classMember = members[0];
3911 EngineTestCase.assertInstanceOf(
3912 (obj) => obj is FieldDeclaration,
3913 FieldDeclaration,
3914 classMember);
3915 VariableDeclarationList fieldList =
3916 (classMember as FieldDeclaration).fields;
3917 expect((fieldList.keyword as KeywordToken).keyword, Keyword.FINAL);
3918 NodeList<VariableDeclaration> fields = fieldList.variables;
3919 expect(fields, hasLength(1));
3920 VariableDeclaration field = fields[0];
3921 expect(field.name.isSynthetic, isTrue);
3922 }
3923
3924 void test_incompleteField_var() {
3925 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
3926 class C {
3927 var
3928 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
3929 NodeList<CompilationUnitMember> declarations = unit.declarations;
3930 expect(declarations, hasLength(1));
3931 CompilationUnitMember unitMember = declarations[0];
3932 EngineTestCase.assertInstanceOf(
3933 (obj) => obj is ClassDeclaration,
3934 ClassDeclaration,
3935 unitMember);
3936 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
3937 expect(members, hasLength(1));
3938 ClassMember classMember = members[0];
3939 EngineTestCase.assertInstanceOf(
3940 (obj) => obj is FieldDeclaration,
3941 FieldDeclaration,
3942 classMember);
3943 VariableDeclarationList fieldList =
3944 (classMember as FieldDeclaration).fields;
3945 expect((fieldList.keyword as KeywordToken).keyword, Keyword.VAR);
3946 NodeList<VariableDeclaration> fields = fieldList.variables;
3947 expect(fields, hasLength(1));
3948 VariableDeclaration field = fields[0];
3949 expect(field.name.isSynthetic, isTrue);
3950 }
3951
3868 void test_incomplete_conditionalExpression() { 3952 void test_incomplete_conditionalExpression() {
3869 ParserTestCase.parseExpression( 3953 ParserTestCase.parseExpression(
3870 "x ? 0", 3954 "x ? 0",
3871 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); 3955 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]);
3872 } 3956 }
3873 3957
3874 void test_incomplete_constructorInitializers_empty() { 3958 void test_incomplete_constructorInitializers_empty() {
3875 ParserTestCase.parse3( 3959 ParserTestCase.parse3(
3876 "parseClassMember", 3960 "parseClassMember",
3877 ["C"], 3961 ["C"],
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 (obj) => obj is TopLevelVariableDeclaration, 4060 (obj) => obj is TopLevelVariableDeclaration,
3977 TopLevelVariableDeclaration, 4061 TopLevelVariableDeclaration,
3978 member); 4062 member);
3979 NodeList<VariableDeclaration> variables = 4063 NodeList<VariableDeclaration> variables =
3980 (member as TopLevelVariableDeclaration).variables.variables; 4064 (member as TopLevelVariableDeclaration).variables.variables;
3981 expect(variables, hasLength(1)); 4065 expect(variables, hasLength(1));
3982 SimpleIdentifier name = variables[0].name; 4066 SimpleIdentifier name = variables[0].name;
3983 expect(name.isSynthetic, isTrue); 4067 expect(name.isSynthetic, isTrue);
3984 } 4068 }
3985 4069
3986 void test_incompleteField_const() {
3987 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
3988 class C {
3989 const
3990 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
3991 NodeList<CompilationUnitMember> declarations = unit.declarations;
3992 expect(declarations, hasLength(1));
3993 CompilationUnitMember unitMember = declarations[0];
3994 EngineTestCase.assertInstanceOf(
3995 (obj) => obj is ClassDeclaration,
3996 ClassDeclaration,
3997 unitMember);
3998 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
3999 expect(members, hasLength(1));
4000 ClassMember classMember = members[0];
4001 EngineTestCase.assertInstanceOf(
4002 (obj) => obj is FieldDeclaration,
4003 FieldDeclaration,
4004 classMember);
4005 VariableDeclarationList fieldList =
4006 (classMember as FieldDeclaration).fields;
4007 expect((fieldList.keyword as KeywordToken).keyword, Keyword.CONST);
4008 NodeList<VariableDeclaration> fields = fieldList.variables;
4009 expect(fields, hasLength(1));
4010 VariableDeclaration field = fields[0];
4011 expect(field.name.isSynthetic, isTrue);
4012 }
4013
4014 void test_incompleteField_final() {
4015 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
4016 class C {
4017 final
4018 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
4019 NodeList<CompilationUnitMember> declarations = unit.declarations;
4020 expect(declarations, hasLength(1));
4021 CompilationUnitMember unitMember = declarations[0];
4022 EngineTestCase.assertInstanceOf(
4023 (obj) => obj is ClassDeclaration,
4024 ClassDeclaration,
4025 unitMember);
4026 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
4027 expect(members, hasLength(1));
4028 ClassMember classMember = members[0];
4029 EngineTestCase.assertInstanceOf(
4030 (obj) => obj is FieldDeclaration,
4031 FieldDeclaration,
4032 classMember);
4033 VariableDeclarationList fieldList =
4034 (classMember as FieldDeclaration).fields;
4035 expect((fieldList.keyword as KeywordToken).keyword, Keyword.FINAL);
4036 NodeList<VariableDeclaration> fields = fieldList.variables;
4037 expect(fields, hasLength(1));
4038 VariableDeclaration field = fields[0];
4039 expect(field.name.isSynthetic, isTrue);
4040 }
4041
4042 void test_incompleteField_var() {
4043 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
4044 class C {
4045 var
4046 }''', [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]);
4047 NodeList<CompilationUnitMember> declarations = unit.declarations;
4048 expect(declarations, hasLength(1));
4049 CompilationUnitMember unitMember = declarations[0];
4050 EngineTestCase.assertInstanceOf(
4051 (obj) => obj is ClassDeclaration,
4052 ClassDeclaration,
4053 unitMember);
4054 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members;
4055 expect(members, hasLength(1));
4056 ClassMember classMember = members[0];
4057 EngineTestCase.assertInstanceOf(
4058 (obj) => obj is FieldDeclaration,
4059 FieldDeclaration,
4060 classMember);
4061 VariableDeclarationList fieldList =
4062 (classMember as FieldDeclaration).fields;
4063 expect((fieldList.keyword as KeywordToken).keyword, Keyword.VAR);
4064 NodeList<VariableDeclaration> fields = fieldList.variables;
4065 expect(fields, hasLength(1));
4066 VariableDeclaration field = fields[0];
4067 expect(field.name.isSynthetic, isTrue);
4068 }
4069
4070 void test_invalidFunctionBodyModifier() { 4070 void test_invalidFunctionBodyModifier() {
4071 ParserTestCase.parseCompilationUnit( 4071 ParserTestCase.parseCompilationUnit(
4072 "f() sync {}", 4072 "f() sync {}",
4073 [ParserErrorCode.MISSING_STAR_AFTER_SYNC]); 4073 [ParserErrorCode.MISSING_STAR_AFTER_SYNC]);
4074 } 4074 }
4075 4075
4076 void test_isExpression_noType() { 4076 void test_isExpression_noType() {
4077 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 4077 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
4078 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", 4078 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}",
4079 [ 4079 [
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
4221 [ 4221 [
4222 ParserErrorCode.MISSING_IDENTIFIER, 4222 ParserErrorCode.MISSING_IDENTIFIER,
4223 ParserErrorCode.MISSING_IDENTIFIER, 4223 ParserErrorCode.MISSING_IDENTIFIER,
4224 ParserErrorCode.MISSING_IDENTIFIER]); 4224 ParserErrorCode.MISSING_IDENTIFIER]);
4225 EngineTestCase.assertInstanceOf( 4225 EngineTestCase.assertInstanceOf(
4226 (obj) => obj is BinaryExpression, 4226 (obj) => obj is BinaryExpression,
4227 BinaryExpression, 4227 BinaryExpression,
4228 expression.rightOperand); 4228 expression.rightOperand);
4229 } 4229 }
4230 4230
4231 void test_missing_commaInArgumentList() {
4232 ParserTestCase.parseExpression(
4233 "f(x: 1 y: 2)",
4234 [ParserErrorCode.EXPECTED_TOKEN]);
4235 }
4236
4237 void test_missingGet() { 4231 void test_missingGet() {
4238 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 4232 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
4239 class C { 4233 class C {
4240 int length {} 4234 int length {}
4241 void foo() {} 4235 void foo() {}
4242 }''', [ParserErrorCode.MISSING_GET]); 4236 }''', [ParserErrorCode.MISSING_GET]);
4243 expect(unit, isNotNull); 4237 expect(unit, isNotNull);
4244 ClassDeclaration classDeclaration = 4238 ClassDeclaration classDeclaration =
4245 unit.declarations[0] as ClassDeclaration; 4239 unit.declarations[0] as ClassDeclaration;
4246 NodeList<ClassMember> members = classDeclaration.members; 4240 NodeList<ClassMember> members = classDeclaration.members;
(...skipping 15 matching lines...) Expand all
4262 "parseClassMember", 4256 "parseClassMember",
4263 <Object>["C"], 4257 <Object>["C"],
4264 "@override }", 4258 "@override }",
4265 [ParserErrorCode.EXPECTED_CLASS_MEMBER]); 4259 [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
4266 expect(method.documentationComment, isNull); 4260 expect(method.documentationComment, isNull);
4267 NodeList<Annotation> metadata = method.metadata; 4261 NodeList<Annotation> metadata = method.metadata;
4268 expect(metadata, hasLength(1)); 4262 expect(metadata, hasLength(1));
4269 expect(metadata[0].name.name, "override"); 4263 expect(metadata[0].name.name, "override");
4270 } 4264 }
4271 4265
4266 void test_missing_commaInArgumentList() {
4267 ParserTestCase.parseExpression(
4268 "f(x: 1 y: 2)",
4269 [ParserErrorCode.EXPECTED_TOKEN]);
4270 }
4271
4272 void test_multiplicativeExpression_missing_LHS() { 4272 void test_multiplicativeExpression_missing_LHS() {
4273 BinaryExpression expression = 4273 BinaryExpression expression =
4274 ParserTestCase.parseExpression("* y", [ParserErrorCode.MISSING_IDENTIFIE R]); 4274 ParserTestCase.parseExpression("* y", [ParserErrorCode.MISSING_IDENTIFIE R]);
4275 EngineTestCase.assertInstanceOf( 4275 EngineTestCase.assertInstanceOf(
4276 (obj) => obj is SimpleIdentifier, 4276 (obj) => obj is SimpleIdentifier,
4277 SimpleIdentifier, 4277 SimpleIdentifier,
4278 expression.leftOperand); 4278 expression.leftOperand);
4279 expect(expression.leftOperand.isSynthetic, isTrue); 4279 expect(expression.leftOperand.isSynthetic, isTrue);
4280 } 4280 }
4281 4281
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
4970 PostfixExpression toNode = AstFactory.postfixExpression( 4970 PostfixExpression toNode = AstFactory.postfixExpression(
4971 AstFactory.identifier3(variableName), 4971 AstFactory.identifier3(variableName),
4972 TokenType.PLUS_PLUS); 4972 TokenType.PLUS_PLUS);
4973 ResolutionCopier.copyResolutionData(fromNode, toNode); 4973 ResolutionCopier.copyResolutionData(fromNode, toNode);
4974 expect(toNode.propagatedElement, same(propagatedElement)); 4974 expect(toNode.propagatedElement, same(propagatedElement));
4975 expect(toNode.propagatedType, same(propagatedType)); 4975 expect(toNode.propagatedType, same(propagatedType));
4976 expect(toNode.staticElement, same(staticElement)); 4976 expect(toNode.staticElement, same(staticElement));
4977 expect(toNode.staticType, same(staticType)); 4977 expect(toNode.staticType, same(staticType));
4978 } 4978 }
4979 4979
4980 void test_visitPrefixedIdentifier() {
4981 PrefixedIdentifier fromNode = AstFactory.identifier5("p", "f");
4982 DartType propagatedType = ElementFactory.classElement2("C").type;
4983 fromNode.propagatedType = propagatedType;
4984 DartType staticType = ElementFactory.classElement2("C").type;
4985 fromNode.staticType = staticType;
4986 PrefixedIdentifier toNode = AstFactory.identifier5("p", "f");
4987 ResolutionCopier.copyResolutionData(fromNode, toNode);
4988 expect(toNode.propagatedType, same(propagatedType));
4989 expect(toNode.staticType, same(staticType));
4990 }
4991
4992 void test_visitPrefixExpression() { 4980 void test_visitPrefixExpression() {
4993 PrefixExpression fromNode = 4981 PrefixExpression fromNode =
4994 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x")); 4982 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x"));
4995 MethodElement propagatedElement = 4983 MethodElement propagatedElement =
4996 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type ); 4984 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type );
4997 DartType propagatedType = ElementFactory.classElement2("C").type; 4985 DartType propagatedType = ElementFactory.classElement2("C").type;
4998 fromNode.propagatedElement = propagatedElement; 4986 fromNode.propagatedElement = propagatedElement;
4999 fromNode.propagatedType = propagatedType; 4987 fromNode.propagatedType = propagatedType;
5000 DartType staticType = ElementFactory.classElement2("C").type; 4988 DartType staticType = ElementFactory.classElement2("C").type;
5001 MethodElement staticElement = 4989 MethodElement staticElement =
5002 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type ); 4990 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type );
5003 fromNode.staticElement = staticElement; 4991 fromNode.staticElement = staticElement;
5004 fromNode.staticType = staticType; 4992 fromNode.staticType = staticType;
5005 PrefixExpression toNode = 4993 PrefixExpression toNode =
5006 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x")); 4994 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x"));
5007 ResolutionCopier.copyResolutionData(fromNode, toNode); 4995 ResolutionCopier.copyResolutionData(fromNode, toNode);
5008 expect(toNode.propagatedElement, same(propagatedElement)); 4996 expect(toNode.propagatedElement, same(propagatedElement));
5009 expect(toNode.propagatedType, same(propagatedType)); 4997 expect(toNode.propagatedType, same(propagatedType));
5010 expect(toNode.staticElement, same(staticElement)); 4998 expect(toNode.staticElement, same(staticElement));
5011 expect(toNode.staticType, same(staticType)); 4999 expect(toNode.staticType, same(staticType));
5012 } 5000 }
5013 5001
5002 void test_visitPrefixedIdentifier() {
5003 PrefixedIdentifier fromNode = AstFactory.identifier5("p", "f");
5004 DartType propagatedType = ElementFactory.classElement2("C").type;
5005 fromNode.propagatedType = propagatedType;
5006 DartType staticType = ElementFactory.classElement2("C").type;
5007 fromNode.staticType = staticType;
5008 PrefixedIdentifier toNode = AstFactory.identifier5("p", "f");
5009 ResolutionCopier.copyResolutionData(fromNode, toNode);
5010 expect(toNode.propagatedType, same(propagatedType));
5011 expect(toNode.staticType, same(staticType));
5012 }
5013
5014 void test_visitPropertyAccess() { 5014 void test_visitPropertyAccess() {
5015 PropertyAccess fromNode = 5015 PropertyAccess fromNode =
5016 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y"); 5016 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y");
5017 DartType propagatedType = ElementFactory.classElement2("C").type; 5017 DartType propagatedType = ElementFactory.classElement2("C").type;
5018 fromNode.propagatedType = propagatedType; 5018 fromNode.propagatedType = propagatedType;
5019 DartType staticType = ElementFactory.classElement2("C").type; 5019 DartType staticType = ElementFactory.classElement2("C").type;
5020 fromNode.staticType = staticType; 5020 fromNode.staticType = staticType;
5021 PropertyAccess toNode = 5021 PropertyAccess toNode =
5022 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y"); 5022 AstFactory.propertyAccess2(AstFactory.identifier3("x"), "y");
5023 ResolutionCopier.copyResolutionData(fromNode, toNode); 5023 ResolutionCopier.copyResolutionData(fromNode, toNode);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
5217 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], ""); 5217 ParserTestCase.parse("parseCommentReference", <Object>["this", 5], "");
5218 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 5218 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
5219 (obj) => obj is SimpleIdentifier, 5219 (obj) => obj is SimpleIdentifier,
5220 SimpleIdentifier, 5220 SimpleIdentifier,
5221 reference.identifier); 5221 reference.identifier);
5222 expect(identifier.token, isNotNull); 5222 expect(identifier.token, isNotNull);
5223 expect(identifier.name, "a"); 5223 expect(identifier.name, "a");
5224 expect(identifier.offset, 5); 5224 expect(identifier.offset, 5);
5225 } 5225 }
5226 5226
5227 void test_Parser() {
5228 expect(new Parser(null, null), isNotNull);
5229 }
5230
5227 void test_computeStringValue_emptyInterpolationPrefix() { 5231 void test_computeStringValue_emptyInterpolationPrefix() {
5228 expect(_computeStringValue("'''", true, false), ""); 5232 expect(_computeStringValue("'''", true, false), "");
5229 } 5233 }
5230 5234
5231 void test_computeStringValue_escape_b() { 5235 void test_computeStringValue_escape_b() {
5232 expect(_computeStringValue("'\\b'", true, true), "\b"); 5236 expect(_computeStringValue("'\\b'", true, true), "\b");
5233 } 5237 }
5234 5238
5235 void test_computeStringValue_escape_f() { 5239 void test_computeStringValue_escape_f() {
5236 expect(_computeStringValue("'\\f'", true, true), "\f"); 5240 expect(_computeStringValue("'\\f'", true, true), "\f");
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
5589 void test_parseAnnotation_n3_a() { 5593 void test_parseAnnotation_n3_a() {
5590 Annotation annotation = 5594 Annotation annotation =
5591 ParserTestCase.parse4("parseAnnotation", "@A.B.C(x,y)"); 5595 ParserTestCase.parse4("parseAnnotation", "@A.B.C(x,y)");
5592 expect(annotation.atSign, isNotNull); 5596 expect(annotation.atSign, isNotNull);
5593 expect(annotation.name, isNotNull); 5597 expect(annotation.name, isNotNull);
5594 expect(annotation.period, isNotNull); 5598 expect(annotation.period, isNotNull);
5595 expect(annotation.constructorName, isNotNull); 5599 expect(annotation.constructorName, isNotNull);
5596 expect(annotation.arguments, isNotNull); 5600 expect(annotation.arguments, isNotNull);
5597 } 5601 }
5598 5602
5599 void test_parseArgument_named() {
5600 NamedExpression expression = ParserTestCase.parse4("parseArgument", "n: x");
5601 Label name = expression.name;
5602 expect(name, isNotNull);
5603 expect(name.label, isNotNull);
5604 expect(name.colon, isNotNull);
5605 expect(expression.expression, isNotNull);
5606 }
5607
5608 void test_parseArgument_unnamed() {
5609 String lexeme = "x";
5610 SimpleIdentifier identifier =
5611 ParserTestCase.parse4("parseArgument", lexeme);
5612 expect(identifier.name, lexeme);
5613 }
5614
5615 void test_parseArgumentList_empty() { 5603 void test_parseArgumentList_empty() {
5616 ArgumentList argumentList = 5604 ArgumentList argumentList =
5617 ParserTestCase.parse4("parseArgumentList", "()"); 5605 ParserTestCase.parse4("parseArgumentList", "()");
5618 NodeList<Expression> arguments = argumentList.arguments; 5606 NodeList<Expression> arguments = argumentList.arguments;
5619 expect(arguments, hasLength(0)); 5607 expect(arguments, hasLength(0));
5620 } 5608 }
5621 5609
5622 void test_parseArgumentList_mixed() { 5610 void test_parseArgumentList_mixed() {
5623 ArgumentList argumentList = 5611 ArgumentList argumentList =
5624 ParserTestCase.parse4("parseArgumentList", "(w, x, y: y, z: z)"); 5612 ParserTestCase.parse4("parseArgumentList", "(w, x, y: y, z: z)");
5625 NodeList<Expression> arguments = argumentList.arguments; 5613 NodeList<Expression> arguments = argumentList.arguments;
5626 expect(arguments, hasLength(4)); 5614 expect(arguments, hasLength(4));
5627 } 5615 }
5628 5616
5629 void test_parseArgumentList_noNamed() { 5617 void test_parseArgumentList_noNamed() {
5630 ArgumentList argumentList = 5618 ArgumentList argumentList =
5631 ParserTestCase.parse4("parseArgumentList", "(x, y, z)"); 5619 ParserTestCase.parse4("parseArgumentList", "(x, y, z)");
5632 NodeList<Expression> arguments = argumentList.arguments; 5620 NodeList<Expression> arguments = argumentList.arguments;
5633 expect(arguments, hasLength(3)); 5621 expect(arguments, hasLength(3));
5634 } 5622 }
5635 5623
5636 void test_parseArgumentList_onlyNamed() { 5624 void test_parseArgumentList_onlyNamed() {
5637 ArgumentList argumentList = 5625 ArgumentList argumentList =
5638 ParserTestCase.parse4("parseArgumentList", "(x: x, y: y)"); 5626 ParserTestCase.parse4("parseArgumentList", "(x: x, y: y)");
5639 NodeList<Expression> arguments = argumentList.arguments; 5627 NodeList<Expression> arguments = argumentList.arguments;
5640 expect(arguments, hasLength(2)); 5628 expect(arguments, hasLength(2));
5641 } 5629 }
5642 5630
5631 void test_parseArgument_named() {
5632 NamedExpression expression = ParserTestCase.parse4("parseArgument", "n: x");
5633 Label name = expression.name;
5634 expect(name, isNotNull);
5635 expect(name.label, isNotNull);
5636 expect(name.colon, isNotNull);
5637 expect(expression.expression, isNotNull);
5638 }
5639
5640 void test_parseArgument_unnamed() {
5641 String lexeme = "x";
5642 SimpleIdentifier identifier =
5643 ParserTestCase.parse4("parseArgument", lexeme);
5644 expect(identifier.name, lexeme);
5645 }
5646
5643 void test_parseAssertStatement() { 5647 void test_parseAssertStatement() {
5644 AssertStatement statement = 5648 AssertStatement statement =
5645 ParserTestCase.parse4("parseAssertStatement", "assert (x);"); 5649 ParserTestCase.parse4("parseAssertStatement", "assert (x);");
5646 expect(statement.keyword, isNotNull); 5650 expect(statement.keyword, isNotNull);
5647 expect(statement.leftParenthesis, isNotNull); 5651 expect(statement.leftParenthesis, isNotNull);
5648 expect(statement.condition, isNotNull); 5652 expect(statement.condition, isNotNull);
5649 expect(statement.rightParenthesis, isNotNull); 5653 expect(statement.rightParenthesis, isNotNull);
5650 expect(statement.semicolon, isNotNull); 5654 expect(statement.semicolon, isNotNull);
5651 } 5655 }
5652 5656
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
6978 3)]; 6982 3)];
6979 List<CommentReference> references = 6983 List<CommentReference> references =
6980 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6984 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6981 expect(references, hasLength(1)); 6985 expect(references, hasLength(1));
6982 CommentReference reference = references[0]; 6986 CommentReference reference = references[0];
6983 expect(reference, isNotNull); 6987 expect(reference, isNotNull);
6984 expect(reference.identifier, isNotNull); 6988 expect(reference.identifier, isNotNull);
6985 expect(reference.offset, 15); 6989 expect(reference.offset, 15);
6986 } 6990 }
6987 6991
6988 void test_parseCompilationUnit_abstractAsPrefix_parameterized() {
6989 CompilationUnit unit = ParserTestCase.parse4(
6990 "parseCompilationUnit",
6991 "abstract<dynamic> _abstract = new abstract.A();");
6992 expect(unit.scriptTag, isNull);
6993 expect(unit.directives, hasLength(0));
6994 expect(unit.declarations, hasLength(1));
6995 }
6996
6997 void test_parseCompilationUnit_builtIn_asFunctionName() {
6998 ParserTestCase.parse4("parseCompilationUnit", "abstract(x) => 0;");
6999 ParserTestCase.parse4("parseCompilationUnit", "as(x) => 0;");
7000 ParserTestCase.parse4("parseCompilationUnit", "dynamic(x) => 0;");
7001 ParserTestCase.parse4("parseCompilationUnit", "export(x) => 0;");
7002 ParserTestCase.parse4("parseCompilationUnit", "external(x) => 0;");
7003 ParserTestCase.parse4("parseCompilationUnit", "factory(x) => 0;");
7004 ParserTestCase.parse4("parseCompilationUnit", "get(x) => 0;");
7005 ParserTestCase.parse4("parseCompilationUnit", "implements(x) => 0;");
7006 ParserTestCase.parse4("parseCompilationUnit", "import(x) => 0;");
7007 ParserTestCase.parse4("parseCompilationUnit", "library(x) => 0;");
7008 ParserTestCase.parse4("parseCompilationUnit", "operator(x) => 0;");
7009 ParserTestCase.parse4("parseCompilationUnit", "part(x) => 0;");
7010 ParserTestCase.parse4("parseCompilationUnit", "set(x) => 0;");
7011 ParserTestCase.parse4("parseCompilationUnit", "static(x) => 0;");
7012 ParserTestCase.parse4("parseCompilationUnit", "typedef(x) => 0;");
7013 }
7014
7015 void test_parseCompilationUnit_directives_multiple() {
7016 CompilationUnit unit =
7017 ParserTestCase.parse4("parseCompilationUnit", "library l;\npart 'a.dart' ;");
7018 expect(unit.scriptTag, isNull);
7019 expect(unit.directives, hasLength(2));
7020 expect(unit.declarations, hasLength(0));
7021 }
7022
7023 void test_parseCompilationUnit_directives_single() {
7024 CompilationUnit unit =
7025 ParserTestCase.parse4("parseCompilationUnit", "library l;");
7026 expect(unit.scriptTag, isNull);
7027 expect(unit.directives, hasLength(1));
7028 expect(unit.declarations, hasLength(0));
7029 }
7030
7031 void test_parseCompilationUnit_empty() {
7032 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "");
7033 expect(unit.scriptTag, isNull);
7034 expect(unit.directives, hasLength(0));
7035 expect(unit.declarations, hasLength(0));
7036 }
7037
7038 void test_parseCompilationUnit_exportAsPrefix() {
7039 CompilationUnit unit = ParserTestCase.parse4(
7040 "parseCompilationUnit",
7041 "export.A _export = new export.A();");
7042 expect(unit.scriptTag, isNull);
7043 expect(unit.directives, hasLength(0));
7044 expect(unit.declarations, hasLength(1));
7045 }
7046
7047 void test_parseCompilationUnit_exportAsPrefix_parameterized() {
7048 CompilationUnit unit = ParserTestCase.parse4(
7049 "parseCompilationUnit",
7050 "export<dynamic> _export = new export.A();");
7051 expect(unit.scriptTag, isNull);
7052 expect(unit.directives, hasLength(0));
7053 expect(unit.declarations, hasLength(1));
7054 }
7055
7056 void test_parseCompilationUnit_operatorAsPrefix_parameterized() {
7057 CompilationUnit unit = ParserTestCase.parse4(
7058 "parseCompilationUnit",
7059 "operator<dynamic> _operator = new operator.A();");
7060 expect(unit.scriptTag, isNull);
7061 expect(unit.directives, hasLength(0));
7062 expect(unit.declarations, hasLength(1));
7063 }
7064
7065 void test_parseCompilationUnit_script() {
7066 CompilationUnit unit =
7067 ParserTestCase.parse4("parseCompilationUnit", "#! /bin/dart");
7068 expect(unit.scriptTag, isNotNull);
7069 expect(unit.directives, hasLength(0));
7070 expect(unit.declarations, hasLength(0));
7071 }
7072
7073 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() {
7074 ParserTestCase.parseFunctionBodies = false;
7075 CompilationUnit unit =
7076 ParserTestCase.parse4("parseCompilationUnit", "f() { '\${n}'; }");
7077 expect(unit.scriptTag, isNull);
7078 expect(unit.declarations, hasLength(1));
7079 }
7080
7081 void test_parseCompilationUnit_topLevelDeclaration() {
7082 CompilationUnit unit =
7083 ParserTestCase.parse4("parseCompilationUnit", "class A {}");
7084 expect(unit.scriptTag, isNull);
7085 expect(unit.directives, hasLength(0));
7086 expect(unit.declarations, hasLength(1));
7087 }
7088
7089 void test_parseCompilationUnit_typedefAsPrefix() {
7090 CompilationUnit unit = ParserTestCase.parse4(
7091 "parseCompilationUnit",
7092 "typedef.A _typedef = new typedef.A();");
7093 expect(unit.scriptTag, isNull);
7094 expect(unit.directives, hasLength(0));
7095 expect(unit.declarations, hasLength(1));
7096 }
7097
7098 void test_parseCompilationUnitMember_abstractAsPrefix() { 6992 void test_parseCompilationUnitMember_abstractAsPrefix() {
7099 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 6993 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7100 "parseCompilationUnitMember", 6994 "parseCompilationUnitMember",
7101 <Object>[emptyCommentAndMetadata()], 6995 <Object>[emptyCommentAndMetadata()],
7102 "abstract.A _abstract = new abstract.A();"); 6996 "abstract.A _abstract = new abstract.A();");
7103 expect(declaration.semicolon, isNotNull); 6997 expect(declaration.semicolon, isNotNull);
7104 expect(declaration.variables, isNotNull); 6998 expect(declaration.variables, isNotNull);
7105 } 6999 }
7106 7000
7107 void test_parseCompilationUnitMember_class() { 7001 void test_parseCompilationUnitMember_class() {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
7356 7250
7357 void test_parseCompilationUnitMember_variableSet() { 7251 void test_parseCompilationUnitMember_variableSet() {
7358 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 7252 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7359 "parseCompilationUnitMember", 7253 "parseCompilationUnitMember",
7360 <Object>[emptyCommentAndMetadata()], 7254 <Object>[emptyCommentAndMetadata()],
7361 "String set = null;"); 7255 "String set = null;");
7362 expect(declaration.semicolon, isNotNull); 7256 expect(declaration.semicolon, isNotNull);
7363 expect(declaration.variables, isNotNull); 7257 expect(declaration.variables, isNotNull);
7364 } 7258 }
7365 7259
7260 void test_parseCompilationUnit_abstractAsPrefix_parameterized() {
7261 CompilationUnit unit = ParserTestCase.parse4(
7262 "parseCompilationUnit",
7263 "abstract<dynamic> _abstract = new abstract.A();");
7264 expect(unit.scriptTag, isNull);
7265 expect(unit.directives, hasLength(0));
7266 expect(unit.declarations, hasLength(1));
7267 }
7268
7269 void test_parseCompilationUnit_builtIn_asFunctionName() {
7270 ParserTestCase.parse4("parseCompilationUnit", "abstract(x) => 0;");
7271 ParserTestCase.parse4("parseCompilationUnit", "as(x) => 0;");
7272 ParserTestCase.parse4("parseCompilationUnit", "dynamic(x) => 0;");
7273 ParserTestCase.parse4("parseCompilationUnit", "export(x) => 0;");
7274 ParserTestCase.parse4("parseCompilationUnit", "external(x) => 0;");
7275 ParserTestCase.parse4("parseCompilationUnit", "factory(x) => 0;");
7276 ParserTestCase.parse4("parseCompilationUnit", "get(x) => 0;");
7277 ParserTestCase.parse4("parseCompilationUnit", "implements(x) => 0;");
7278 ParserTestCase.parse4("parseCompilationUnit", "import(x) => 0;");
7279 ParserTestCase.parse4("parseCompilationUnit", "library(x) => 0;");
7280 ParserTestCase.parse4("parseCompilationUnit", "operator(x) => 0;");
7281 ParserTestCase.parse4("parseCompilationUnit", "part(x) => 0;");
7282 ParserTestCase.parse4("parseCompilationUnit", "set(x) => 0;");
7283 ParserTestCase.parse4("parseCompilationUnit", "static(x) => 0;");
7284 ParserTestCase.parse4("parseCompilationUnit", "typedef(x) => 0;");
7285 }
7286
7287 void test_parseCompilationUnit_directives_multiple() {
7288 CompilationUnit unit =
7289 ParserTestCase.parse4("parseCompilationUnit", "library l;\npart 'a.dart' ;");
7290 expect(unit.scriptTag, isNull);
7291 expect(unit.directives, hasLength(2));
7292 expect(unit.declarations, hasLength(0));
7293 }
7294
7295 void test_parseCompilationUnit_directives_single() {
7296 CompilationUnit unit =
7297 ParserTestCase.parse4("parseCompilationUnit", "library l;");
7298 expect(unit.scriptTag, isNull);
7299 expect(unit.directives, hasLength(1));
7300 expect(unit.declarations, hasLength(0));
7301 }
7302
7303 void test_parseCompilationUnit_empty() {
7304 CompilationUnit unit = ParserTestCase.parse4("parseCompilationUnit", "");
7305 expect(unit.scriptTag, isNull);
7306 expect(unit.directives, hasLength(0));
7307 expect(unit.declarations, hasLength(0));
7308 }
7309
7310 void test_parseCompilationUnit_exportAsPrefix() {
7311 CompilationUnit unit = ParserTestCase.parse4(
7312 "parseCompilationUnit",
7313 "export.A _export = new export.A();");
7314 expect(unit.scriptTag, isNull);
7315 expect(unit.directives, hasLength(0));
7316 expect(unit.declarations, hasLength(1));
7317 }
7318
7319 void test_parseCompilationUnit_exportAsPrefix_parameterized() {
7320 CompilationUnit unit = ParserTestCase.parse4(
7321 "parseCompilationUnit",
7322 "export<dynamic> _export = new export.A();");
7323 expect(unit.scriptTag, isNull);
7324 expect(unit.directives, hasLength(0));
7325 expect(unit.declarations, hasLength(1));
7326 }
7327
7328 void test_parseCompilationUnit_operatorAsPrefix_parameterized() {
7329 CompilationUnit unit = ParserTestCase.parse4(
7330 "parseCompilationUnit",
7331 "operator<dynamic> _operator = new operator.A();");
7332 expect(unit.scriptTag, isNull);
7333 expect(unit.directives, hasLength(0));
7334 expect(unit.declarations, hasLength(1));
7335 }
7336
7337 void test_parseCompilationUnit_script() {
7338 CompilationUnit unit =
7339 ParserTestCase.parse4("parseCompilationUnit", "#! /bin/dart");
7340 expect(unit.scriptTag, isNotNull);
7341 expect(unit.directives, hasLength(0));
7342 expect(unit.declarations, hasLength(0));
7343 }
7344
7345 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() {
7346 ParserTestCase.parseFunctionBodies = false;
7347 CompilationUnit unit =
7348 ParserTestCase.parse4("parseCompilationUnit", "f() { '\${n}'; }");
7349 expect(unit.scriptTag, isNull);
7350 expect(unit.declarations, hasLength(1));
7351 }
7352
7353 void test_parseCompilationUnit_topLevelDeclaration() {
7354 CompilationUnit unit =
7355 ParserTestCase.parse4("parseCompilationUnit", "class A {}");
7356 expect(unit.scriptTag, isNull);
7357 expect(unit.directives, hasLength(0));
7358 expect(unit.declarations, hasLength(1));
7359 }
7360
7361 void test_parseCompilationUnit_typedefAsPrefix() {
7362 CompilationUnit unit = ParserTestCase.parse4(
7363 "parseCompilationUnit",
7364 "typedef.A _typedef = new typedef.A();");
7365 expect(unit.scriptTag, isNull);
7366 expect(unit.directives, hasLength(0));
7367 expect(unit.declarations, hasLength(1));
7368 }
7369
7366 void test_parseConditionalExpression() { 7370 void test_parseConditionalExpression() {
7367 ConditionalExpression expression = 7371 ConditionalExpression expression =
7368 ParserTestCase.parse4("parseConditionalExpression", "x ? y : z"); 7372 ParserTestCase.parse4("parseConditionalExpression", "x ? y : z");
7369 expect(expression.condition, isNotNull); 7373 expect(expression.condition, isNotNull);
7370 expect(expression.question, isNotNull); 7374 expect(expression.question, isNotNull);
7371 expect(expression.thenExpression, isNotNull); 7375 expect(expression.thenExpression, isNotNull);
7372 expect(expression.colon, isNotNull); 7376 expect(expression.colon, isNotNull);
7373 expect(expression.elseExpression, isNotNull); 7377 expect(expression.elseExpression, isNotNull);
7374 } 7378 }
7375 7379
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
7424 } 7428 }
7425 7429
7426 void test_parseConstructor() { 7430 void test_parseConstructor() {
7427 // TODO(brianwilkerson) Implement tests for this method. 7431 // TODO(brianwilkerson) Implement tests for this method.
7428 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class, 7432 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class,
7429 // Token.class, Token.class, SimpleIdentifier.class, Token.class, 7433 // Token.class, Token.class, SimpleIdentifier.class, Token.class,
7430 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt yCommentAndMetadata(), 7434 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt yCommentAndMetadata(),
7431 // null, null, null, null, null, null}, ""); 7435 // null, null, null, null, null, null}, "");
7432 } 7436 }
7433 7437
7434 void test_parseConstructor_with_pseudo_function_literal() {
7435 // "(b) {}" should not be misinterpreted as a function literal even though
7436 // it looks like one.
7437 ClassMember classMember =
7438 ParserTestCase.parse("parseClassMember", <Object>["C"], "C() : a = (b) { }");
7439 EngineTestCase.assertInstanceOf(
7440 (obj) => obj is ConstructorDeclaration,
7441 ConstructorDeclaration,
7442 classMember);
7443 ConstructorDeclaration constructor = classMember as ConstructorDeclaration;
7444 NodeList<ConstructorInitializer> initializers = constructor.initializers;
7445 expect(initializers, hasLength(1));
7446 ConstructorInitializer initializer = initializers[0];
7447 EngineTestCase.assertInstanceOf(
7448 (obj) => obj is ConstructorFieldInitializer,
7449 ConstructorFieldInitializer,
7450 initializer);
7451 EngineTestCase.assertInstanceOf(
7452 (obj) => obj is ParenthesizedExpression,
7453 ParenthesizedExpression,
7454 (initializer as ConstructorFieldInitializer).expression);
7455 EngineTestCase.assertInstanceOf(
7456 (obj) => obj is BlockFunctionBody,
7457 BlockFunctionBody,
7458 constructor.body);
7459 }
7460
7461 void test_parseConstructorFieldInitializer_qualified() { 7438 void test_parseConstructorFieldInitializer_qualified() {
7462 ConstructorFieldInitializer invocation = 7439 ConstructorFieldInitializer invocation =
7463 ParserTestCase.parse4("parseConstructorFieldInitializer", "this.a = b"); 7440 ParserTestCase.parse4("parseConstructorFieldInitializer", "this.a = b");
7464 expect(invocation.equals, isNotNull); 7441 expect(invocation.equals, isNotNull);
7465 expect(invocation.expression, isNotNull); 7442 expect(invocation.expression, isNotNull);
7466 expect(invocation.fieldName, isNotNull); 7443 expect(invocation.fieldName, isNotNull);
7467 expect(invocation.keyword, isNotNull); 7444 expect(invocation.keyword, isNotNull);
7468 expect(invocation.period, isNotNull); 7445 expect(invocation.period, isNotNull);
7469 } 7446 }
7470 7447
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
7502 } 7479 }
7503 7480
7504 void test_parseConstructorName_unnamed_prefixed() { 7481 void test_parseConstructorName_unnamed_prefixed() {
7505 ConstructorName name = 7482 ConstructorName name =
7506 ParserTestCase.parse4("parseConstructorName", "p.A;"); 7483 ParserTestCase.parse4("parseConstructorName", "p.A;");
7507 expect(name.type, isNotNull); 7484 expect(name.type, isNotNull);
7508 expect(name.period, isNull); 7485 expect(name.period, isNull);
7509 expect(name.name, isNull); 7486 expect(name.name, isNull);
7510 } 7487 }
7511 7488
7489 void test_parseConstructor_with_pseudo_function_literal() {
7490 // "(b) {}" should not be misinterpreted as a function literal even though
7491 // it looks like one.
7492 ClassMember classMember =
7493 ParserTestCase.parse("parseClassMember", <Object>["C"], "C() : a = (b) { }");
7494 EngineTestCase.assertInstanceOf(
7495 (obj) => obj is ConstructorDeclaration,
7496 ConstructorDeclaration,
7497 classMember);
7498 ConstructorDeclaration constructor = classMember as ConstructorDeclaration;
7499 NodeList<ConstructorInitializer> initializers = constructor.initializers;
7500 expect(initializers, hasLength(1));
7501 ConstructorInitializer initializer = initializers[0];
7502 EngineTestCase.assertInstanceOf(
7503 (obj) => obj is ConstructorFieldInitializer,
7504 ConstructorFieldInitializer,
7505 initializer);
7506 EngineTestCase.assertInstanceOf(
7507 (obj) => obj is ParenthesizedExpression,
7508 ParenthesizedExpression,
7509 (initializer as ConstructorFieldInitializer).expression);
7510 EngineTestCase.assertInstanceOf(
7511 (obj) => obj is BlockFunctionBody,
7512 BlockFunctionBody,
7513 constructor.body);
7514 }
7515
7512 void test_parseContinueStatement_label() { 7516 void test_parseContinueStatement_label() {
7513 ContinueStatement statement = ParserTestCase.parse4( 7517 ContinueStatement statement = ParserTestCase.parse4(
7514 "parseContinueStatement", 7518 "parseContinueStatement",
7515 "continue foo;", 7519 "continue foo;",
7516 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); 7520 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
7517 expect(statement.keyword, isNotNull); 7521 expect(statement.keyword, isNotNull);
7518 expect(statement.label, isNotNull); 7522 expect(statement.label, isNotNull);
7519 expect(statement.semicolon, isNotNull); 7523 expect(statement.semicolon, isNotNull);
7520 } 7524 }
7521 7525
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
7621 expect(unit.scriptTag, isNull); 7625 expect(unit.scriptTag, isNull);
7622 expect(unit.directives, hasLength(1)); 7626 expect(unit.directives, hasLength(1));
7623 } 7627 }
7624 7628
7625 void test_parseDirectives_topLevelDeclaration() { 7629 void test_parseDirectives_topLevelDeclaration() {
7626 CompilationUnit unit = _parseDirectives("class A {}"); 7630 CompilationUnit unit = _parseDirectives("class A {}");
7627 expect(unit.scriptTag, isNull); 7631 expect(unit.scriptTag, isNull);
7628 expect(unit.directives, hasLength(0)); 7632 expect(unit.directives, hasLength(0));
7629 } 7633 }
7630 7634
7635 void test_parseDoStatement() {
7636 DoStatement statement =
7637 ParserTestCase.parse4("parseDoStatement", "do {} while (x);");
7638 expect(statement.doKeyword, isNotNull);
7639 expect(statement.body, isNotNull);
7640 expect(statement.whileKeyword, isNotNull);
7641 expect(statement.leftParenthesis, isNotNull);
7642 expect(statement.condition, isNotNull);
7643 expect(statement.rightParenthesis, isNotNull);
7644 expect(statement.semicolon, isNotNull);
7645 }
7646
7631 void test_parseDocumentationComment_block() { 7647 void test_parseDocumentationComment_block() {
7632 Comment comment = 7648 Comment comment =
7633 ParserTestCase.parse4("parseDocumentationComment", "/** */ class"); 7649 ParserTestCase.parse4("parseDocumentationComment", "/** */ class");
7634 expect(comment.isBlock, isFalse); 7650 expect(comment.isBlock, isFalse);
7635 expect(comment.isDocumentation, isTrue); 7651 expect(comment.isDocumentation, isTrue);
7636 expect(comment.isEndOfLine, isFalse); 7652 expect(comment.isEndOfLine, isFalse);
7637 } 7653 }
7638 7654
7639 void test_parseDocumentationComment_block_withReference() { 7655 void test_parseDocumentationComment_block_withReference() {
7640 Comment comment = 7656 Comment comment =
7641 ParserTestCase.parse4("parseDocumentationComment", "/** [a] */ class"); 7657 ParserTestCase.parse4("parseDocumentationComment", "/** [a] */ class");
7642 expect(comment.isBlock, isFalse); 7658 expect(comment.isBlock, isFalse);
7643 expect(comment.isDocumentation, isTrue); 7659 expect(comment.isDocumentation, isTrue);
7644 expect(comment.isEndOfLine, isFalse); 7660 expect(comment.isEndOfLine, isFalse);
7645 NodeList<CommentReference> references = comment.references; 7661 NodeList<CommentReference> references = comment.references;
7646 expect(references, hasLength(1)); 7662 expect(references, hasLength(1));
7647 CommentReference reference = references[0]; 7663 CommentReference reference = references[0];
7648 expect(reference, isNotNull); 7664 expect(reference, isNotNull);
7649 expect(reference.offset, 5); 7665 expect(reference.offset, 5);
7650 } 7666 }
7651 7667
7652 void test_parseDocumentationComment_endOfLine() { 7668 void test_parseDocumentationComment_endOfLine() {
7653 Comment comment = 7669 Comment comment =
7654 ParserTestCase.parse4("parseDocumentationComment", "/// \n/// \n class") ; 7670 ParserTestCase.parse4("parseDocumentationComment", "/// \n/// \n class") ;
7655 expect(comment.isBlock, isFalse); 7671 expect(comment.isBlock, isFalse);
7656 expect(comment.isDocumentation, isTrue); 7672 expect(comment.isDocumentation, isTrue);
7657 expect(comment.isEndOfLine, isFalse); 7673 expect(comment.isEndOfLine, isFalse);
7658 } 7674 }
7659 7675
7660 void test_parseDoStatement() {
7661 DoStatement statement =
7662 ParserTestCase.parse4("parseDoStatement", "do {} while (x);");
7663 expect(statement.doKeyword, isNotNull);
7664 expect(statement.body, isNotNull);
7665 expect(statement.whileKeyword, isNotNull);
7666 expect(statement.leftParenthesis, isNotNull);
7667 expect(statement.condition, isNotNull);
7668 expect(statement.rightParenthesis, isNotNull);
7669 expect(statement.semicolon, isNotNull);
7670 }
7671
7672 void test_parseEmptyStatement() { 7676 void test_parseEmptyStatement() {
7673 EmptyStatement statement = 7677 EmptyStatement statement =
7674 ParserTestCase.parse4("parseEmptyStatement", ";"); 7678 ParserTestCase.parse4("parseEmptyStatement", ";");
7675 expect(statement.semicolon, isNotNull); 7679 expect(statement.semicolon, isNotNull);
7676 } 7680 }
7677 7681
7678 void test_parseEnumDeclaration_one() { 7682 void test_parseEnumDeclaration_one() {
7679 EnumDeclaration declaration = ParserTestCase.parse( 7683 EnumDeclaration declaration = ParserTestCase.parse(
7680 "parseEnumDeclaration", 7684 "parseEnumDeclaration",
7681 <Object>[emptyCommentAndMetadata()], 7685 <Object>[emptyCommentAndMetadata()],
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
7783 ExportDirective directive = ParserTestCase.parse( 7787 ExportDirective directive = ParserTestCase.parse(
7784 "parseExportDirective", 7788 "parseExportDirective",
7785 <Object>[emptyCommentAndMetadata()], 7789 <Object>[emptyCommentAndMetadata()],
7786 "export 'lib/lib.dart' show B hide A;"); 7790 "export 'lib/lib.dart' show B hide A;");
7787 expect(directive.keyword, isNotNull); 7791 expect(directive.keyword, isNotNull);
7788 expect(directive.uri, isNotNull); 7792 expect(directive.uri, isNotNull);
7789 expect(directive.combinators, hasLength(2)); 7793 expect(directive.combinators, hasLength(2));
7790 expect(directive.semicolon, isNotNull); 7794 expect(directive.semicolon, isNotNull);
7791 } 7795 }
7792 7796
7797 void test_parseExpressionList_multiple() {
7798 List<Expression> result =
7799 ParserTestCase.parse4("parseExpressionList", "1, 2, 3");
7800 expect(result, hasLength(3));
7801 }
7802
7803 void test_parseExpressionList_single() {
7804 List<Expression> result = ParserTestCase.parse4("parseExpressionList", "1");
7805 expect(result, hasLength(1));
7806 }
7807
7808 void test_parseExpressionWithoutCascade_assign() {
7809 // TODO(brianwilkerson) Implement more tests for this method.
7810 AssignmentExpression expression =
7811 ParserTestCase.parse4("parseExpressionWithoutCascade", "x = y");
7812 expect(expression.leftHandSide, isNotNull);
7813 expect(expression.operator, isNotNull);
7814 expect(expression.operator.type, TokenType.EQ);
7815 expect(expression.rightHandSide, isNotNull);
7816 }
7817
7818 void test_parseExpressionWithoutCascade_comparison() {
7819 BinaryExpression expression =
7820 ParserTestCase.parse4("parseExpressionWithoutCascade", "--a.b == c");
7821 expect(expression.leftOperand, isNotNull);
7822 expect(expression.operator, isNotNull);
7823 expect(expression.operator.type, TokenType.EQ_EQ);
7824 expect(expression.rightOperand, isNotNull);
7825 }
7826
7827 void test_parseExpressionWithoutCascade_superMethodInvocation() {
7828 MethodInvocation invocation =
7829 ParserTestCase.parse4("parseExpressionWithoutCascade", "super.m()");
7830 expect(invocation.target, isNotNull);
7831 expect(invocation.methodName, isNotNull);
7832 expect(invocation.argumentList, isNotNull);
7833 }
7834
7793 void test_parseExpression_assign() { 7835 void test_parseExpression_assign() {
7794 // TODO(brianwilkerson) Implement more tests for this method. 7836 // TODO(brianwilkerson) Implement more tests for this method.
7795 AssignmentExpression expression = 7837 AssignmentExpression expression =
7796 ParserTestCase.parse4("parseExpression", "x = y"); 7838 ParserTestCase.parse4("parseExpression", "x = y");
7797 expect(expression.leftHandSide, isNotNull); 7839 expect(expression.leftHandSide, isNotNull);
7798 expect(expression.operator, isNotNull); 7840 expect(expression.operator, isNotNull);
7799 expect(expression.operator.type, TokenType.EQ); 7841 expect(expression.operator.type, TokenType.EQ);
7800 expect(expression.rightHandSide, isNotNull); 7842 expect(expression.rightHandSide, isNotNull);
7801 } 7843 }
7802 7844
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
7865 } 7907 }
7866 7908
7867 void test_parseExpression_superMethodInvocation() { 7909 void test_parseExpression_superMethodInvocation() {
7868 MethodInvocation invocation = 7910 MethodInvocation invocation =
7869 ParserTestCase.parse4("parseExpression", "super.m()"); 7911 ParserTestCase.parse4("parseExpression", "super.m()");
7870 expect(invocation.target, isNotNull); 7912 expect(invocation.target, isNotNull);
7871 expect(invocation.methodName, isNotNull); 7913 expect(invocation.methodName, isNotNull);
7872 expect(invocation.argumentList, isNotNull); 7914 expect(invocation.argumentList, isNotNull);
7873 } 7915 }
7874 7916
7875 void test_parseExpressionList_multiple() {
7876 List<Expression> result =
7877 ParserTestCase.parse4("parseExpressionList", "1, 2, 3");
7878 expect(result, hasLength(3));
7879 }
7880
7881 void test_parseExpressionList_single() {
7882 List<Expression> result = ParserTestCase.parse4("parseExpressionList", "1");
7883 expect(result, hasLength(1));
7884 }
7885
7886 void test_parseExpressionWithoutCascade_assign() {
7887 // TODO(brianwilkerson) Implement more tests for this method.
7888 AssignmentExpression expression =
7889 ParserTestCase.parse4("parseExpressionWithoutCascade", "x = y");
7890 expect(expression.leftHandSide, isNotNull);
7891 expect(expression.operator, isNotNull);
7892 expect(expression.operator.type, TokenType.EQ);
7893 expect(expression.rightHandSide, isNotNull);
7894 }
7895
7896 void test_parseExpressionWithoutCascade_comparison() {
7897 BinaryExpression expression =
7898 ParserTestCase.parse4("parseExpressionWithoutCascade", "--a.b == c");
7899 expect(expression.leftOperand, isNotNull);
7900 expect(expression.operator, isNotNull);
7901 expect(expression.operator.type, TokenType.EQ_EQ);
7902 expect(expression.rightOperand, isNotNull);
7903 }
7904
7905 void test_parseExpressionWithoutCascade_superMethodInvocation() {
7906 MethodInvocation invocation =
7907 ParserTestCase.parse4("parseExpressionWithoutCascade", "super.m()");
7908 expect(invocation.target, isNotNull);
7909 expect(invocation.methodName, isNotNull);
7910 expect(invocation.argumentList, isNotNull);
7911 }
7912
7913 void test_parseExtendsClause() { 7917 void test_parseExtendsClause() {
7914 ExtendsClause clause = 7918 ExtendsClause clause =
7915 ParserTestCase.parse4("parseExtendsClause", "extends B"); 7919 ParserTestCase.parse4("parseExtendsClause", "extends B");
7916 expect(clause.keyword, isNotNull); 7920 expect(clause.keyword, isNotNull);
7917 expect(clause.superclass, isNotNull); 7921 expect(clause.superclass, isNotNull);
7918 EngineTestCase.assertInstanceOf( 7922 EngineTestCase.assertInstanceOf(
7919 (obj) => obj is TypeName, 7923 (obj) => obj is TypeName,
7920 TypeName, 7924 TypeName,
7921 clause.superclass); 7925 clause.superclass);
7922 } 7926 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
7980 expect(result.type, isNotNull); 7984 expect(result.type, isNotNull);
7981 } 7985 }
7982 7986
7983 void test_parseFinalConstVarOrType_type_prefixed() { 7987 void test_parseFinalConstVarOrType_type_prefixed() {
7984 FinalConstVarOrType result = 7988 FinalConstVarOrType result =
7985 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A a "); 7989 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A a ");
7986 expect(result.keyword, isNull); 7990 expect(result.keyword, isNull);
7987 expect(result.type, isNotNull); 7991 expect(result.type, isNotNull);
7988 } 7992 }
7989 7993
7994 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() {
7995 FinalConstVarOrType result =
7996 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A<B > a");
7997 expect(result.keyword, isNull);
7998 expect(result.type, isNotNull);
7999 }
8000
7990 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() { 8001 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() {
7991 FinalConstVarOrType result = 8002 FinalConstVarOrType result =
7992 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A," ); 8003 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A," );
7993 expect(result.keyword, isNull); 8004 expect(result.keyword, isNull);
7994 expect(result.type, isNotNull); 8005 expect(result.type, isNotNull);
7995 } 8006 }
7996
7997 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() {
7998 FinalConstVarOrType result =
7999 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A<B > a");
8000 expect(result.keyword, isNull);
8001 expect(result.type, isNotNull);
8002 }
8003 8007
8004 void test_parseFinalConstVarOrType_type_simple() { 8008 void test_parseFinalConstVarOrType_type_simple() {
8005 FinalConstVarOrType result = 8009 FinalConstVarOrType result =
8006 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "A a") ; 8010 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "A a") ;
8007 expect(result.keyword, isNull); 8011 expect(result.keyword, isNull);
8008 expect(result.type, isNotNull); 8012 expect(result.type, isNotNull);
8009 } 8013 }
8010 8014
8011 void test_parseFinalConstVarOrType_var() { 8015 void test_parseFinalConstVarOrType_var() {
8012 FinalConstVarOrType result = 8016 FinalConstVarOrType result =
(...skipping 12 matching lines...) Expand all
8025 expect(result.type, isNotNull); 8029 expect(result.type, isNotNull);
8026 } 8030 }
8027 8031
8028 void test_parseFinalConstVarOrType_void_noIdentifier() { 8032 void test_parseFinalConstVarOrType_void_noIdentifier() {
8029 FinalConstVarOrType result = 8033 FinalConstVarOrType result =
8030 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "void, "); 8034 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "void, ");
8031 expect(result.keyword, isNull); 8035 expect(result.keyword, isNull);
8032 expect(result.type, isNotNull); 8036 expect(result.type, isNotNull);
8033 } 8037 }
8034 8038
8035 void test_parseFormalParameter_final_withType_named() {
8036 ParameterKind kind = ParameterKind.NAMED;
8037 DefaultFormalParameter parameter = ParserTestCase.parse(
8038 "parseFormalParameter",
8039 <Object>[kind],
8040 "final A a : null");
8041 SimpleFormalParameter simpleParameter =
8042 parameter.parameter as SimpleFormalParameter;
8043 expect(simpleParameter.identifier, isNotNull);
8044 expect(simpleParameter.keyword, isNotNull);
8045 expect(simpleParameter.type, isNotNull);
8046 expect(simpleParameter.kind, kind);
8047 expect(parameter.separator, isNotNull);
8048 expect(parameter.defaultValue, isNotNull);
8049 expect(parameter.kind, kind);
8050 }
8051
8052 void test_parseFormalParameter_final_withType_normal() {
8053 ParameterKind kind = ParameterKind.REQUIRED;
8054 SimpleFormalParameter parameter =
8055 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "final A a" );
8056 expect(parameter.identifier, isNotNull);
8057 expect(parameter.keyword, isNotNull);
8058 expect(parameter.type, isNotNull);
8059 expect(parameter.kind, kind);
8060 }
8061
8062 void test_parseFormalParameter_final_withType_positional() {
8063 ParameterKind kind = ParameterKind.POSITIONAL;
8064 DefaultFormalParameter parameter = ParserTestCase.parse(
8065 "parseFormalParameter",
8066 <Object>[kind],
8067 "final A a = null");
8068 SimpleFormalParameter simpleParameter =
8069 parameter.parameter as SimpleFormalParameter;
8070 expect(simpleParameter.identifier, isNotNull);
8071 expect(simpleParameter.keyword, isNotNull);
8072 expect(simpleParameter.type, isNotNull);
8073 expect(simpleParameter.kind, kind);
8074 expect(parameter.separator, isNotNull);
8075 expect(parameter.defaultValue, isNotNull);
8076 expect(parameter.kind, kind);
8077 }
8078
8079 void test_parseFormalParameter_nonFinal_withType_named() {
8080 ParameterKind kind = ParameterKind.NAMED;
8081 DefaultFormalParameter parameter =
8082 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a : null ");
8083 SimpleFormalParameter simpleParameter =
8084 parameter.parameter as SimpleFormalParameter;
8085 expect(simpleParameter.identifier, isNotNull);
8086 expect(simpleParameter.keyword, isNull);
8087 expect(simpleParameter.type, isNotNull);
8088 expect(simpleParameter.kind, kind);
8089 expect(parameter.separator, isNotNull);
8090 expect(parameter.defaultValue, isNotNull);
8091 expect(parameter.kind, kind);
8092 }
8093
8094 void test_parseFormalParameter_nonFinal_withType_normal() {
8095 ParameterKind kind = ParameterKind.REQUIRED;
8096 SimpleFormalParameter parameter =
8097 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a");
8098 expect(parameter.identifier, isNotNull);
8099 expect(parameter.keyword, isNull);
8100 expect(parameter.type, isNotNull);
8101 expect(parameter.kind, kind);
8102 }
8103
8104 void test_parseFormalParameter_nonFinal_withType_positional() {
8105 ParameterKind kind = ParameterKind.POSITIONAL;
8106 DefaultFormalParameter parameter =
8107 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a = null ");
8108 SimpleFormalParameter simpleParameter =
8109 parameter.parameter as SimpleFormalParameter;
8110 expect(simpleParameter.identifier, isNotNull);
8111 expect(simpleParameter.keyword, isNull);
8112 expect(simpleParameter.type, isNotNull);
8113 expect(simpleParameter.kind, kind);
8114 expect(parameter.separator, isNotNull);
8115 expect(parameter.defaultValue, isNotNull);
8116 expect(parameter.kind, kind);
8117 }
8118
8119 void test_parseFormalParameter_var() {
8120 ParameterKind kind = ParameterKind.REQUIRED;
8121 SimpleFormalParameter parameter =
8122 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a");
8123 expect(parameter.identifier, isNotNull);
8124 expect(parameter.keyword, isNotNull);
8125 expect(parameter.type, isNull);
8126 expect(parameter.kind, kind);
8127 }
8128
8129 void test_parseFormalParameter_var_named() {
8130 ParameterKind kind = ParameterKind.NAMED;
8131 DefaultFormalParameter parameter =
8132 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a : nu ll");
8133 SimpleFormalParameter simpleParameter =
8134 parameter.parameter as SimpleFormalParameter;
8135 expect(simpleParameter.identifier, isNotNull);
8136 expect(simpleParameter.keyword, isNotNull);
8137 expect(simpleParameter.type, isNull);
8138 expect(simpleParameter.kind, kind);
8139 expect(parameter.separator, isNotNull);
8140 expect(parameter.defaultValue, isNotNull);
8141 expect(parameter.kind, kind);
8142 }
8143
8144 void test_parseFormalParameter_var_positional() {
8145 ParameterKind kind = ParameterKind.POSITIONAL;
8146 DefaultFormalParameter parameter =
8147 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a = nu ll");
8148 SimpleFormalParameter simpleParameter =
8149 parameter.parameter as SimpleFormalParameter;
8150 expect(simpleParameter.identifier, isNotNull);
8151 expect(simpleParameter.keyword, isNotNull);
8152 expect(simpleParameter.type, isNull);
8153 expect(simpleParameter.kind, kind);
8154 expect(parameter.separator, isNotNull);
8155 expect(parameter.defaultValue, isNotNull);
8156 expect(parameter.kind, kind);
8157 }
8158
8159 void test_parseFormalParameterList_empty() {
8160 FormalParameterList parameterList =
8161 ParserTestCase.parse4("parseFormalParameterList", "()");
8162 expect(parameterList.leftParenthesis, isNotNull);
8163 expect(parameterList.leftDelimiter, isNull);
8164 expect(parameterList.parameters, hasLength(0));
8165 expect(parameterList.rightDelimiter, isNull);
8166 expect(parameterList.rightParenthesis, isNotNull);
8167 }
8168
8169 void test_parseFormalParameterList_named_multiple() {
8170 FormalParameterList parameterList =
8171 ParserTestCase.parse4("parseFormalParameterList", "({A a : 1, B b, C c : 3})");
8172 expect(parameterList.leftParenthesis, isNotNull);
8173 expect(parameterList.leftDelimiter, isNotNull);
8174 expect(parameterList.parameters, hasLength(3));
8175 expect(parameterList.rightDelimiter, isNotNull);
8176 expect(parameterList.rightParenthesis, isNotNull);
8177 }
8178
8179 void test_parseFormalParameterList_named_single() {
8180 FormalParameterList parameterList =
8181 ParserTestCase.parse4("parseFormalParameterList", "({A a})");
8182 expect(parameterList.leftParenthesis, isNotNull);
8183 expect(parameterList.leftDelimiter, isNotNull);
8184 expect(parameterList.parameters, hasLength(1));
8185 expect(parameterList.rightDelimiter, isNotNull);
8186 expect(parameterList.rightParenthesis, isNotNull);
8187 }
8188
8189 void test_parseFormalParameterList_normal_multiple() {
8190 FormalParameterList parameterList =
8191 ParserTestCase.parse4("parseFormalParameterList", "(A a, B b, C c)");
8192 expect(parameterList.leftParenthesis, isNotNull);
8193 expect(parameterList.leftDelimiter, isNull);
8194 expect(parameterList.parameters, hasLength(3));
8195 expect(parameterList.rightDelimiter, isNull);
8196 expect(parameterList.rightParenthesis, isNotNull);
8197 }
8198
8199 void test_parseFormalParameterList_normal_named() {
8200 FormalParameterList parameterList =
8201 ParserTestCase.parse4("parseFormalParameterList", "(A a, {B b})");
8202 expect(parameterList.leftParenthesis, isNotNull);
8203 expect(parameterList.leftDelimiter, isNotNull);
8204 expect(parameterList.parameters, hasLength(2));
8205 expect(parameterList.rightDelimiter, isNotNull);
8206 expect(parameterList.rightParenthesis, isNotNull);
8207 }
8208
8209 void test_parseFormalParameterList_normal_positional() {
8210 FormalParameterList parameterList =
8211 ParserTestCase.parse4("parseFormalParameterList", "(A a, [B b])");
8212 expect(parameterList.leftParenthesis, isNotNull);
8213 expect(parameterList.leftDelimiter, isNotNull);
8214 expect(parameterList.parameters, hasLength(2));
8215 expect(parameterList.rightDelimiter, isNotNull);
8216 expect(parameterList.rightParenthesis, isNotNull);
8217 }
8218
8219 void test_parseFormalParameterList_normal_single() {
8220 FormalParameterList parameterList =
8221 ParserTestCase.parse4("parseFormalParameterList", "(A a)");
8222 expect(parameterList.leftParenthesis, isNotNull);
8223 expect(parameterList.leftDelimiter, isNull);
8224 expect(parameterList.parameters, hasLength(1));
8225 expect(parameterList.rightDelimiter, isNull);
8226 expect(parameterList.rightParenthesis, isNotNull);
8227 }
8228
8229 void test_parseFormalParameterList_positional_multiple() {
8230 FormalParameterList parameterList = ParserTestCase.parse4(
8231 "parseFormalParameterList",
8232 "([A a = null, B b, C c = null])");
8233 expect(parameterList.leftParenthesis, isNotNull);
8234 expect(parameterList.leftDelimiter, isNotNull);
8235 expect(parameterList.parameters, hasLength(3));
8236 expect(parameterList.rightDelimiter, isNotNull);
8237 expect(parameterList.rightParenthesis, isNotNull);
8238 }
8239
8240 void test_parseFormalParameterList_positional_single() {
8241 FormalParameterList parameterList =
8242 ParserTestCase.parse4("parseFormalParameterList", "([A a = null])");
8243 expect(parameterList.leftParenthesis, isNotNull);
8244 expect(parameterList.leftDelimiter, isNotNull);
8245 expect(parameterList.parameters, hasLength(1));
8246 expect(parameterList.rightDelimiter, isNotNull);
8247 expect(parameterList.rightParenthesis, isNotNull);
8248 }
8249
8250 void test_parseForStatement_each_await() { 8039 void test_parseForStatement_each_await() {
8251 ForEachStatement statement = 8040 ForEachStatement statement =
8252 ParserTestCase.parse4("parseForStatement", "await for (element in list) {}"); 8041 ParserTestCase.parse4("parseForStatement", "await for (element in list) {}");
8253 expect(statement.awaitKeyword, isNotNull); 8042 expect(statement.awaitKeyword, isNotNull);
8254 expect(statement.forKeyword, isNotNull); 8043 expect(statement.forKeyword, isNotNull);
8255 expect(statement.leftParenthesis, isNotNull); 8044 expect(statement.leftParenthesis, isNotNull);
8256 expect(statement.loopVariable, isNull); 8045 expect(statement.loopVariable, isNull);
8257 expect(statement.identifier, isNotNull); 8046 expect(statement.identifier, isNotNull);
8258 expect(statement.inKeyword, isNotNull); 8047 expect(statement.inKeyword, isNotNull);
8259 expect(statement.iterable, isNotNull); 8048 expect(statement.iterable, isNotNull);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
8477 expect(statement.variables, isNull); 8266 expect(statement.variables, isNull);
8478 expect(statement.initialization, isNull); 8267 expect(statement.initialization, isNull);
8479 expect(statement.leftSeparator, isNotNull); 8268 expect(statement.leftSeparator, isNotNull);
8480 expect(statement.condition, isNull); 8269 expect(statement.condition, isNull);
8481 expect(statement.rightSeparator, isNotNull); 8270 expect(statement.rightSeparator, isNotNull);
8482 expect(statement.updaters, hasLength(1)); 8271 expect(statement.updaters, hasLength(1));
8483 expect(statement.rightParenthesis, isNotNull); 8272 expect(statement.rightParenthesis, isNotNull);
8484 expect(statement.body, isNotNull); 8273 expect(statement.body, isNotNull);
8485 } 8274 }
8486 8275
8276 void test_parseFormalParameterList_empty() {
8277 FormalParameterList parameterList =
8278 ParserTestCase.parse4("parseFormalParameterList", "()");
8279 expect(parameterList.leftParenthesis, isNotNull);
8280 expect(parameterList.leftDelimiter, isNull);
8281 expect(parameterList.parameters, hasLength(0));
8282 expect(parameterList.rightDelimiter, isNull);
8283 expect(parameterList.rightParenthesis, isNotNull);
8284 }
8285
8286 void test_parseFormalParameterList_named_multiple() {
8287 FormalParameterList parameterList =
8288 ParserTestCase.parse4("parseFormalParameterList", "({A a : 1, B b, C c : 3})");
8289 expect(parameterList.leftParenthesis, isNotNull);
8290 expect(parameterList.leftDelimiter, isNotNull);
8291 expect(parameterList.parameters, hasLength(3));
8292 expect(parameterList.rightDelimiter, isNotNull);
8293 expect(parameterList.rightParenthesis, isNotNull);
8294 }
8295
8296 void test_parseFormalParameterList_named_single() {
8297 FormalParameterList parameterList =
8298 ParserTestCase.parse4("parseFormalParameterList", "({A a})");
8299 expect(parameterList.leftParenthesis, isNotNull);
8300 expect(parameterList.leftDelimiter, isNotNull);
8301 expect(parameterList.parameters, hasLength(1));
8302 expect(parameterList.rightDelimiter, isNotNull);
8303 expect(parameterList.rightParenthesis, isNotNull);
8304 }
8305
8306 void test_parseFormalParameterList_normal_multiple() {
8307 FormalParameterList parameterList =
8308 ParserTestCase.parse4("parseFormalParameterList", "(A a, B b, C c)");
8309 expect(parameterList.leftParenthesis, isNotNull);
8310 expect(parameterList.leftDelimiter, isNull);
8311 expect(parameterList.parameters, hasLength(3));
8312 expect(parameterList.rightDelimiter, isNull);
8313 expect(parameterList.rightParenthesis, isNotNull);
8314 }
8315
8316 void test_parseFormalParameterList_normal_named() {
8317 FormalParameterList parameterList =
8318 ParserTestCase.parse4("parseFormalParameterList", "(A a, {B b})");
8319 expect(parameterList.leftParenthesis, isNotNull);
8320 expect(parameterList.leftDelimiter, isNotNull);
8321 expect(parameterList.parameters, hasLength(2));
8322 expect(parameterList.rightDelimiter, isNotNull);
8323 expect(parameterList.rightParenthesis, isNotNull);
8324 }
8325
8326 void test_parseFormalParameterList_normal_positional() {
8327 FormalParameterList parameterList =
8328 ParserTestCase.parse4("parseFormalParameterList", "(A a, [B b])");
8329 expect(parameterList.leftParenthesis, isNotNull);
8330 expect(parameterList.leftDelimiter, isNotNull);
8331 expect(parameterList.parameters, hasLength(2));
8332 expect(parameterList.rightDelimiter, isNotNull);
8333 expect(parameterList.rightParenthesis, isNotNull);
8334 }
8335
8336 void test_parseFormalParameterList_normal_single() {
8337 FormalParameterList parameterList =
8338 ParserTestCase.parse4("parseFormalParameterList", "(A a)");
8339 expect(parameterList.leftParenthesis, isNotNull);
8340 expect(parameterList.leftDelimiter, isNull);
8341 expect(parameterList.parameters, hasLength(1));
8342 expect(parameterList.rightDelimiter, isNull);
8343 expect(parameterList.rightParenthesis, isNotNull);
8344 }
8345
8346 void test_parseFormalParameterList_positional_multiple() {
8347 FormalParameterList parameterList = ParserTestCase.parse4(
8348 "parseFormalParameterList",
8349 "([A a = null, B b, C c = null])");
8350 expect(parameterList.leftParenthesis, isNotNull);
8351 expect(parameterList.leftDelimiter, isNotNull);
8352 expect(parameterList.parameters, hasLength(3));
8353 expect(parameterList.rightDelimiter, isNotNull);
8354 expect(parameterList.rightParenthesis, isNotNull);
8355 }
8356
8357 void test_parseFormalParameterList_positional_single() {
8358 FormalParameterList parameterList =
8359 ParserTestCase.parse4("parseFormalParameterList", "([A a = null])");
8360 expect(parameterList.leftParenthesis, isNotNull);
8361 expect(parameterList.leftDelimiter, isNotNull);
8362 expect(parameterList.parameters, hasLength(1));
8363 expect(parameterList.rightDelimiter, isNotNull);
8364 expect(parameterList.rightParenthesis, isNotNull);
8365 }
8366
8367 void test_parseFormalParameter_final_withType_named() {
8368 ParameterKind kind = ParameterKind.NAMED;
8369 DefaultFormalParameter parameter = ParserTestCase.parse(
8370 "parseFormalParameter",
8371 <Object>[kind],
8372 "final A a : null");
8373 SimpleFormalParameter simpleParameter =
8374 parameter.parameter as SimpleFormalParameter;
8375 expect(simpleParameter.identifier, isNotNull);
8376 expect(simpleParameter.keyword, isNotNull);
8377 expect(simpleParameter.type, isNotNull);
8378 expect(simpleParameter.kind, kind);
8379 expect(parameter.separator, isNotNull);
8380 expect(parameter.defaultValue, isNotNull);
8381 expect(parameter.kind, kind);
8382 }
8383
8384 void test_parseFormalParameter_final_withType_normal() {
8385 ParameterKind kind = ParameterKind.REQUIRED;
8386 SimpleFormalParameter parameter =
8387 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "final A a" );
8388 expect(parameter.identifier, isNotNull);
8389 expect(parameter.keyword, isNotNull);
8390 expect(parameter.type, isNotNull);
8391 expect(parameter.kind, kind);
8392 }
8393
8394 void test_parseFormalParameter_final_withType_positional() {
8395 ParameterKind kind = ParameterKind.POSITIONAL;
8396 DefaultFormalParameter parameter = ParserTestCase.parse(
8397 "parseFormalParameter",
8398 <Object>[kind],
8399 "final A a = null");
8400 SimpleFormalParameter simpleParameter =
8401 parameter.parameter as SimpleFormalParameter;
8402 expect(simpleParameter.identifier, isNotNull);
8403 expect(simpleParameter.keyword, isNotNull);
8404 expect(simpleParameter.type, isNotNull);
8405 expect(simpleParameter.kind, kind);
8406 expect(parameter.separator, isNotNull);
8407 expect(parameter.defaultValue, isNotNull);
8408 expect(parameter.kind, kind);
8409 }
8410
8411 void test_parseFormalParameter_nonFinal_withType_named() {
8412 ParameterKind kind = ParameterKind.NAMED;
8413 DefaultFormalParameter parameter =
8414 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a : null ");
8415 SimpleFormalParameter simpleParameter =
8416 parameter.parameter as SimpleFormalParameter;
8417 expect(simpleParameter.identifier, isNotNull);
8418 expect(simpleParameter.keyword, isNull);
8419 expect(simpleParameter.type, isNotNull);
8420 expect(simpleParameter.kind, kind);
8421 expect(parameter.separator, isNotNull);
8422 expect(parameter.defaultValue, isNotNull);
8423 expect(parameter.kind, kind);
8424 }
8425
8426 void test_parseFormalParameter_nonFinal_withType_normal() {
8427 ParameterKind kind = ParameterKind.REQUIRED;
8428 SimpleFormalParameter parameter =
8429 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a");
8430 expect(parameter.identifier, isNotNull);
8431 expect(parameter.keyword, isNull);
8432 expect(parameter.type, isNotNull);
8433 expect(parameter.kind, kind);
8434 }
8435
8436 void test_parseFormalParameter_nonFinal_withType_positional() {
8437 ParameterKind kind = ParameterKind.POSITIONAL;
8438 DefaultFormalParameter parameter =
8439 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "A a = null ");
8440 SimpleFormalParameter simpleParameter =
8441 parameter.parameter as SimpleFormalParameter;
8442 expect(simpleParameter.identifier, isNotNull);
8443 expect(simpleParameter.keyword, isNull);
8444 expect(simpleParameter.type, isNotNull);
8445 expect(simpleParameter.kind, kind);
8446 expect(parameter.separator, isNotNull);
8447 expect(parameter.defaultValue, isNotNull);
8448 expect(parameter.kind, kind);
8449 }
8450
8451 void test_parseFormalParameter_var() {
8452 ParameterKind kind = ParameterKind.REQUIRED;
8453 SimpleFormalParameter parameter =
8454 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a");
8455 expect(parameter.identifier, isNotNull);
8456 expect(parameter.keyword, isNotNull);
8457 expect(parameter.type, isNull);
8458 expect(parameter.kind, kind);
8459 }
8460
8461 void test_parseFormalParameter_var_named() {
8462 ParameterKind kind = ParameterKind.NAMED;
8463 DefaultFormalParameter parameter =
8464 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a : nu ll");
8465 SimpleFormalParameter simpleParameter =
8466 parameter.parameter as SimpleFormalParameter;
8467 expect(simpleParameter.identifier, isNotNull);
8468 expect(simpleParameter.keyword, isNotNull);
8469 expect(simpleParameter.type, isNull);
8470 expect(simpleParameter.kind, kind);
8471 expect(parameter.separator, isNotNull);
8472 expect(parameter.defaultValue, isNotNull);
8473 expect(parameter.kind, kind);
8474 }
8475
8476 void test_parseFormalParameter_var_positional() {
8477 ParameterKind kind = ParameterKind.POSITIONAL;
8478 DefaultFormalParameter parameter =
8479 ParserTestCase.parse("parseFormalParameter", <Object>[kind], "var a = nu ll");
8480 SimpleFormalParameter simpleParameter =
8481 parameter.parameter as SimpleFormalParameter;
8482 expect(simpleParameter.identifier, isNotNull);
8483 expect(simpleParameter.keyword, isNotNull);
8484 expect(simpleParameter.type, isNull);
8485 expect(simpleParameter.kind, kind);
8486 expect(parameter.separator, isNotNull);
8487 expect(parameter.defaultValue, isNotNull);
8488 expect(parameter.kind, kind);
8489 }
8490
8487 void test_parseFunctionBody_block() { 8491 void test_parseFunctionBody_block() {
8488 BlockFunctionBody functionBody = 8492 BlockFunctionBody functionBody =
8489 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}"); 8493 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}");
8490 expect(functionBody.keyword, isNull); 8494 expect(functionBody.keyword, isNull);
8491 expect(functionBody.star, isNull); 8495 expect(functionBody.star, isNull);
8492 expect(functionBody.block, isNotNull); 8496 expect(functionBody.block, isNotNull);
8493 expect(functionBody.isAsynchronous, isFalse); 8497 expect(functionBody.isAsynchronous, isFalse);
8494 expect(functionBody.isGenerator, isFalse); 8498 expect(functionBody.isGenerator, isFalse);
8495 expect(functionBody.isSynchronous, isTrue); 8499 expect(functionBody.isSynchronous, isTrue);
8496 } 8500 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
8622 FunctionBody functionBody = ParserTestCase.parse( 8626 FunctionBody functionBody = ParserTestCase.parse(
8623 "parseFunctionBody", 8627 "parseFunctionBody",
8624 <Object>[false, null, false], 8628 <Object>[false, null, false],
8625 "=> y;"); 8629 "=> y;");
8626 EngineTestCase.assertInstanceOf( 8630 EngineTestCase.assertInstanceOf(
8627 (obj) => obj is EmptyFunctionBody, 8631 (obj) => obj is EmptyFunctionBody,
8628 EmptyFunctionBody, 8632 EmptyFunctionBody,
8629 functionBody); 8633 functionBody);
8630 } 8634 }
8631 8635
8636 void test_parseFunctionDeclarationStatement() {
8637 FunctionDeclarationStatement statement = ParserTestCase.parse4(
8638 "parseFunctionDeclarationStatement",
8639 "void f(int p) => p * 2;");
8640 expect(statement.functionDeclaration, isNotNull);
8641 }
8642
8632 void test_parseFunctionDeclaration_function() { 8643 void test_parseFunctionDeclaration_function() {
8633 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8644 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8634 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 8645 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8635 FunctionDeclaration declaration = ParserTestCase.parse( 8646 FunctionDeclaration declaration = ParserTestCase.parse(
8636 "parseFunctionDeclaration", 8647 "parseFunctionDeclaration",
8637 <Object>[commentAndMetadata(comment), null, returnType], 8648 <Object>[commentAndMetadata(comment), null, returnType],
8638 "f() {}"); 8649 "f() {}");
8639 expect(declaration.documentationComment, comment); 8650 expect(declaration.documentationComment, comment);
8640 expect(declaration.returnType, returnType); 8651 expect(declaration.returnType, returnType);
8641 expect(declaration.name, isNotNull); 8652 expect(declaration.name, isNotNull);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
8673 expect(declaration.documentationComment, comment); 8684 expect(declaration.documentationComment, comment);
8674 expect(declaration.returnType, returnType); 8685 expect(declaration.returnType, returnType);
8675 expect(declaration.name, isNotNull); 8686 expect(declaration.name, isNotNull);
8676 FunctionExpression expression = declaration.functionExpression; 8687 FunctionExpression expression = declaration.functionExpression;
8677 expect(expression, isNotNull); 8688 expect(expression, isNotNull);
8678 expect(expression.body, isNotNull); 8689 expect(expression.body, isNotNull);
8679 expect(expression.parameters, isNotNull); 8690 expect(expression.parameters, isNotNull);
8680 expect(declaration.propertyKeyword, isNotNull); 8691 expect(declaration.propertyKeyword, isNotNull);
8681 } 8692 }
8682 8693
8683 void test_parseFunctionDeclarationStatement() {
8684 FunctionDeclarationStatement statement = ParserTestCase.parse4(
8685 "parseFunctionDeclarationStatement",
8686 "void f(int p) => p * 2;");
8687 expect(statement.functionDeclaration, isNotNull);
8688 }
8689
8690 void test_parseFunctionExpression_body_inExpression() { 8694 void test_parseFunctionExpression_body_inExpression() {
8691 FunctionExpression expression = 8695 FunctionExpression expression =
8692 ParserTestCase.parse4("parseFunctionExpression", "(int i) => i++"); 8696 ParserTestCase.parse4("parseFunctionExpression", "(int i) => i++");
8693 expect(expression.body, isNotNull); 8697 expect(expression.body, isNotNull);
8694 expect(expression.parameters, isNotNull); 8698 expect(expression.parameters, isNotNull);
8695 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 8699 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8696 } 8700 }
8697 8701
8698 void test_parseGetter_nonStatic() { 8702 void test_parseGetter_nonStatic() {
8699 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8703 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
9029 TypeArgumentList typeArguments = null; 9033 TypeArgumentList typeArguments = null;
9030 ListLiteral literal = 9034 ListLiteral literal =
9031 ParserTestCase.parse("parseListLiteral", <Object>[token, typeArguments], "[]"); 9035 ParserTestCase.parse("parseListLiteral", <Object>[token, typeArguments], "[]");
9032 expect(literal.constKeyword, token); 9036 expect(literal.constKeyword, token);
9033 expect(literal.typeArguments, typeArguments); 9037 expect(literal.typeArguments, typeArguments);
9034 expect(literal.leftBracket, isNotNull); 9038 expect(literal.leftBracket, isNotNull);
9035 expect(literal.elements, hasLength(0)); 9039 expect(literal.elements, hasLength(0));
9036 expect(literal.rightBracket, isNotNull); 9040 expect(literal.rightBracket, isNotNull);
9037 } 9041 }
9038 9042
9043 void test_parseListLiteral_empty_oneToken_withComment() {
9044 Token constToken = null;
9045 TypeArgumentList typeArguments = null;
9046 ListLiteral literal = ParserTestCase.parse(
9047 "parseListLiteral",
9048 <Object>[constToken, typeArguments],
9049 "/* 0 */ []");
9050 expect(literal.constKeyword, constToken);
9051 expect(literal.typeArguments, typeArguments);
9052 Token leftBracket = literal.leftBracket;
9053 expect(leftBracket, isNotNull);
9054 expect(leftBracket.precedingComments, isNotNull);
9055 expect(literal.elements, hasLength(0));
9056 expect(literal.rightBracket, isNotNull);
9057 }
9058
9039 void test_parseListLiteral_empty_twoTokens() { 9059 void test_parseListLiteral_empty_twoTokens() {
9040 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); 9060 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST);
9041 TypeArgumentList typeArguments = null; 9061 TypeArgumentList typeArguments = null;
9042 ListLiteral literal = ParserTestCase.parse( 9062 ListLiteral literal = ParserTestCase.parse(
9043 "parseListLiteral", 9063 "parseListLiteral",
9044 <Object>[token, typeArguments], 9064 <Object>[token, typeArguments],
9045 "[ ]"); 9065 "[ ]");
9046 expect(literal.constKeyword, token); 9066 expect(literal.constKeyword, token);
9047 expect(literal.typeArguments, typeArguments); 9067 expect(literal.typeArguments, typeArguments);
9048 expect(literal.leftBracket, isNotNull); 9068 expect(literal.leftBracket, isNotNull);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
9123 9143
9124 void test_parseLogicalOrExpression() { 9144 void test_parseLogicalOrExpression() {
9125 BinaryExpression expression = 9145 BinaryExpression expression =
9126 ParserTestCase.parse4("parseLogicalOrExpression", "x || y"); 9146 ParserTestCase.parse4("parseLogicalOrExpression", "x || y");
9127 expect(expression.leftOperand, isNotNull); 9147 expect(expression.leftOperand, isNotNull);
9128 expect(expression.operator, isNotNull); 9148 expect(expression.operator, isNotNull);
9129 expect(expression.operator.type, TokenType.BAR_BAR); 9149 expect(expression.operator.type, TokenType.BAR_BAR);
9130 expect(expression.rightOperand, isNotNull); 9150 expect(expression.rightOperand, isNotNull);
9131 } 9151 }
9132 9152
9153 void test_parseMapLiteralEntry_complex() {
9154 MapLiteralEntry entry =
9155 ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2 : y");
9156 expect(entry.key, isNotNull);
9157 expect(entry.separator, isNotNull);
9158 expect(entry.value, isNotNull);
9159 }
9160
9161 void test_parseMapLiteralEntry_int() {
9162 MapLiteralEntry entry =
9163 ParserTestCase.parse4("parseMapLiteralEntry", "0 : y");
9164 expect(entry.key, isNotNull);
9165 expect(entry.separator, isNotNull);
9166 expect(entry.value, isNotNull);
9167 }
9168
9169 void test_parseMapLiteralEntry_string() {
9170 MapLiteralEntry entry =
9171 ParserTestCase.parse4("parseMapLiteralEntry", "'x' : y");
9172 expect(entry.key, isNotNull);
9173 expect(entry.separator, isNotNull);
9174 expect(entry.value, isNotNull);
9175 }
9176
9133 void test_parseMapLiteral_empty() { 9177 void test_parseMapLiteral_empty() {
9134 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); 9178 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST);
9135 TypeArgumentList typeArguments = AstFactory.typeArgumentList( 9179 TypeArgumentList typeArguments = AstFactory.typeArgumentList(
9136 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]); 9180 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]);
9137 MapLiteral literal = 9181 MapLiteral literal =
9138 ParserTestCase.parse("parseMapLiteral", <Object>[token, typeArguments], "{}"); 9182 ParserTestCase.parse("parseMapLiteral", <Object>[token, typeArguments], "{}");
9139 expect(literal.constKeyword, token); 9183 expect(literal.constKeyword, token);
9140 expect(literal.typeArguments, typeArguments); 9184 expect(literal.typeArguments, typeArguments);
9141 expect(literal.leftBracket, isNotNull); 9185 expect(literal.leftBracket, isNotNull);
9142 expect(literal.entries, hasLength(0)); 9186 expect(literal.entries, hasLength(0));
(...skipping 11 matching lines...) Expand all
9154 } 9198 }
9155 9199
9156 void test_parseMapLiteral_single() { 9200 void test_parseMapLiteral_single() {
9157 MapLiteral literal = 9201 MapLiteral literal =
9158 ParserTestCase.parse("parseMapLiteral", <Object>[null, null], "{'x' : y} "); 9202 ParserTestCase.parse("parseMapLiteral", <Object>[null, null], "{'x' : y} ");
9159 expect(literal.leftBracket, isNotNull); 9203 expect(literal.leftBracket, isNotNull);
9160 expect(literal.entries, hasLength(1)); 9204 expect(literal.entries, hasLength(1));
9161 expect(literal.rightBracket, isNotNull); 9205 expect(literal.rightBracket, isNotNull);
9162 } 9206 }
9163 9207
9164 void test_parseMapLiteralEntry_complex() {
9165 MapLiteralEntry entry =
9166 ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2 : y");
9167 expect(entry.key, isNotNull);
9168 expect(entry.separator, isNotNull);
9169 expect(entry.value, isNotNull);
9170 }
9171
9172 void test_parseMapLiteralEntry_int() {
9173 MapLiteralEntry entry =
9174 ParserTestCase.parse4("parseMapLiteralEntry", "0 : y");
9175 expect(entry.key, isNotNull);
9176 expect(entry.separator, isNotNull);
9177 expect(entry.value, isNotNull);
9178 }
9179
9180 void test_parseMapLiteralEntry_string() {
9181 MapLiteralEntry entry =
9182 ParserTestCase.parse4("parseMapLiteralEntry", "'x' : y");
9183 expect(entry.key, isNotNull);
9184 expect(entry.separator, isNotNull);
9185 expect(entry.value, isNotNull);
9186 }
9187
9188 void test_parseModifiers_abstract() { 9208 void test_parseModifiers_abstract() {
9189 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "abstract A"); 9209 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "abstract A");
9190 expect(modifiers.abstractKeyword, isNotNull); 9210 expect(modifiers.abstractKeyword, isNotNull);
9191 } 9211 }
9192 9212
9193 void test_parseModifiers_const() { 9213 void test_parseModifiers_const() {
9194 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "const A"); 9214 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "const A");
9195 expect(modifiers.constKeyword, isNotNull); 9215 expect(modifiers.constKeyword, isNotNull);
9196 } 9216 }
9197 9217
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
9764 expect(expression.keyword, isNotNull); 9784 expect(expression.keyword, isNotNull);
9765 } 9785 }
9766 9786
9767 void test_parsePrimaryExpression_true() { 9787 void test_parsePrimaryExpression_true() {
9768 BooleanLiteral literal = 9788 BooleanLiteral literal =
9769 ParserTestCase.parse4("parsePrimaryExpression", "true"); 9789 ParserTestCase.parse4("parsePrimaryExpression", "true");
9770 expect(literal.literal, isNotNull); 9790 expect(literal.literal, isNotNull);
9771 expect(literal.value, isTrue); 9791 expect(literal.value, isTrue);
9772 } 9792 }
9773 9793
9774 void test_Parser() {
9775 expect(new Parser(null, null), isNotNull);
9776 }
9777
9778 void test_parseRedirectingConstructorInvocation_named() { 9794 void test_parseRedirectingConstructorInvocation_named() {
9779 RedirectingConstructorInvocation invocation = 9795 RedirectingConstructorInvocation invocation =
9780 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this.a() "); 9796 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this.a() ");
9781 expect(invocation.argumentList, isNotNull); 9797 expect(invocation.argumentList, isNotNull);
9782 expect(invocation.constructorName, isNotNull); 9798 expect(invocation.constructorName, isNotNull);
9783 expect(invocation.keyword, isNotNull); 9799 expect(invocation.keyword, isNotNull);
9784 expect(invocation.period, isNotNull); 9800 expect(invocation.period, isNotNull);
9785 } 9801 }
9786 9802
9787 void test_parseRedirectingConstructorInvocation_unnamed() { 9803 void test_parseRedirectingConstructorInvocation_unnamed() {
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
10354 expect(argumentList.leftBracket, isNotNull); 10370 expect(argumentList.leftBracket, isNotNull);
10355 expect(argumentList.arguments, hasLength(1)); 10371 expect(argumentList.arguments, hasLength(1));
10356 TypeName argument = argumentList.arguments[0]; 10372 TypeName argument = argumentList.arguments[0];
10357 expect(argument, isNotNull); 10373 expect(argument, isNotNull);
10358 TypeArgumentList innerList = argument.typeArguments; 10374 TypeArgumentList innerList = argument.typeArguments;
10359 expect(innerList, isNotNull); 10375 expect(innerList, isNotNull);
10360 expect(innerList.arguments, hasLength(1)); 10376 expect(innerList.arguments, hasLength(1));
10361 expect(argumentList.rightBracket, isNotNull); 10377 expect(argumentList.rightBracket, isNotNull);
10362 } 10378 }
10363 10379
10380 void test_parseTypeArgumentList_nested_withComment_double() {
10381 TypeArgumentList argumentList =
10382 ParserTestCase.parse4("parseTypeArgumentList", "<A<B /* 0 */ >>");
10383 expect(argumentList.leftBracket, isNotNull);
10384 expect(argumentList.rightBracket, isNotNull);
10385 expect(argumentList.arguments, hasLength(1));
10386
10387 TypeName argument = argumentList.arguments[0];
10388 expect(argument, isNotNull);
10389
10390 TypeArgumentList innerList = argument.typeArguments;
10391 expect(innerList, isNotNull);
10392 expect(innerList.leftBracket, isNotNull);
10393 expect(innerList.arguments, hasLength(1));
10394 expect(innerList.rightBracket, isNotNull);
10395 expect(innerList.rightBracket.precedingComments, isNotNull);
10396 }
10397
10398 void test_parseTypeArgumentList_nested_withComment_tripple() {
10399 TypeArgumentList argumentList =
10400 ParserTestCase.parse4("parseTypeArgumentList", "<A<B<C /* 0 */ >>>");
10401 expect(argumentList.leftBracket, isNotNull);
10402 expect(argumentList.rightBracket, isNotNull);
10403 expect(argumentList.arguments, hasLength(1));
10404
10405 TypeName argument = argumentList.arguments[0];
10406 expect(argument, isNotNull);
10407
10408 TypeArgumentList innerList = argument.typeArguments;
10409 expect(innerList, isNotNull);
10410 expect(innerList.leftBracket, isNotNull);
10411 expect(innerList.arguments, hasLength(1));
10412 expect(innerList.rightBracket, isNotNull);
10413
10414 TypeName innerArgument = innerList.arguments[0];
10415 expect(innerArgument, isNotNull);
10416
10417 TypeArgumentList innerInnerList = innerArgument.typeArguments;
10418 expect(innerInnerList, isNotNull);
10419 expect(innerInnerList.leftBracket, isNotNull);
10420 expect(innerInnerList.arguments, hasLength(1));
10421 expect(innerInnerList.rightBracket, isNotNull);
10422 expect(innerInnerList.rightBracket.precedingComments, isNotNull);
10423 }
10424
10364 void test_parseTypeArgumentList_single() { 10425 void test_parseTypeArgumentList_single() {
10365 TypeArgumentList argumentList = 10426 TypeArgumentList argumentList =
10366 ParserTestCase.parse4("parseTypeArgumentList", "<int>"); 10427 ParserTestCase.parse4("parseTypeArgumentList", "<int>");
10367 expect(argumentList.leftBracket, isNotNull); 10428 expect(argumentList.leftBracket, isNotNull);
10368 expect(argumentList.arguments, hasLength(1)); 10429 expect(argumentList.arguments, hasLength(1));
10369 expect(argumentList.rightBracket, isNotNull); 10430 expect(argumentList.rightBracket, isNotNull);
10370 } 10431 }
10371 10432
10372 void test_parseTypeName_parameterized() { 10433 void test_parseTypeName_parameterized() {
10373 TypeName typeName = ParserTestCase.parse4("parseTypeName", "List<int>"); 10434 TypeName typeName = ParserTestCase.parse4("parseTypeName", "List<int>");
10374 expect(typeName.name, isNotNull); 10435 expect(typeName.name, isNotNull);
10375 expect(typeName.typeArguments, isNotNull); 10436 expect(typeName.typeArguments, isNotNull);
10376 } 10437 }
10377 10438
10378 void test_parseTypeName_simple() { 10439 void test_parseTypeName_simple() {
10379 TypeName typeName = ParserTestCase.parse4("parseTypeName", "int"); 10440 TypeName typeName = ParserTestCase.parse4("parseTypeName", "int");
10380 expect(typeName.name, isNotNull); 10441 expect(typeName.name, isNotNull);
10381 expect(typeName.typeArguments, isNull); 10442 expect(typeName.typeArguments, isNull);
10382 } 10443 }
10383 10444
10384 void test_parseTypeParameter_bounded() {
10385 TypeParameter parameter =
10386 ParserTestCase.parse4("parseTypeParameter", "A extends B");
10387 expect(parameter.bound, isNotNull);
10388 expect(parameter.keyword, isNotNull);
10389 expect(parameter.name, isNotNull);
10390 }
10391
10392 void test_parseTypeParameter_simple() {
10393 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A");
10394 expect(parameter.bound, isNull);
10395 expect(parameter.keyword, isNull);
10396 expect(parameter.name, isNotNull);
10397 }
10398
10399 void test_parseTypeParameterList_multiple() { 10445 void test_parseTypeParameterList_multiple() {
10400 TypeParameterList parameterList = 10446 TypeParameterList parameterList =
10401 ParserTestCase.parse4("parseTypeParameterList", "<A, B extends C, D>"); 10447 ParserTestCase.parse4("parseTypeParameterList", "<A, B extends C, D>");
10402 expect(parameterList.leftBracket, isNotNull); 10448 expect(parameterList.leftBracket, isNotNull);
10403 expect(parameterList.rightBracket, isNotNull); 10449 expect(parameterList.rightBracket, isNotNull);
10404 expect(parameterList.typeParameters, hasLength(3)); 10450 expect(parameterList.typeParameters, hasLength(3));
10405 } 10451 }
10406 10452
10407 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { 10453 void test_parseTypeParameterList_parameterizedWithTrailingEquals() {
10408 TypeParameterList parameterList = 10454 TypeParameterList parameterList =
(...skipping 12 matching lines...) Expand all
10421 } 10467 }
10422 10468
10423 void test_parseTypeParameterList_withTrailingEquals() { 10469 void test_parseTypeParameterList_withTrailingEquals() {
10424 TypeParameterList parameterList = 10470 TypeParameterList parameterList =
10425 ParserTestCase.parse4("parseTypeParameterList", "<A>="); 10471 ParserTestCase.parse4("parseTypeParameterList", "<A>=");
10426 expect(parameterList.leftBracket, isNotNull); 10472 expect(parameterList.leftBracket, isNotNull);
10427 expect(parameterList.rightBracket, isNotNull); 10473 expect(parameterList.rightBracket, isNotNull);
10428 expect(parameterList.typeParameters, hasLength(1)); 10474 expect(parameterList.typeParameters, hasLength(1));
10429 } 10475 }
10430 10476
10477 void test_parseTypeParameter_bounded() {
10478 TypeParameter parameter =
10479 ParserTestCase.parse4("parseTypeParameter", "A extends B");
10480 expect(parameter.bound, isNotNull);
10481 expect(parameter.keyword, isNotNull);
10482 expect(parameter.name, isNotNull);
10483 }
10484
10485 void test_parseTypeParameter_simple() {
10486 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A");
10487 expect(parameter.bound, isNull);
10488 expect(parameter.keyword, isNull);
10489 expect(parameter.name, isNotNull);
10490 }
10491
10431 void test_parseUnaryExpression_decrement_normal() { 10492 void test_parseUnaryExpression_decrement_normal() {
10432 PrefixExpression expression = 10493 PrefixExpression expression =
10433 ParserTestCase.parse4("parseUnaryExpression", "--x"); 10494 ParserTestCase.parse4("parseUnaryExpression", "--x");
10434 expect(expression.operator, isNotNull); 10495 expect(expression.operator, isNotNull);
10435 expect(expression.operator.type, TokenType.MINUS_MINUS); 10496 expect(expression.operator.type, TokenType.MINUS_MINUS);
10436 expect(expression.operand, isNotNull); 10497 expect(expression.operand, isNotNull);
10437 } 10498 }
10438 10499
10439 void test_parseUnaryExpression_decrement_super() { 10500 void test_parseUnaryExpression_decrement_super() {
10440 PrefixExpression expression = 10501 PrefixExpression expression =
(...skipping 13 matching lines...) Expand all
10454 PrefixExpression expression = 10515 PrefixExpression expression =
10455 ParserTestCase.parse4("parseUnaryExpression", "--super.x"); 10516 ParserTestCase.parse4("parseUnaryExpression", "--super.x");
10456 expect(expression.operator, isNotNull); 10517 expect(expression.operator, isNotNull);
10457 expect(expression.operator.type, TokenType.MINUS_MINUS); 10518 expect(expression.operator.type, TokenType.MINUS_MINUS);
10458 expect(expression.operand, isNotNull); 10519 expect(expression.operand, isNotNull);
10459 PropertyAccess operand = expression.operand as PropertyAccess; 10520 PropertyAccess operand = expression.operand as PropertyAccess;
10460 expect(operand.target is SuperExpression, isTrue); 10521 expect(operand.target is SuperExpression, isTrue);
10461 expect(operand.propertyName.name, "x"); 10522 expect(operand.propertyName.name, "x");
10462 } 10523 }
10463 10524
10525 void test_parseUnaryExpression_decrement_super_withComment() {
10526 PrefixExpression expression =
10527 ParserTestCase.parse4("parseUnaryExpression", "/* 0 */ --super");
10528 expect(expression.operator, isNotNull);
10529 expect(expression.operator.type, TokenType.MINUS);
10530 expect(expression.operator.precedingComments, isNotNull);
10531 Expression innerExpression = expression.operand;
10532 expect(innerExpression, isNotNull);
10533 expect(innerExpression is PrefixExpression, isTrue);
10534 PrefixExpression operand = innerExpression as PrefixExpression;
10535 expect(operand.operator, isNotNull);
10536 expect(operand.operator.type, TokenType.MINUS);
10537 expect(operand.operand, isNotNull);
10538 }
10539
10464 void test_parseUnaryExpression_increment_normal() { 10540 void test_parseUnaryExpression_increment_normal() {
10465 PrefixExpression expression = 10541 PrefixExpression expression =
10466 ParserTestCase.parse4("parseUnaryExpression", "++x"); 10542 ParserTestCase.parse4("parseUnaryExpression", "++x");
10467 expect(expression.operator, isNotNull); 10543 expect(expression.operator, isNotNull);
10468 expect(expression.operator.type, TokenType.PLUS_PLUS); 10544 expect(expression.operator.type, TokenType.PLUS_PLUS);
10469 expect(expression.operand, isNotNull); 10545 expect(expression.operand, isNotNull);
10470 } 10546 }
10471 10547
10472 void test_parseUnaryExpression_increment_super_index() { 10548 void test_parseUnaryExpression_increment_super_index() {
10473 PrefixExpression expression = 10549 PrefixExpression expression =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
10532 } 10608 }
10533 10609
10534 void test_parseUnaryExpression_tilda_super() { 10610 void test_parseUnaryExpression_tilda_super() {
10535 PrefixExpression expression = 10611 PrefixExpression expression =
10536 ParserTestCase.parse4("parseUnaryExpression", "~super"); 10612 ParserTestCase.parse4("parseUnaryExpression", "~super");
10537 expect(expression.operator, isNotNull); 10613 expect(expression.operator, isNotNull);
10538 expect(expression.operator.type, TokenType.TILDE); 10614 expect(expression.operator.type, TokenType.TILDE);
10539 expect(expression.operand, isNotNull); 10615 expect(expression.operand, isNotNull);
10540 } 10616 }
10541 10617
10542 void test_parseVariableDeclaration_equals() {
10543 VariableDeclaration declaration =
10544 ParserTestCase.parse4("parseVariableDeclaration", "a = b");
10545 expect(declaration.name, isNotNull);
10546 expect(declaration.equals, isNotNull);
10547 expect(declaration.initializer, isNotNull);
10548 }
10549
10550 void test_parseVariableDeclaration_noEquals() {
10551 VariableDeclaration declaration =
10552 ParserTestCase.parse4("parseVariableDeclaration", "a");
10553 expect(declaration.name, isNotNull);
10554 expect(declaration.equals, isNull);
10555 expect(declaration.initializer, isNull);
10556 }
10557
10558 void test_parseVariableDeclarationListAfterMetadata_const_noType() { 10618 void test_parseVariableDeclarationListAfterMetadata_const_noType() {
10559 VariableDeclarationList declarationList = ParserTestCase.parse( 10619 VariableDeclarationList declarationList = ParserTestCase.parse(
10560 "parseVariableDeclarationListAfterMetadata", 10620 "parseVariableDeclarationListAfterMetadata",
10561 <Object>[emptyCommentAndMetadata()], 10621 <Object>[emptyCommentAndMetadata()],
10562 "const a"); 10622 "const a");
10563 expect(declarationList.keyword, isNotNull); 10623 expect(declarationList.keyword, isNotNull);
10564 expect(declarationList.type, isNull); 10624 expect(declarationList.type, isNull);
10565 expect(declarationList.variables, hasLength(1)); 10625 expect(declarationList.variables, hasLength(1));
10566 } 10626 }
10567 10627
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
10672 VariableDeclarationStatement statement = ParserTestCase.parse( 10732 VariableDeclarationStatement statement = ParserTestCase.parse(
10673 "parseVariableDeclarationStatementAfterMetadata", 10733 "parseVariableDeclarationStatementAfterMetadata",
10674 <Object>[emptyCommentAndMetadata()], 10734 <Object>[emptyCommentAndMetadata()],
10675 "var x;"); 10735 "var x;");
10676 expect(statement.semicolon, isNotNull); 10736 expect(statement.semicolon, isNotNull);
10677 VariableDeclarationList variableList = statement.variables; 10737 VariableDeclarationList variableList = statement.variables;
10678 expect(variableList, isNotNull); 10738 expect(variableList, isNotNull);
10679 expect(variableList.variables, hasLength(1)); 10739 expect(variableList.variables, hasLength(1));
10680 } 10740 }
10681 10741
10742 void test_parseVariableDeclaration_equals() {
10743 VariableDeclaration declaration =
10744 ParserTestCase.parse4("parseVariableDeclaration", "a = b");
10745 expect(declaration.name, isNotNull);
10746 expect(declaration.equals, isNotNull);
10747 expect(declaration.initializer, isNotNull);
10748 }
10749
10750 void test_parseVariableDeclaration_noEquals() {
10751 VariableDeclaration declaration =
10752 ParserTestCase.parse4("parseVariableDeclaration", "a");
10753 expect(declaration.name, isNotNull);
10754 expect(declaration.equals, isNull);
10755 expect(declaration.initializer, isNull);
10756 }
10757
10682 void test_parseWhileStatement() { 10758 void test_parseWhileStatement() {
10683 WhileStatement statement = 10759 WhileStatement statement =
10684 ParserTestCase.parse4("parseWhileStatement", "while (x) {}"); 10760 ParserTestCase.parse4("parseWhileStatement", "while (x) {}");
10685 expect(statement.keyword, isNotNull); 10761 expect(statement.keyword, isNotNull);
10686 expect(statement.leftParenthesis, isNotNull); 10762 expect(statement.leftParenthesis, isNotNull);
10687 expect(statement.condition, isNotNull); 10763 expect(statement.condition, isNotNull);
10688 expect(statement.rightParenthesis, isNotNull); 10764 expect(statement.rightParenthesis, isNotNull);
10689 expect(statement.body, isNotNull); 10765 expect(statement.body, isNotNull);
10690 } 10766 }
10691 10767
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
11001 // Parse the source. 11077 // Parse the source.
11002 // 11078 //
11003 Parser parser = new Parser(null, listener); 11079 Parser parser = new Parser(null, listener);
11004 return invokeParserMethodImpl( 11080 return invokeParserMethodImpl(
11005 parser, 11081 parser,
11006 methodName, 11082 methodName,
11007 <Object>[tokenStream], 11083 <Object>[tokenStream],
11008 tokenStream) as Token; 11084 tokenStream) as Token;
11009 } 11085 }
11010 } 11086 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698