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

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

Issue 970913002: API clean-up (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Sort ast.dart Created 5 years, 9 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
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
128 void test_additiveExpression_noSpaces() { 136 void test_additiveExpression_noSpaces() {
129 BinaryExpression expression = ParserTestCase.parseExpression("i+1"); 137 BinaryExpression expression = ParserTestCase.parseExpression("i+1");
130 EngineTestCase.assertInstanceOf( 138 EngineTestCase.assertInstanceOf(
131 (obj) => obj is SimpleIdentifier, 139 (obj) => obj is SimpleIdentifier,
132 SimpleIdentifier, 140 SimpleIdentifier,
133 expression.leftOperand); 141 expression.leftOperand);
134 EngineTestCase.assertInstanceOf( 142 EngineTestCase.assertInstanceOf(
135 (obj) => obj is IntegerLiteral, 143 (obj) => obj is IntegerLiteral,
136 IntegerLiteral, 144 IntegerLiteral,
137 expression.rightOperand); 145 expression.rightOperand);
138 } 146 }
139 147
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
943 void test_constructorWithReturnType() { 937 void test_constructorWithReturnType() {
944 ParserTestCase.parse3( 938 ParserTestCase.parse3(
945 "parseClassMember", 939 "parseClassMember",
946 <Object>["C"], 940 <Object>["C"],
947 "C C() {}", 941 "C C() {}",
948 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); 942 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
949 } 943 }
950 944
951 void test_constructorWithReturnType_var() { 945 void test_constructorWithReturnType_var() {
952 ParserTestCase.parse3( 946 ParserTestCase.parse3(
953 "parseClassMember", 947 "parseClassMember",
954 <Object>["C"], 948 <Object>["C"],
955 "var C() {}", 949 "var C() {}",
956 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]); 950 [ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE]);
957 } 951 }
958 952
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
1046 void test_duplicatedModifier_const() { 1039 void test_duplicatedModifier_const() {
1047 ParserTestCase.parse3( 1040 ParserTestCase.parse3(
1048 "parseClassMember", 1041 "parseClassMember",
1049 <Object>["C"], 1042 <Object>["C"],
1050 "const const m;", 1043 "const const m;",
1051 [ParserErrorCode.DUPLICATED_MODIFIER]); 1044 [ParserErrorCode.DUPLICATED_MODIFIER]);
1052 } 1045 }
1053 1046
1054 void test_duplicatedModifier_external() { 1047 void test_duplicatedModifier_external() {
1055 ParserTestCase.parse3( 1048 ParserTestCase.parse3(
(...skipping 28 matching lines...) Expand all
1084 } 1077 }
1085 1078
1086 void test_duplicatedModifier_var() { 1079 void test_duplicatedModifier_var() {
1087 ParserTestCase.parse3( 1080 ParserTestCase.parse3(
1088 "parseClassMember", 1081 "parseClassMember",
1089 <Object>["C"], 1082 <Object>["C"],
1090 "var var m;", 1083 "var var m;",
1091 [ParserErrorCode.DUPLICATED_MODIFIER]); 1084 [ParserErrorCode.DUPLICATED_MODIFIER]);
1092 } 1085 }
1093 1086
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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 1753
1754 void test_missingAssignableSelector_selector() { 1754 void test_missingAssignableSelector_selector() {
1755 ParserTestCase.parseExpression("x(y)(z).a++"); 1755 ParserTestCase.parseExpression("x(y)(z).a++");
1756 } 1756 }
1757 1757
1758 void test_missingAssignableSelector_superPrimaryExpression() { 1758 void test_missingAssignableSelector_superPrimaryExpression() {
1759 SuperExpression expression = ParserTestCase.parse4( 1759 SuperExpression expression = ParserTestCase.parse4(
1760 "parsePrimaryExpression", 1760 "parsePrimaryExpression",
1761 "super", 1761 "super",
1762 [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); 1762 [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1763 expect(expression.keyword, isNotNull); 1763 expect(expression.superKeyword, isNotNull);
1764 } 1764 }
1765 1765
1766 void test_missingAssignableSelector_superPropertyAccessAssigned() { 1766 void test_missingAssignableSelector_superPropertyAccessAssigned() {
1767 ParserTestCase.parseExpression("super.x = x;"); 1767 ParserTestCase.parseExpression("super.x = x;");
1768 } 1768 }
1769 1769
1770 void test_missingCatchOrFinally() { 1770 void test_missingCatchOrFinally() {
1771 TryStatement statement = ParserTestCase.parse4( 1771 TryStatement statement = ParserTestCase.parse4(
1772 "parseTryStatement", 1772 "parseTryStatement",
1773 "try {}", 1773 "try {}",
(...skipping 567 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
2351 void test_topLevelOperator_withType() { 2359 void test_topLevelOperator_withType() {
2352 ParserTestCase.parse3( 2360 ParserTestCase.parse3(
2353 "parseCompilationUnitMember", 2361 "parseCompilationUnitMember",
2354 <Object>[emptyCommentAndMetadata()], 2362 <Object>[emptyCommentAndMetadata()],
2355 "bool operator +(bool x, bool y) => x | y;", 2363 "bool operator +(bool x, bool y) => x | y;",
2356 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 2364 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
2357 } 2365 }
2358 2366
2359 void test_topLevelOperator_withVoid() { 2367 void test_topLevelOperator_withVoid() {
2360 ParserTestCase.parse3( 2368 ParserTestCase.parse3(
2361 "parseCompilationUnitMember", 2369 "parseCompilationUnitMember",
2362 <Object>[emptyCommentAndMetadata()], 2370 <Object>[emptyCommentAndMetadata()],
2363 "void operator +(bool x, bool y) => x | y;", 2371 "void operator +(bool x, bool y) => x | y;",
2364 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 2372 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
2365 } 2373 }
2366 2374
2367 void test_topLevelOperator_withoutType() { 2375 void test_typedefInClass_withoutReturnType() {
2368 ParserTestCase.parse3( 2376 ParserTestCase.parseCompilationUnit(
2369 "parseCompilationUnitMember", 2377 "class C { typedef F(x); }",
2370 <Object>[emptyCommentAndMetadata()], 2378 [ParserErrorCode.TYPEDEF_IN_CLASS]);
2371 "operator +(bool x, bool y) => x | y;",
2372 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
2373 } 2379 }
2374 2380
2375 void test_typedefInClass_withReturnType() { 2381 void test_typedefInClass_withReturnType() {
2376 ParserTestCase.parseCompilationUnit( 2382 ParserTestCase.parseCompilationUnit(
2377 "class C { typedef int F(int x); }", 2383 "class C { typedef int F(int x); }",
2378 [ParserErrorCode.TYPEDEF_IN_CLASS]); 2384 [ParserErrorCode.TYPEDEF_IN_CLASS]);
2379 } 2385 }
2380 2386
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
2506 void test_voidVariable_parseCompilationUnitMember_initializer() { 2518 void test_voidVariable_parseCompilationUnitMember_initializer() {
2507 ParserTestCase.parse3( 2519 ParserTestCase.parse3(
2508 "parseCompilationUnitMember", 2520 "parseCompilationUnitMember",
2509 <Object>[emptyCommentAndMetadata()], 2521 <Object>[emptyCommentAndMetadata()],
2510 "void a = 0;", 2522 "void a = 0;",
2511 [ParserErrorCode.VOID_VARIABLE]); 2523 [ParserErrorCode.VOID_VARIABLE]);
2512 } 2524 }
2513 2525
2514 void test_voidVariable_parseCompilationUnitMember_noInitializer() { 2526 void test_voidVariable_parseCompilationUnitMember_noInitializer() {
2515 ParserTestCase.parse3( 2527 ParserTestCase.parse3(
2516 "parseCompilationUnitMember", 2528 "parseCompilationUnitMember",
2517 <Object>[emptyCommentAndMetadata()], 2529 <Object>[emptyCommentAndMetadata()],
2518 "void a;", 2530 "void a;",
2519 [ParserErrorCode.VOID_VARIABLE]); 2531 [ParserErrorCode.VOID_VARIABLE]);
2520 } 2532 }
2521 2533
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
2736 void test_insert_period_betweenIdentifiers1() { 2730 void test_insert_period_betweenIdentifiers1() {
2737 // "f() => a b;" 2731 // "f() => a b;"
2738 // "f() => a. b;" 2732 // "f() => a. b;"
2739 _assertParse("f() => a", "", ".", " b;"); 2733 _assertParse("f() => a", "", ".", " b;");
2740 } 2734 }
2741 2735
2742 void test_insert_period_betweenIdentifiers2() { 2736 void test_insert_period_betweenIdentifiers2() {
2743 // "f() => a b;" 2737 // "f() => a b;"
2744 // "f() => a .b;" 2738 // "f() => a .b;"
2745 _assertParse("f() => a ", "", ".", "b;"); 2739 _assertParse("f() => a ", "", ".", "b;");
2746 } 2740 }
2747 2741
2748 void test_insert_period_betweenIdentifiers3() { 2742 void test_insert_period_betweenIdentifiers3() {
2749 // "f() => a b;" 2743 // "f() => a b;"
2750 // "f() => a . b;" 2744 // "f() => a . b;"
2751 _assertParse("f() => a ", "", ".", " b;"); 2745 _assertParse("f() => a ", "", ".", " b;");
2752 } 2746 }
2753 2747
2754 void test_insert_period_insideExistingIdentifier() { 2748 void test_insert_period_insideExistingIdentifier() {
2755 // "f() => ab;" 2749 // "f() => ab;"
2756 // "f() => a.b;" 2750 // "f() => a.b;"
2757 _assertParse("f() => a", "", ".", "b;"); 2751 _assertParse("f() => a", "", ".", "b;");
2758 } 2752 }
2759 2753
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
3399 void test_assignmentExpression_missing_compound1() { 3379 void test_assignmentExpression_missing_compound1() {
3400 AssignmentExpression expression = ParserTestCase.parseExpression( 3380 AssignmentExpression expression = ParserTestCase.parseExpression(
3401 "= y = 0", 3381 "= y = 0",
3402 [ParserErrorCode.MISSING_IDENTIFIER]); 3382 [ParserErrorCode.MISSING_IDENTIFIER]);
3403 Expression syntheticExpression = expression.leftHandSide; 3383 Expression syntheticExpression = expression.leftHandSide;
3404 EngineTestCase.assertInstanceOf( 3384 EngineTestCase.assertInstanceOf(
3405 (obj) => obj is SimpleIdentifier, 3385 (obj) => obj is SimpleIdentifier,
3406 SimpleIdentifier, 3386 SimpleIdentifier,
3407 syntheticExpression); 3387 syntheticExpression);
3408 expect(syntheticExpression.isSynthetic, isTrue); 3388 expect(syntheticExpression.isSynthetic, isTrue);
(...skipping 18 matching lines...) Expand all
3427 [ParserErrorCode.MISSING_IDENTIFIER]); 3407 [ParserErrorCode.MISSING_IDENTIFIER]);
3428 Expression syntheticExpression = 3408 Expression syntheticExpression =
3429 (expression.rightHandSide as AssignmentExpression).rightHandSide; 3409 (expression.rightHandSide as AssignmentExpression).rightHandSide;
3430 EngineTestCase.assertInstanceOf( 3410 EngineTestCase.assertInstanceOf(
3431 (obj) => obj is SimpleIdentifier, 3411 (obj) => obj is SimpleIdentifier,
3432 SimpleIdentifier, 3412 SimpleIdentifier,
3433 syntheticExpression); 3413 syntheticExpression);
3434 expect(syntheticExpression.isSynthetic, isTrue); 3414 expect(syntheticExpression.isSynthetic, isTrue);
3435 } 3415 }
3436 3416
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
3952 void test_incomplete_conditionalExpression() { 3868 void test_incomplete_conditionalExpression() {
3953 ParserTestCase.parseExpression( 3869 ParserTestCase.parseExpression(
3954 "x ? 0", 3870 "x ? 0",
3955 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); 3871 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]);
3956 } 3872 }
3957 3873
3958 void test_incomplete_constructorInitializers_empty() { 3874 void test_incomplete_constructorInitializers_empty() {
3959 ParserTestCase.parse3( 3875 ParserTestCase.parse3(
3960 "parseClassMember", 3876 "parseClassMember",
3961 ["C"], 3877 ["C"],
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4060 (obj) => obj is TopLevelVariableDeclaration, 3976 (obj) => obj is TopLevelVariableDeclaration,
4061 TopLevelVariableDeclaration, 3977 TopLevelVariableDeclaration,
4062 member); 3978 member);
4063 NodeList<VariableDeclaration> variables = 3979 NodeList<VariableDeclaration> variables =
4064 (member as TopLevelVariableDeclaration).variables.variables; 3980 (member as TopLevelVariableDeclaration).variables.variables;
4065 expect(variables, hasLength(1)); 3981 expect(variables, hasLength(1));
4066 SimpleIdentifier name = variables[0].name; 3982 SimpleIdentifier name = variables[0].name;
4067 expect(name.isSynthetic, isTrue); 3983 expect(name.isSynthetic, isTrue);
4068 } 3984 }
4069 3985
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
4231 void test_missingGet() { 4237 void test_missingGet() {
4232 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r''' 4238 CompilationUnit unit = ParserTestCase.parseCompilationUnit(r'''
4233 class C { 4239 class C {
4234 int length {} 4240 int length {}
4235 void foo() {} 4241 void foo() {}
4236 }''', [ParserErrorCode.MISSING_GET]); 4242 }''', [ParserErrorCode.MISSING_GET]);
4237 expect(unit, isNotNull); 4243 expect(unit, isNotNull);
4238 ClassDeclaration classDeclaration = 4244 ClassDeclaration classDeclaration =
4239 unit.declarations[0] as ClassDeclaration; 4245 unit.declarations[0] as ClassDeclaration;
4240 NodeList<ClassMember> members = classDeclaration.members; 4246 NodeList<ClassMember> members = classDeclaration.members;
(...skipping 15 matching lines...) Expand all
4256 "parseClassMember", 4262 "parseClassMember",
4257 <Object>["C"], 4263 <Object>["C"],
4258 "@override }", 4264 "@override }",
4259 [ParserErrorCode.EXPECTED_CLASS_MEMBER]); 4265 [ParserErrorCode.EXPECTED_CLASS_MEMBER]);
4260 expect(method.documentationComment, isNull); 4266 expect(method.documentationComment, isNull);
4261 NodeList<Annotation> metadata = method.metadata; 4267 NodeList<Annotation> metadata = method.metadata;
4262 expect(metadata, hasLength(1)); 4268 expect(metadata, hasLength(1));
4263 expect(metadata[0].name.name, "override"); 4269 expect(metadata[0].name.name, "override");
4264 } 4270 }
4265 4271
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
4980 void test_visitPrefixExpression() { 4992 void test_visitPrefixExpression() {
4981 PrefixExpression fromNode = 4993 PrefixExpression fromNode =
4982 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x")); 4994 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x"));
4983 MethodElement propagatedElement = 4995 MethodElement propagatedElement =
4984 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type ); 4996 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type );
4985 DartType propagatedType = ElementFactory.classElement2("C").type; 4997 DartType propagatedType = ElementFactory.classElement2("C").type;
4986 fromNode.propagatedElement = propagatedElement; 4998 fromNode.propagatedElement = propagatedElement;
4987 fromNode.propagatedType = propagatedType; 4999 fromNode.propagatedType = propagatedType;
4988 DartType staticType = ElementFactory.classElement2("C").type; 5000 DartType staticType = ElementFactory.classElement2("C").type;
4989 MethodElement staticElement = 5001 MethodElement staticElement =
4990 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type ); 5002 ElementFactory.methodElement("+", ElementFactory.classElement2("C").type );
4991 fromNode.staticElement = staticElement; 5003 fromNode.staticElement = staticElement;
4992 fromNode.staticType = staticType; 5004 fromNode.staticType = staticType;
4993 PrefixExpression toNode = 5005 PrefixExpression toNode =
4994 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x")); 5006 AstFactory.prefixExpression(TokenType.PLUS_PLUS, AstFactory.identifier3( "x"));
4995 ResolutionCopier.copyResolutionData(fromNode, toNode); 5007 ResolutionCopier.copyResolutionData(fromNode, toNode);
4996 expect(toNode.propagatedElement, same(propagatedElement)); 5008 expect(toNode.propagatedElement, same(propagatedElement));
4997 expect(toNode.propagatedType, same(propagatedType)); 5009 expect(toNode.propagatedType, same(propagatedType));
4998 expect(toNode.staticElement, same(staticElement)); 5010 expect(toNode.staticElement, same(staticElement));
4999 expect(toNode.staticType, same(staticType)); 5011 expect(toNode.staticType, same(staticType));
5000 } 5012 }
5001 5013
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
5231 void test_computeStringValue_emptyInterpolationPrefix() { 5227 void test_computeStringValue_emptyInterpolationPrefix() {
5232 expect(_computeStringValue("'''", true, false), ""); 5228 expect(_computeStringValue("'''", true, false), "");
5233 } 5229 }
5234 5230
5235 void test_computeStringValue_escape_b() { 5231 void test_computeStringValue_escape_b() {
5236 expect(_computeStringValue("'\\b'", true, true), "\b"); 5232 expect(_computeStringValue("'\\b'", true, true), "\b");
5237 } 5233 }
5238 5234
5239 void test_computeStringValue_escape_f() { 5235 void test_computeStringValue_escape_f() {
5240 expect(_computeStringValue("'\\f'", true, true), "\f"); 5236 expect(_computeStringValue("'\\f'", true, true), "\f");
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
5593 void test_parseAnnotation_n3_a() { 5589 void test_parseAnnotation_n3_a() {
5594 Annotation annotation = 5590 Annotation annotation =
5595 ParserTestCase.parse4("parseAnnotation", "@A.B.C(x,y)"); 5591 ParserTestCase.parse4("parseAnnotation", "@A.B.C(x,y)");
5596 expect(annotation.atSign, isNotNull); 5592 expect(annotation.atSign, isNotNull);
5597 expect(annotation.name, isNotNull); 5593 expect(annotation.name, isNotNull);
5598 expect(annotation.period, isNotNull); 5594 expect(annotation.period, isNotNull);
5599 expect(annotation.constructorName, isNotNull); 5595 expect(annotation.constructorName, isNotNull);
5600 expect(annotation.arguments, isNotNull); 5596 expect(annotation.arguments, isNotNull);
5601 } 5597 }
5602 5598
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
5603 void test_parseArgumentList_empty() { 5615 void test_parseArgumentList_empty() {
5604 ArgumentList argumentList = 5616 ArgumentList argumentList =
5605 ParserTestCase.parse4("parseArgumentList", "()"); 5617 ParserTestCase.parse4("parseArgumentList", "()");
5606 NodeList<Expression> arguments = argumentList.arguments; 5618 NodeList<Expression> arguments = argumentList.arguments;
5607 expect(arguments, hasLength(0)); 5619 expect(arguments, hasLength(0));
5608 } 5620 }
5609 5621
5610 void test_parseArgumentList_mixed() { 5622 void test_parseArgumentList_mixed() {
5611 ArgumentList argumentList = 5623 ArgumentList argumentList =
5612 ParserTestCase.parse4("parseArgumentList", "(w, x, y: y, z: z)"); 5624 ParserTestCase.parse4("parseArgumentList", "(w, x, y: y, z: z)");
5613 NodeList<Expression> arguments = argumentList.arguments; 5625 NodeList<Expression> arguments = argumentList.arguments;
5614 expect(arguments, hasLength(4)); 5626 expect(arguments, hasLength(4));
5615 } 5627 }
5616 5628
5617 void test_parseArgumentList_noNamed() { 5629 void test_parseArgumentList_noNamed() {
5618 ArgumentList argumentList = 5630 ArgumentList argumentList =
5619 ParserTestCase.parse4("parseArgumentList", "(x, y, z)"); 5631 ParserTestCase.parse4("parseArgumentList", "(x, y, z)");
5620 NodeList<Expression> arguments = argumentList.arguments; 5632 NodeList<Expression> arguments = argumentList.arguments;
5621 expect(arguments, hasLength(3)); 5633 expect(arguments, hasLength(3));
5622 } 5634 }
5623 5635
5624 void test_parseArgumentList_onlyNamed() { 5636 void test_parseArgumentList_onlyNamed() {
5625 ArgumentList argumentList = 5637 ArgumentList argumentList =
5626 ParserTestCase.parse4("parseArgumentList", "(x: x, y: y)"); 5638 ParserTestCase.parse4("parseArgumentList", "(x: x, y: y)");
5627 NodeList<Expression> arguments = argumentList.arguments; 5639 NodeList<Expression> arguments = argumentList.arguments;
5628 expect(arguments, hasLength(2)); 5640 expect(arguments, hasLength(2));
5629 } 5641 }
5630 5642
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
5647 void test_parseAssertStatement() { 5643 void test_parseAssertStatement() {
5648 AssertStatement statement = 5644 AssertStatement statement =
5649 ParserTestCase.parse4("parseAssertStatement", "assert (x);"); 5645 ParserTestCase.parse4("parseAssertStatement", "assert (x);");
5650 expect(statement.keyword, isNotNull); 5646 expect(statement.assertKeyword, isNotNull);
5651 expect(statement.leftParenthesis, isNotNull); 5647 expect(statement.leftParenthesis, isNotNull);
5652 expect(statement.condition, isNotNull); 5648 expect(statement.condition, isNotNull);
5653 expect(statement.rightParenthesis, isNotNull); 5649 expect(statement.rightParenthesis, isNotNull);
5654 expect(statement.semicolon, isNotNull); 5650 expect(statement.semicolon, isNotNull);
5655 } 5651 }
5656 5652
5657 void test_parseAssignableExpression_expression_args_dot() { 5653 void test_parseAssignableExpression_expression_args_dot() {
5658 PropertyAccess propertyAccess = 5654 PropertyAccess propertyAccess =
5659 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "(x)( y).z"); 5655 ParserTestCase.parse("parseAssignableExpression", <Object>[false], "(x)( y).z");
5660 FunctionExpressionInvocation invocation = 5656 FunctionExpressionInvocation invocation =
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
5884 void test_parseBlock_nonEmpty() { 5880 void test_parseBlock_nonEmpty() {
5885 Block block = ParserTestCase.parse4("parseBlock", "{;}"); 5881 Block block = ParserTestCase.parse4("parseBlock", "{;}");
5886 expect(block.leftBracket, isNotNull); 5882 expect(block.leftBracket, isNotNull);
5887 expect(block.statements, hasLength(1)); 5883 expect(block.statements, hasLength(1));
5888 expect(block.rightBracket, isNotNull); 5884 expect(block.rightBracket, isNotNull);
5889 } 5885 }
5890 5886
5891 void test_parseBreakStatement_label() { 5887 void test_parseBreakStatement_label() {
5892 BreakStatement statement = 5888 BreakStatement statement =
5893 ParserTestCase.parse4("parseBreakStatement", "break foo;"); 5889 ParserTestCase.parse4("parseBreakStatement", "break foo;");
5894 expect(statement.keyword, isNotNull); 5890 expect(statement.breakKeyword, isNotNull);
5895 expect(statement.label, isNotNull); 5891 expect(statement.label, isNotNull);
5896 expect(statement.semicolon, isNotNull); 5892 expect(statement.semicolon, isNotNull);
5897 } 5893 }
5898 5894
5899 void test_parseBreakStatement_noLabel() { 5895 void test_parseBreakStatement_noLabel() {
5900 BreakStatement statement = ParserTestCase.parse4( 5896 BreakStatement statement = ParserTestCase.parse4(
5901 "parseBreakStatement", 5897 "parseBreakStatement",
5902 "break;", 5898 "break;",
5903 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]); 5899 [ParserErrorCode.BREAK_OUTSIDE_OF_LOOP]);
5904 expect(statement.keyword, isNotNull); 5900 expect(statement.breakKeyword, isNotNull);
5905 expect(statement.label, isNull); 5901 expect(statement.label, isNull);
5906 expect(statement.semicolon, isNotNull); 5902 expect(statement.semicolon, isNotNull);
5907 } 5903 }
5908 5904
5909 void test_parseCascadeSection_i() { 5905 void test_parseCascadeSection_i() {
5910 IndexExpression section = 5906 IndexExpression section =
5911 ParserTestCase.parse4("parseCascadeSection", "..[i]"); 5907 ParserTestCase.parse4("parseCascadeSection", "..[i]");
5912 expect(section.target, isNull); 5908 expect(section.target, isNull);
5913 expect(section.leftBracket, isNotNull); 5909 expect(section.leftBracket, isNotNull);
5914 expect(section.index, isNotNull); 5910 expect(section.index, isNotNull);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
6138 expect(declaration.typeParameters, isNull); 6134 expect(declaration.typeParameters, isNull);
6139 } 6135 }
6140 6136
6141 void test_parseClassDeclaration_native() { 6137 void test_parseClassDeclaration_native() {
6142 ClassDeclaration declaration = ParserTestCase.parse( 6138 ClassDeclaration declaration = ParserTestCase.parse(
6143 "parseClassDeclaration", 6139 "parseClassDeclaration",
6144 <Object>[emptyCommentAndMetadata(), null], 6140 <Object>[emptyCommentAndMetadata(), null],
6145 "class A native 'nativeValue' {}"); 6141 "class A native 'nativeValue' {}");
6146 NativeClause nativeClause = declaration.nativeClause; 6142 NativeClause nativeClause = declaration.nativeClause;
6147 expect(nativeClause, isNotNull); 6143 expect(nativeClause, isNotNull);
6148 expect(nativeClause.keyword, isNotNull); 6144 expect(nativeClause.nativeKeyword, isNotNull);
6149 expect(nativeClause.name.stringValue, "nativeValue"); 6145 expect(nativeClause.name.stringValue, "nativeValue");
6150 expect(nativeClause.beginToken, same(nativeClause.keyword)); 6146 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword));
6151 expect(nativeClause.endToken, same(nativeClause.name.endToken)); 6147 expect(nativeClause.endToken, same(nativeClause.name.endToken));
6152 } 6148 }
6153 6149
6154 void test_parseClassDeclaration_nonEmpty() { 6150 void test_parseClassDeclaration_nonEmpty() {
6155 ClassDeclaration declaration = ParserTestCase.parse( 6151 ClassDeclaration declaration = ParserTestCase.parse(
6156 "parseClassDeclaration", 6152 "parseClassDeclaration",
6157 <Object>[emptyCommentAndMetadata(), null], 6153 <Object>[emptyCommentAndMetadata(), null],
6158 "class A {var f;}"); 6154 "class A {var f;}");
6159 expect(declaration.documentationComment, isNull); 6155 expect(declaration.documentationComment, isNull);
6160 expect(declaration.abstractKeyword, isNull); 6156 expect(declaration.abstractKeyword, isNull);
6161 expect(declaration.extendsClause, isNull); 6157 expect(declaration.extendsClause, isNull);
6162 expect(declaration.implementsClause, isNull); 6158 expect(declaration.implementsClause, isNull);
6163 expect(declaration.classKeyword, isNotNull); 6159 expect(declaration.classKeyword, isNotNull);
6164 expect(declaration.leftBracket, isNotNull); 6160 expect(declaration.leftBracket, isNotNull);
6165 expect(declaration.name, isNotNull); 6161 expect(declaration.name, isNotNull);
6166 expect(declaration.members, hasLength(1)); 6162 expect(declaration.members, hasLength(1));
6167 expect(declaration.rightBracket, isNotNull); 6163 expect(declaration.rightBracket, isNotNull);
6168 expect(declaration.typeParameters, isNull); 6164 expect(declaration.typeParameters, isNull);
6169 } 6165 }
6170 6166
6171 void test_parseClassDeclaration_typeAlias_implementsC() { 6167 void test_parseClassDeclaration_typeAlias_implementsC() {
6172 ClassTypeAlias typeAlias = ParserTestCase.parse( 6168 ClassTypeAlias typeAlias = ParserTestCase.parse(
6173 "parseClassDeclaration", 6169 "parseClassDeclaration",
6174 <Object>[emptyCommentAndMetadata(), null], 6170 <Object>[emptyCommentAndMetadata(), null],
6175 "class A = Object with B implements C;"); 6171 "class A = Object with B implements C;");
6176 expect(typeAlias.keyword, isNotNull); 6172 expect(typeAlias.typedefKeyword, isNotNull);
6177 expect(typeAlias.name, isNotNull); 6173 expect(typeAlias.name, isNotNull);
6178 expect(typeAlias.typeParameters, isNull); 6174 expect(typeAlias.typeParameters, isNull);
6179 expect(typeAlias.withClause, isNotNull); 6175 expect(typeAlias.withClause, isNotNull);
6180 expect(typeAlias.implementsClause, isNotNull); 6176 expect(typeAlias.implementsClause, isNotNull);
6181 expect(typeAlias.implementsClause.keyword, isNotNull); 6177 expect(typeAlias.implementsClause.implementsKeyword, isNotNull);
6182 expect(typeAlias.implementsClause.interfaces.length, 1); 6178 expect(typeAlias.implementsClause.interfaces.length, 1);
6183 expect(typeAlias.semicolon, isNotNull); 6179 expect(typeAlias.semicolon, isNotNull);
6184 } 6180 }
6185 6181
6186 void test_parseClassDeclaration_typeAlias_withB() { 6182 void test_parseClassDeclaration_typeAlias_withB() {
6187 ClassTypeAlias typeAlias = ParserTestCase.parse( 6183 ClassTypeAlias typeAlias = ParserTestCase.parse(
6188 "parseClassDeclaration", 6184 "parseClassDeclaration",
6189 <Object>[emptyCommentAndMetadata(), null], 6185 <Object>[emptyCommentAndMetadata(), null],
6190 "class A = Object with B;"); 6186 "class A = Object with B;");
6191 expect(typeAlias.keyword, isNotNull); 6187 expect(typeAlias.typedefKeyword, isNotNull);
6192 expect(typeAlias.name, isNotNull); 6188 expect(typeAlias.name, isNotNull);
6193 expect(typeAlias.typeParameters, isNull); 6189 expect(typeAlias.typeParameters, isNull);
6194 expect(typeAlias.withClause, isNotNull); 6190 expect(typeAlias.withClause, isNotNull);
6195 expect(typeAlias.withClause.withKeyword, isNotNull); 6191 expect(typeAlias.withClause.withKeyword, isNotNull);
6196 expect(typeAlias.withClause.mixinTypes.length, 1); 6192 expect(typeAlias.withClause.mixinTypes.length, 1);
6197 expect(typeAlias.implementsClause, isNull); 6193 expect(typeAlias.implementsClause, isNull);
6198 expect(typeAlias.semicolon, isNotNull); 6194 expect(typeAlias.semicolon, isNotNull);
6199 } 6195 }
6200 6196
6201 void test_parseClassDeclaration_typeParameters() { 6197 void test_parseClassDeclaration_typeParameters() {
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
6555 expect(constructor.body, isNotNull); 6551 expect(constructor.body, isNotNull);
6556 } 6552 }
6557 6553
6558 void test_parseClassTypeAlias_abstract() { 6554 void test_parseClassTypeAlias_abstract() {
6559 Token classToken = TokenFactory.tokenFromKeyword(Keyword.CLASS); 6555 Token classToken = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6560 Token abstractToken = TokenFactory.tokenFromKeyword(Keyword.ABSTRACT); 6556 Token abstractToken = TokenFactory.tokenFromKeyword(Keyword.ABSTRACT);
6561 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 6557 ClassTypeAlias classTypeAlias = ParserTestCase.parse(
6562 "parseClassTypeAlias", 6558 "parseClassTypeAlias",
6563 <Object>[emptyCommentAndMetadata(), abstractToken, classToken], 6559 <Object>[emptyCommentAndMetadata(), abstractToken, classToken],
6564 "A = B with C;"); 6560 "A = B with C;");
6565 expect(classTypeAlias.keyword, isNotNull); 6561 expect(classTypeAlias.typedefKeyword, isNotNull);
6566 expect(classTypeAlias.name.name, "A"); 6562 expect(classTypeAlias.name.name, "A");
6567 expect(classTypeAlias.equals, isNotNull); 6563 expect(classTypeAlias.equals, isNotNull);
6568 expect(classTypeAlias.abstractKeyword, isNotNull); 6564 expect(classTypeAlias.abstractKeyword, isNotNull);
6569 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 6565 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6570 expect(classTypeAlias.withClause, isNotNull); 6566 expect(classTypeAlias.withClause, isNotNull);
6571 expect(classTypeAlias.implementsClause, isNull); 6567 expect(classTypeAlias.implementsClause, isNull);
6572 expect(classTypeAlias.semicolon, isNotNull); 6568 expect(classTypeAlias.semicolon, isNotNull);
6573 } 6569 }
6574 6570
6575 void test_parseClassTypeAlias_implements() { 6571 void test_parseClassTypeAlias_implements() {
6576 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); 6572 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6577 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 6573 ClassTypeAlias classTypeAlias = ParserTestCase.parse(
6578 "parseClassTypeAlias", 6574 "parseClassTypeAlias",
6579 <Object>[emptyCommentAndMetadata(), null, token], 6575 <Object>[emptyCommentAndMetadata(), null, token],
6580 "A = B with C implements D;"); 6576 "A = B with C implements D;");
6581 expect(classTypeAlias.keyword, isNotNull); 6577 expect(classTypeAlias.typedefKeyword, isNotNull);
6582 expect(classTypeAlias.name.name, "A"); 6578 expect(classTypeAlias.name.name, "A");
6583 expect(classTypeAlias.equals, isNotNull); 6579 expect(classTypeAlias.equals, isNotNull);
6584 expect(classTypeAlias.abstractKeyword, isNull); 6580 expect(classTypeAlias.abstractKeyword, isNull);
6585 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 6581 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6586 expect(classTypeAlias.withClause, isNotNull); 6582 expect(classTypeAlias.withClause, isNotNull);
6587 expect(classTypeAlias.implementsClause, isNotNull); 6583 expect(classTypeAlias.implementsClause, isNotNull);
6588 expect(classTypeAlias.semicolon, isNotNull); 6584 expect(classTypeAlias.semicolon, isNotNull);
6589 } 6585 }
6590 6586
6591 void test_parseClassTypeAlias_with() { 6587 void test_parseClassTypeAlias_with() {
6592 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); 6588 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6593 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 6589 ClassTypeAlias classTypeAlias = ParserTestCase.parse(
6594 "parseClassTypeAlias", 6590 "parseClassTypeAlias",
6595 <Object>[emptyCommentAndMetadata(), null, token], 6591 <Object>[emptyCommentAndMetadata(), null, token],
6596 "A = B with C;"); 6592 "A = B with C;");
6597 expect(classTypeAlias.keyword, isNotNull); 6593 expect(classTypeAlias.typedefKeyword, isNotNull);
6598 expect(classTypeAlias.name.name, "A"); 6594 expect(classTypeAlias.name.name, "A");
6599 expect(classTypeAlias.equals, isNotNull); 6595 expect(classTypeAlias.equals, isNotNull);
6600 expect(classTypeAlias.abstractKeyword, isNull); 6596 expect(classTypeAlias.abstractKeyword, isNull);
6601 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 6597 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6602 expect(classTypeAlias.withClause, isNotNull); 6598 expect(classTypeAlias.withClause, isNotNull);
6603 expect(classTypeAlias.implementsClause, isNull); 6599 expect(classTypeAlias.implementsClause, isNull);
6604 expect(classTypeAlias.semicolon, isNotNull); 6600 expect(classTypeAlias.semicolon, isNotNull);
6605 } 6601 }
6606 6602
6607 void test_parseClassTypeAlias_with_implements() { 6603 void test_parseClassTypeAlias_with_implements() {
6608 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS); 6604 Token token = TokenFactory.tokenFromKeyword(Keyword.CLASS);
6609 ClassTypeAlias classTypeAlias = ParserTestCase.parse( 6605 ClassTypeAlias classTypeAlias = ParserTestCase.parse(
6610 "parseClassTypeAlias", 6606 "parseClassTypeAlias",
6611 <Object>[emptyCommentAndMetadata(), null, token], 6607 <Object>[emptyCommentAndMetadata(), null, token],
6612 "A = B with C implements D;"); 6608 "A = B with C implements D;");
6613 expect(classTypeAlias.keyword, isNotNull); 6609 expect(classTypeAlias.typedefKeyword, isNotNull);
6614 expect(classTypeAlias.name.name, "A"); 6610 expect(classTypeAlias.name.name, "A");
6615 expect(classTypeAlias.equals, isNotNull); 6611 expect(classTypeAlias.equals, isNotNull);
6616 expect(classTypeAlias.abstractKeyword, isNull); 6612 expect(classTypeAlias.abstractKeyword, isNull);
6617 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B"); 6613 expect(classTypeAlias.superclass.name.name, isNotNull, reason: "B");
6618 expect(classTypeAlias.withClause, isNotNull); 6614 expect(classTypeAlias.withClause, isNotNull);
6619 expect(classTypeAlias.implementsClause, isNotNull); 6615 expect(classTypeAlias.implementsClause, isNotNull);
6620 expect(classTypeAlias.semicolon, isNotNull); 6616 expect(classTypeAlias.semicolon, isNotNull);
6621 } 6617 }
6622 6618
6623 void test_parseCombinator_hide() { 6619 void test_parseCombinator_hide() {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
6982 3)]; 6978 3)];
6983 List<CommentReference> references = 6979 List<CommentReference> references =
6984 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6980 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6985 expect(references, hasLength(1)); 6981 expect(references, hasLength(1));
6986 CommentReference reference = references[0]; 6982 CommentReference reference = references[0];
6987 expect(reference, isNotNull); 6983 expect(reference, isNotNull);
6988 expect(reference.identifier, isNotNull); 6984 expect(reference.identifier, isNotNull);
6989 expect(reference.offset, 15); 6985 expect(reference.offset, 15);
6990 } 6986 }
6991 6987
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
6992 void test_parseCompilationUnitMember_abstractAsPrefix() { 7098 void test_parseCompilationUnitMember_abstractAsPrefix() {
6993 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 7099 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
6994 "parseCompilationUnitMember", 7100 "parseCompilationUnitMember",
6995 <Object>[emptyCommentAndMetadata()], 7101 <Object>[emptyCommentAndMetadata()],
6996 "abstract.A _abstract = new abstract.A();"); 7102 "abstract.A _abstract = new abstract.A();");
6997 expect(declaration.semicolon, isNotNull); 7103 expect(declaration.semicolon, isNotNull);
6998 expect(declaration.variables, isNotNull); 7104 expect(declaration.variables, isNotNull);
6999 } 7105 }
7000 7106
7001 void test_parseCompilationUnitMember_class() { 7107 void test_parseCompilationUnitMember_class() {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
7155 expect(declaration.functionExpression, isNotNull); 7261 expect(declaration.functionExpression, isNotNull);
7156 expect(declaration.propertyKeyword, isNotNull); 7262 expect(declaration.propertyKeyword, isNotNull);
7157 expect(declaration.returnType, isNotNull); 7263 expect(declaration.returnType, isNotNull);
7158 } 7264 }
7159 7265
7160 void test_parseCompilationUnitMember_typeAlias_abstract() { 7266 void test_parseCompilationUnitMember_typeAlias_abstract() {
7161 ClassTypeAlias typeAlias = ParserTestCase.parse( 7267 ClassTypeAlias typeAlias = ParserTestCase.parse(
7162 "parseCompilationUnitMember", 7268 "parseCompilationUnitMember",
7163 <Object>[emptyCommentAndMetadata()], 7269 <Object>[emptyCommentAndMetadata()],
7164 "abstract class C = S with M;"); 7270 "abstract class C = S with M;");
7165 expect(typeAlias.keyword, isNotNull); 7271 expect(typeAlias.typedefKeyword, isNotNull);
7166 expect(typeAlias.name.name, "C"); 7272 expect(typeAlias.name.name, "C");
7167 expect(typeAlias.typeParameters, isNull); 7273 expect(typeAlias.typeParameters, isNull);
7168 expect(typeAlias.equals, isNotNull); 7274 expect(typeAlias.equals, isNotNull);
7169 expect(typeAlias.abstractKeyword, isNotNull); 7275 expect(typeAlias.abstractKeyword, isNotNull);
7170 expect(typeAlias.superclass.name.name, "S"); 7276 expect(typeAlias.superclass.name.name, "S");
7171 expect(typeAlias.withClause, isNotNull); 7277 expect(typeAlias.withClause, isNotNull);
7172 expect(typeAlias.implementsClause, isNull); 7278 expect(typeAlias.implementsClause, isNull);
7173 expect(typeAlias.semicolon, isNotNull); 7279 expect(typeAlias.semicolon, isNotNull);
7174 } 7280 }
7175 7281
7176 void test_parseCompilationUnitMember_typeAlias_generic() { 7282 void test_parseCompilationUnitMember_typeAlias_generic() {
7177 ClassTypeAlias typeAlias = ParserTestCase.parse( 7283 ClassTypeAlias typeAlias = ParserTestCase.parse(
7178 "parseCompilationUnitMember", 7284 "parseCompilationUnitMember",
7179 <Object>[emptyCommentAndMetadata()], 7285 <Object>[emptyCommentAndMetadata()],
7180 "class C<E> = S<E> with M<E> implements I<E>;"); 7286 "class C<E> = S<E> with M<E> implements I<E>;");
7181 expect(typeAlias.keyword, isNotNull); 7287 expect(typeAlias.typedefKeyword, isNotNull);
7182 expect(typeAlias.name.name, "C"); 7288 expect(typeAlias.name.name, "C");
7183 expect(typeAlias.typeParameters.typeParameters, hasLength(1)); 7289 expect(typeAlias.typeParameters.typeParameters, hasLength(1));
7184 expect(typeAlias.equals, isNotNull); 7290 expect(typeAlias.equals, isNotNull);
7185 expect(typeAlias.abstractKeyword, isNull); 7291 expect(typeAlias.abstractKeyword, isNull);
7186 expect(typeAlias.superclass.name.name, "S"); 7292 expect(typeAlias.superclass.name.name, "S");
7187 expect(typeAlias.withClause, isNotNull); 7293 expect(typeAlias.withClause, isNotNull);
7188 expect(typeAlias.implementsClause, isNotNull); 7294 expect(typeAlias.implementsClause, isNotNull);
7189 expect(typeAlias.semicolon, isNotNull); 7295 expect(typeAlias.semicolon, isNotNull);
7190 } 7296 }
7191 7297
7192 void test_parseCompilationUnitMember_typeAlias_implements() { 7298 void test_parseCompilationUnitMember_typeAlias_implements() {
7193 ClassTypeAlias typeAlias = ParserTestCase.parse( 7299 ClassTypeAlias typeAlias = ParserTestCase.parse(
7194 "parseCompilationUnitMember", 7300 "parseCompilationUnitMember",
7195 <Object>[emptyCommentAndMetadata()], 7301 <Object>[emptyCommentAndMetadata()],
7196 "class C = S with M implements I;"); 7302 "class C = S with M implements I;");
7197 expect(typeAlias.keyword, isNotNull); 7303 expect(typeAlias.typedefKeyword, isNotNull);
7198 expect(typeAlias.name.name, "C"); 7304 expect(typeAlias.name.name, "C");
7199 expect(typeAlias.typeParameters, isNull); 7305 expect(typeAlias.typeParameters, isNull);
7200 expect(typeAlias.equals, isNotNull); 7306 expect(typeAlias.equals, isNotNull);
7201 expect(typeAlias.abstractKeyword, isNull); 7307 expect(typeAlias.abstractKeyword, isNull);
7202 expect(typeAlias.superclass.name.name, "S"); 7308 expect(typeAlias.superclass.name.name, "S");
7203 expect(typeAlias.withClause, isNotNull); 7309 expect(typeAlias.withClause, isNotNull);
7204 expect(typeAlias.implementsClause, isNotNull); 7310 expect(typeAlias.implementsClause, isNotNull);
7205 expect(typeAlias.semicolon, isNotNull); 7311 expect(typeAlias.semicolon, isNotNull);
7206 } 7312 }
7207 7313
7208 void test_parseCompilationUnitMember_typeAlias_noImplements() { 7314 void test_parseCompilationUnitMember_typeAlias_noImplements() {
7209 ClassTypeAlias typeAlias = ParserTestCase.parse( 7315 ClassTypeAlias typeAlias = ParserTestCase.parse(
7210 "parseCompilationUnitMember", 7316 "parseCompilationUnitMember",
7211 <Object>[emptyCommentAndMetadata()], 7317 <Object>[emptyCommentAndMetadata()],
7212 "class C = S with M;"); 7318 "class C = S with M;");
7213 expect(typeAlias.keyword, isNotNull); 7319 expect(typeAlias.typedefKeyword, isNotNull);
7214 expect(typeAlias.name.name, "C"); 7320 expect(typeAlias.name.name, "C");
7215 expect(typeAlias.typeParameters, isNull); 7321 expect(typeAlias.typeParameters, isNull);
7216 expect(typeAlias.equals, isNotNull); 7322 expect(typeAlias.equals, isNotNull);
7217 expect(typeAlias.abstractKeyword, isNull); 7323 expect(typeAlias.abstractKeyword, isNull);
7218 expect(typeAlias.superclass.name.name, "S"); 7324 expect(typeAlias.superclass.name.name, "S");
7219 expect(typeAlias.withClause, isNotNull); 7325 expect(typeAlias.withClause, isNotNull);
7220 expect(typeAlias.implementsClause, isNull); 7326 expect(typeAlias.implementsClause, isNull);
7221 expect(typeAlias.semicolon, isNotNull); 7327 expect(typeAlias.semicolon, isNotNull);
7222 } 7328 }
7223 7329
(...skipping 26 matching lines...) Expand all
7250 7356
7251 void test_parseCompilationUnitMember_variableSet() { 7357 void test_parseCompilationUnitMember_variableSet() {
7252 TopLevelVariableDeclaration declaration = ParserTestCase.parse( 7358 TopLevelVariableDeclaration declaration = ParserTestCase.parse(
7253 "parseCompilationUnitMember", 7359 "parseCompilationUnitMember",
7254 <Object>[emptyCommentAndMetadata()], 7360 <Object>[emptyCommentAndMetadata()],
7255 "String set = null;"); 7361 "String set = null;");
7256 expect(declaration.semicolon, isNotNull); 7362 expect(declaration.semicolon, isNotNull);
7257 expect(declaration.variables, isNotNull); 7363 expect(declaration.variables, isNotNull);
7258 } 7364 }
7259 7365
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
7370 void test_parseConditionalExpression() { 7366 void test_parseConditionalExpression() {
7371 ConditionalExpression expression = 7367 ConditionalExpression expression =
7372 ParserTestCase.parse4("parseConditionalExpression", "x ? y : z"); 7368 ParserTestCase.parse4("parseConditionalExpression", "x ? y : z");
7373 expect(expression.condition, isNotNull); 7369 expect(expression.condition, isNotNull);
7374 expect(expression.question, isNotNull); 7370 expect(expression.question, isNotNull);
7375 expect(expression.thenExpression, isNotNull); 7371 expect(expression.thenExpression, isNotNull);
7376 expect(expression.colon, isNotNull); 7372 expect(expression.colon, isNotNull);
7377 expect(expression.elseExpression, isNotNull); 7373 expect(expression.elseExpression, isNotNull);
7378 } 7374 }
7379 7375
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
7428 } 7424 }
7429 7425
7430 void test_parseConstructor() { 7426 void test_parseConstructor() {
7431 // TODO(brianwilkerson) Implement tests for this method. 7427 // TODO(brianwilkerson) Implement tests for this method.
7432 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class, 7428 // parse("parseConstructor", new Class[] {Parser.CommentAndMetadata.class,
7433 // Token.class, Token.class, SimpleIdentifier.class, Token.class, 7429 // Token.class, Token.class, SimpleIdentifier.class, Token.class,
7434 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt yCommentAndMetadata(), 7430 // SimpleIdentifier.class, FormalParameterList.class}, new Object[] {empt yCommentAndMetadata(),
7435 // null, null, null, null, null, null}, ""); 7431 // null, null, null, null, null, null}, "");
7436 } 7432 }
7437 7433
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
7438 void test_parseConstructorFieldInitializer_qualified() { 7461 void test_parseConstructorFieldInitializer_qualified() {
7439 ConstructorFieldInitializer invocation = 7462 ConstructorFieldInitializer invocation =
7440 ParserTestCase.parse4("parseConstructorFieldInitializer", "this.a = b"); 7463 ParserTestCase.parse4("parseConstructorFieldInitializer", "this.a = b");
7441 expect(invocation.equals, isNotNull); 7464 expect(invocation.equals, isNotNull);
7442 expect(invocation.expression, isNotNull); 7465 expect(invocation.expression, isNotNull);
7443 expect(invocation.fieldName, isNotNull); 7466 expect(invocation.fieldName, isNotNull);
7444 expect(invocation.keyword, isNotNull); 7467 expect(invocation.thisKeyword, isNotNull);
7445 expect(invocation.period, isNotNull); 7468 expect(invocation.period, isNotNull);
7446 } 7469 }
7447 7470
7448 void test_parseConstructorFieldInitializer_unqualified() { 7471 void test_parseConstructorFieldInitializer_unqualified() {
7449 ConstructorFieldInitializer invocation = 7472 ConstructorFieldInitializer invocation =
7450 ParserTestCase.parse4("parseConstructorFieldInitializer", "a = b"); 7473 ParserTestCase.parse4("parseConstructorFieldInitializer", "a = b");
7451 expect(invocation.equals, isNotNull); 7474 expect(invocation.equals, isNotNull);
7452 expect(invocation.expression, isNotNull); 7475 expect(invocation.expression, isNotNull);
7453 expect(invocation.fieldName, isNotNull); 7476 expect(invocation.fieldName, isNotNull);
7454 expect(invocation.keyword, isNull); 7477 expect(invocation.thisKeyword, isNull);
7455 expect(invocation.period, isNull); 7478 expect(invocation.period, isNull);
7456 } 7479 }
7457 7480
7458 void test_parseConstructorName_named_noPrefix() { 7481 void test_parseConstructorName_named_noPrefix() {
7459 ConstructorName name = 7482 ConstructorName name =
7460 ParserTestCase.parse4("parseConstructorName", "A.n;"); 7483 ParserTestCase.parse4("parseConstructorName", "A.n;");
7461 expect(name.type, isNotNull); 7484 expect(name.type, isNotNull);
7462 expect(name.period, isNull); 7485 expect(name.period, isNull);
7463 expect(name.name, isNull); 7486 expect(name.name, isNull);
7464 } 7487 }
(...skipping 14 matching lines...) Expand all
7479 } 7502 }
7480 7503
7481 void test_parseConstructorName_unnamed_prefixed() { 7504 void test_parseConstructorName_unnamed_prefixed() {
7482 ConstructorName name = 7505 ConstructorName name =
7483 ParserTestCase.parse4("parseConstructorName", "p.A;"); 7506 ParserTestCase.parse4("parseConstructorName", "p.A;");
7484 expect(name.type, isNotNull); 7507 expect(name.type, isNotNull);
7485 expect(name.period, isNull); 7508 expect(name.period, isNull);
7486 expect(name.name, isNull); 7509 expect(name.name, isNull);
7487 } 7510 }
7488 7511
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
7516 void test_parseContinueStatement_label() { 7512 void test_parseContinueStatement_label() {
7517 ContinueStatement statement = ParserTestCase.parse4( 7513 ContinueStatement statement = ParserTestCase.parse4(
7518 "parseContinueStatement", 7514 "parseContinueStatement",
7519 "continue foo;", 7515 "continue foo;",
7520 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); 7516 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
7521 expect(statement.keyword, isNotNull); 7517 expect(statement.continueKeyword, isNotNull);
7522 expect(statement.label, isNotNull); 7518 expect(statement.label, isNotNull);
7523 expect(statement.semicolon, isNotNull); 7519 expect(statement.semicolon, isNotNull);
7524 } 7520 }
7525 7521
7526 void test_parseContinueStatement_noLabel() { 7522 void test_parseContinueStatement_noLabel() {
7527 ContinueStatement statement = ParserTestCase.parse4( 7523 ContinueStatement statement = ParserTestCase.parse4(
7528 "parseContinueStatement", 7524 "parseContinueStatement",
7529 "continue;", 7525 "continue;",
7530 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]); 7526 [ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP]);
7531 expect(statement.keyword, isNotNull); 7527 expect(statement.continueKeyword, isNotNull);
7532 expect(statement.label, isNull); 7528 expect(statement.label, isNull);
7533 expect(statement.semicolon, isNotNull); 7529 expect(statement.semicolon, isNotNull);
7534 } 7530 }
7535 7531
7536 void test_parseDirective_export() { 7532 void test_parseDirective_export() {
7537 ExportDirective directive = ParserTestCase.parse( 7533 ExportDirective directive = ParserTestCase.parse(
7538 "parseDirective", 7534 "parseDirective",
7539 <Object>[emptyCommentAndMetadata()], 7535 <Object>[emptyCommentAndMetadata()],
7540 "export 'lib/lib.dart';"); 7536 "export 'lib/lib.dart';");
7541 expect(directive.keyword, isNotNull); 7537 expect(directive.keyword, isNotNull);
7542 expect(directive.uri, isNotNull); 7538 expect(directive.uri, isNotNull);
7543 expect(directive.combinators, hasLength(0)); 7539 expect(directive.combinators, hasLength(0));
7544 expect(directive.semicolon, isNotNull); 7540 expect(directive.semicolon, isNotNull);
7545 } 7541 }
7546 7542
7547 void test_parseDirective_import() { 7543 void test_parseDirective_import() {
7548 ImportDirective directive = ParserTestCase.parse( 7544 ImportDirective directive = ParserTestCase.parse(
7549 "parseDirective", 7545 "parseDirective",
7550 <Object>[emptyCommentAndMetadata()], 7546 <Object>[emptyCommentAndMetadata()],
7551 "import 'lib/lib.dart';"); 7547 "import 'lib/lib.dart';");
7552 expect(directive.keyword, isNotNull); 7548 expect(directive.keyword, isNotNull);
7553 expect(directive.uri, isNotNull); 7549 expect(directive.uri, isNotNull);
7554 expect(directive.asToken, isNull); 7550 expect(directive.asKeyword, isNull);
7555 expect(directive.prefix, isNull); 7551 expect(directive.prefix, isNull);
7556 expect(directive.combinators, hasLength(0)); 7552 expect(directive.combinators, hasLength(0));
7557 expect(directive.semicolon, isNotNull); 7553 expect(directive.semicolon, isNotNull);
7558 } 7554 }
7559 7555
7560 void test_parseDirective_library() { 7556 void test_parseDirective_library() {
7561 LibraryDirective directive = ParserTestCase.parse( 7557 LibraryDirective directive = ParserTestCase.parse(
7562 "parseDirective", 7558 "parseDirective",
7563 <Object>[emptyCommentAndMetadata()], 7559 <Object>[emptyCommentAndMetadata()],
7564 "library l;"); 7560 "library l;");
7565 expect(directive.libraryToken, isNotNull); 7561 expect(directive.libraryKeyword, isNotNull);
7566 expect(directive.name, isNotNull); 7562 expect(directive.name, isNotNull);
7567 expect(directive.semicolon, isNotNull); 7563 expect(directive.semicolon, isNotNull);
7568 } 7564 }
7569 7565
7570 void test_parseDirective_part() { 7566 void test_parseDirective_part() {
7571 PartDirective directive = ParserTestCase.parse( 7567 PartDirective directive = ParserTestCase.parse(
7572 "parseDirective", 7568 "parseDirective",
7573 <Object>[emptyCommentAndMetadata()], 7569 <Object>[emptyCommentAndMetadata()],
7574 "part 'lib/lib.dart';"); 7570 "part 'lib/lib.dart';");
7575 expect(directive.partToken, isNotNull); 7571 expect(directive.partKeyword, isNotNull);
7576 expect(directive.uri, isNotNull); 7572 expect(directive.uri, isNotNull);
7577 expect(directive.semicolon, isNotNull); 7573 expect(directive.semicolon, isNotNull);
7578 } 7574 }
7579 7575
7580 void test_parseDirective_partOf() { 7576 void test_parseDirective_partOf() {
7581 PartOfDirective directive = ParserTestCase.parse( 7577 PartOfDirective directive = ParserTestCase.parse(
7582 "parseDirective", 7578 "parseDirective",
7583 <Object>[emptyCommentAndMetadata()], 7579 <Object>[emptyCommentAndMetadata()],
7584 "part of l;"); 7580 "part of l;");
7585 expect(directive.partToken, isNotNull); 7581 expect(directive.partKeyword, isNotNull);
7586 expect(directive.ofToken, isNotNull); 7582 expect(directive.ofKeyword, isNotNull);
7587 expect(directive.libraryName, isNotNull); 7583 expect(directive.libraryName, isNotNull);
7588 expect(directive.semicolon, isNotNull); 7584 expect(directive.semicolon, isNotNull);
7589 } 7585 }
7590 7586
7591 void test_parseDirectives_complete() { 7587 void test_parseDirectives_complete() {
7592 CompilationUnit unit = 7588 CompilationUnit unit =
7593 _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}"); 7589 _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}");
7594 expect(unit.scriptTag, isNotNull); 7590 expect(unit.scriptTag, isNotNull);
7595 expect(unit.directives, hasLength(1)); 7591 expect(unit.directives, hasLength(1));
7596 } 7592 }
(...skipping 28 matching lines...) Expand all
7625 expect(unit.scriptTag, isNull); 7621 expect(unit.scriptTag, isNull);
7626 expect(unit.directives, hasLength(1)); 7622 expect(unit.directives, hasLength(1));
7627 } 7623 }
7628 7624
7629 void test_parseDirectives_topLevelDeclaration() { 7625 void test_parseDirectives_topLevelDeclaration() {
7630 CompilationUnit unit = _parseDirectives("class A {}"); 7626 CompilationUnit unit = _parseDirectives("class A {}");
7631 expect(unit.scriptTag, isNull); 7627 expect(unit.scriptTag, isNull);
7632 expect(unit.directives, hasLength(0)); 7628 expect(unit.directives, hasLength(0));
7633 } 7629 }
7634 7630
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
7647 void test_parseDocumentationComment_block() { 7631 void test_parseDocumentationComment_block() {
7648 Comment comment = 7632 Comment comment =
7649 ParserTestCase.parse4("parseDocumentationComment", "/** */ class"); 7633 ParserTestCase.parse4("parseDocumentationComment", "/** */ class");
7650 expect(comment.isBlock, isFalse); 7634 expect(comment.isBlock, isFalse);
7651 expect(comment.isDocumentation, isTrue); 7635 expect(comment.isDocumentation, isTrue);
7652 expect(comment.isEndOfLine, isFalse); 7636 expect(comment.isEndOfLine, isFalse);
7653 } 7637 }
7654 7638
7655 void test_parseDocumentationComment_block_withReference() { 7639 void test_parseDocumentationComment_block_withReference() {
7656 Comment comment = 7640 Comment comment =
7657 ParserTestCase.parse4("parseDocumentationComment", "/** [a] */ class"); 7641 ParserTestCase.parse4("parseDocumentationComment", "/** [a] */ class");
7658 expect(comment.isBlock, isFalse); 7642 expect(comment.isBlock, isFalse);
7659 expect(comment.isDocumentation, isTrue); 7643 expect(comment.isDocumentation, isTrue);
7660 expect(comment.isEndOfLine, isFalse); 7644 expect(comment.isEndOfLine, isFalse);
7661 NodeList<CommentReference> references = comment.references; 7645 NodeList<CommentReference> references = comment.references;
7662 expect(references, hasLength(1)); 7646 expect(references, hasLength(1));
7663 CommentReference reference = references[0]; 7647 CommentReference reference = references[0];
7664 expect(reference, isNotNull); 7648 expect(reference, isNotNull);
7665 expect(reference.offset, 5); 7649 expect(reference.offset, 5);
7666 } 7650 }
7667 7651
7668 void test_parseDocumentationComment_endOfLine() { 7652 void test_parseDocumentationComment_endOfLine() {
7669 Comment comment = 7653 Comment comment =
7670 ParserTestCase.parse4("parseDocumentationComment", "/// \n/// \n class") ; 7654 ParserTestCase.parse4("parseDocumentationComment", "/// \n/// \n class") ;
7671 expect(comment.isBlock, isFalse); 7655 expect(comment.isBlock, isFalse);
7672 expect(comment.isDocumentation, isTrue); 7656 expect(comment.isDocumentation, isTrue);
7673 expect(comment.isEndOfLine, isFalse); 7657 expect(comment.isEndOfLine, isFalse);
7674 } 7658 }
7675 7659
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
7676 void test_parseEmptyStatement() { 7672 void test_parseEmptyStatement() {
7677 EmptyStatement statement = 7673 EmptyStatement statement =
7678 ParserTestCase.parse4("parseEmptyStatement", ";"); 7674 ParserTestCase.parse4("parseEmptyStatement", ";");
7679 expect(statement.semicolon, isNotNull); 7675 expect(statement.semicolon, isNotNull);
7680 } 7676 }
7681 7677
7682 void test_parseEnumDeclaration_one() { 7678 void test_parseEnumDeclaration_one() {
7683 EnumDeclaration declaration = ParserTestCase.parse( 7679 EnumDeclaration declaration = ParserTestCase.parse(
7684 "parseEnumDeclaration", 7680 "parseEnumDeclaration",
7685 <Object>[emptyCommentAndMetadata()], 7681 <Object>[emptyCommentAndMetadata()],
7686 "enum E {ONE}"); 7682 "enum E {ONE}");
7687 expect(declaration.documentationComment, isNull); 7683 expect(declaration.documentationComment, isNull);
7688 expect(declaration.keyword, isNotNull); 7684 expect(declaration.enumKeyword, isNotNull);
7689 expect(declaration.leftBracket, isNotNull); 7685 expect(declaration.leftBracket, isNotNull);
7690 expect(declaration.name, isNotNull); 7686 expect(declaration.name, isNotNull);
7691 expect(declaration.constants, hasLength(1)); 7687 expect(declaration.constants, hasLength(1));
7692 expect(declaration.rightBracket, isNotNull); 7688 expect(declaration.rightBracket, isNotNull);
7693 } 7689 }
7694 7690
7695 void test_parseEnumDeclaration_trailingComma() { 7691 void test_parseEnumDeclaration_trailingComma() {
7696 EnumDeclaration declaration = ParserTestCase.parse( 7692 EnumDeclaration declaration = ParserTestCase.parse(
7697 "parseEnumDeclaration", 7693 "parseEnumDeclaration",
7698 <Object>[emptyCommentAndMetadata()], 7694 <Object>[emptyCommentAndMetadata()],
7699 "enum E {ONE,}"); 7695 "enum E {ONE,}");
7700 expect(declaration.documentationComment, isNull); 7696 expect(declaration.documentationComment, isNull);
7701 expect(declaration.keyword, isNotNull); 7697 expect(declaration.enumKeyword, isNotNull);
7702 expect(declaration.leftBracket, isNotNull); 7698 expect(declaration.leftBracket, isNotNull);
7703 expect(declaration.name, isNotNull); 7699 expect(declaration.name, isNotNull);
7704 expect(declaration.constants, hasLength(1)); 7700 expect(declaration.constants, hasLength(1));
7705 expect(declaration.rightBracket, isNotNull); 7701 expect(declaration.rightBracket, isNotNull);
7706 } 7702 }
7707 7703
7708 void test_parseEnumDeclaration_two() { 7704 void test_parseEnumDeclaration_two() {
7709 EnumDeclaration declaration = ParserTestCase.parse( 7705 EnumDeclaration declaration = ParserTestCase.parse(
7710 "parseEnumDeclaration", 7706 "parseEnumDeclaration",
7711 <Object>[emptyCommentAndMetadata()], 7707 <Object>[emptyCommentAndMetadata()],
7712 "enum E {ONE, TWO}"); 7708 "enum E {ONE, TWO}");
7713 expect(declaration.documentationComment, isNull); 7709 expect(declaration.documentationComment, isNull);
7714 expect(declaration.keyword, isNotNull); 7710 expect(declaration.enumKeyword, isNotNull);
7715 expect(declaration.leftBracket, isNotNull); 7711 expect(declaration.leftBracket, isNotNull);
7716 expect(declaration.name, isNotNull); 7712 expect(declaration.name, isNotNull);
7717 expect(declaration.constants, hasLength(2)); 7713 expect(declaration.constants, hasLength(2));
7718 expect(declaration.rightBracket, isNotNull); 7714 expect(declaration.rightBracket, isNotNull);
7719 } 7715 }
7720 7716
7721 void test_parseEqualityExpression_normal() { 7717 void test_parseEqualityExpression_normal() {
7722 BinaryExpression expression = 7718 BinaryExpression expression =
7723 ParserTestCase.parse4("parseEqualityExpression", "x == y"); 7719 ParserTestCase.parse4("parseEqualityExpression", "x == y");
7724 expect(expression.leftOperand, isNotNull); 7720 expect(expression.leftOperand, isNotNull);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
7787 ExportDirective directive = ParserTestCase.parse( 7783 ExportDirective directive = ParserTestCase.parse(
7788 "parseExportDirective", 7784 "parseExportDirective",
7789 <Object>[emptyCommentAndMetadata()], 7785 <Object>[emptyCommentAndMetadata()],
7790 "export 'lib/lib.dart' show B hide A;"); 7786 "export 'lib/lib.dart' show B hide A;");
7791 expect(directive.keyword, isNotNull); 7787 expect(directive.keyword, isNotNull);
7792 expect(directive.uri, isNotNull); 7788 expect(directive.uri, isNotNull);
7793 expect(directive.combinators, hasLength(2)); 7789 expect(directive.combinators, hasLength(2));
7794 expect(directive.semicolon, isNotNull); 7790 expect(directive.semicolon, isNotNull);
7795 } 7791 }
7796 7792
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
7835 void test_parseExpression_assign() { 7793 void test_parseExpression_assign() {
7836 // TODO(brianwilkerson) Implement more tests for this method. 7794 // TODO(brianwilkerson) Implement more tests for this method.
7837 AssignmentExpression expression = 7795 AssignmentExpression expression =
7838 ParserTestCase.parse4("parseExpression", "x = y"); 7796 ParserTestCase.parse4("parseExpression", "x = y");
7839 expect(expression.leftHandSide, isNotNull); 7797 expect(expression.leftHandSide, isNotNull);
7840 expect(expression.operator, isNotNull); 7798 expect(expression.operator, isNotNull);
7841 expect(expression.operator.type, TokenType.EQ); 7799 expect(expression.operator.type, TokenType.EQ);
7842 expect(expression.rightHandSide, isNotNull); 7800 expect(expression.rightHandSide, isNotNull);
7843 } 7801 }
7844 7802
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
7907 } 7865 }
7908 7866
7909 void test_parseExpression_superMethodInvocation() { 7867 void test_parseExpression_superMethodInvocation() {
7910 MethodInvocation invocation = 7868 MethodInvocation invocation =
7911 ParserTestCase.parse4("parseExpression", "super.m()"); 7869 ParserTestCase.parse4("parseExpression", "super.m()");
7912 expect(invocation.target, isNotNull); 7870 expect(invocation.target, isNotNull);
7913 expect(invocation.methodName, isNotNull); 7871 expect(invocation.methodName, isNotNull);
7914 expect(invocation.argumentList, isNotNull); 7872 expect(invocation.argumentList, isNotNull);
7915 } 7873 }
7916 7874
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
7917 void test_parseExtendsClause() { 7913 void test_parseExtendsClause() {
7918 ExtendsClause clause = 7914 ExtendsClause clause =
7919 ParserTestCase.parse4("parseExtendsClause", "extends B"); 7915 ParserTestCase.parse4("parseExtendsClause", "extends B");
7920 expect(clause.keyword, isNotNull); 7916 expect(clause.extendsKeyword, isNotNull);
7921 expect(clause.superclass, isNotNull); 7917 expect(clause.superclass, isNotNull);
7922 EngineTestCase.assertInstanceOf( 7918 EngineTestCase.assertInstanceOf(
7923 (obj) => obj is TypeName, 7919 (obj) => obj is TypeName,
7924 TypeName, 7920 TypeName,
7925 clause.superclass); 7921 clause.superclass);
7926 } 7922 }
7927 7923
7928 void test_parseFinalConstVarOrType_const_noType() { 7924 void test_parseFinalConstVarOrType_const_noType() {
7929 FinalConstVarOrType result = 7925 FinalConstVarOrType result =
7930 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "const "); 7926 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "const ");
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
7984 expect(result.type, isNotNull); 7980 expect(result.type, isNotNull);
7985 } 7981 }
7986 7982
7987 void test_parseFinalConstVarOrType_type_prefixed() { 7983 void test_parseFinalConstVarOrType_type_prefixed() {
7988 FinalConstVarOrType result = 7984 FinalConstVarOrType result =
7989 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A a "); 7985 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A a ");
7990 expect(result.keyword, isNull); 7986 expect(result.keyword, isNull);
7991 expect(result.type, isNotNull); 7987 expect(result.type, isNotNull);
7992 } 7988 }
7993 7989
7990 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() {
7991 FinalConstVarOrType result =
7992 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A," );
7993 expect(result.keyword, isNull);
7994 expect(result.type, isNotNull);
7995 }
7996
7994 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() { 7997 void test_parseFinalConstVarOrType_type_prefixedAndParameterized() {
7995 FinalConstVarOrType result = 7998 FinalConstVarOrType result =
7996 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A<B > a"); 7999 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A<B > a");
7997 expect(result.keyword, isNull); 8000 expect(result.keyword, isNull);
7998 expect(result.type, isNotNull); 8001 expect(result.type, isNotNull);
7999 } 8002 }
8000
8001 void test_parseFinalConstVarOrType_type_prefixed_noIdentifier() {
8002 FinalConstVarOrType result =
8003 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "p.A," );
8004 expect(result.keyword, isNull);
8005 expect(result.type, isNotNull);
8006 }
8007 8003
8008 void test_parseFinalConstVarOrType_type_simple() { 8004 void test_parseFinalConstVarOrType_type_simple() {
8009 FinalConstVarOrType result = 8005 FinalConstVarOrType result =
8010 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "A a") ; 8006 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "A a") ;
8011 expect(result.keyword, isNull); 8007 expect(result.keyword, isNull);
8012 expect(result.type, isNotNull); 8008 expect(result.type, isNotNull);
8013 } 8009 }
8014 8010
8015 void test_parseFinalConstVarOrType_var() { 8011 void test_parseFinalConstVarOrType_var() {
8016 FinalConstVarOrType result = 8012 FinalConstVarOrType result =
(...skipping 12 matching lines...) Expand all
8029 expect(result.type, isNotNull); 8025 expect(result.type, isNotNull);
8030 } 8026 }
8031 8027
8032 void test_parseFinalConstVarOrType_void_noIdentifier() { 8028 void test_parseFinalConstVarOrType_void_noIdentifier() {
8033 FinalConstVarOrType result = 8029 FinalConstVarOrType result =
8034 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "void, "); 8030 ParserTestCase.parse("parseFinalConstVarOrType", <Object>[false], "void, ");
8035 expect(result.keyword, isNull); 8031 expect(result.keyword, isNull);
8036 expect(result.type, isNotNull); 8032 expect(result.type, isNotNull);
8037 } 8033 }
8038 8034
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
8039 void test_parseForStatement_each_await() { 8250 void test_parseForStatement_each_await() {
8040 ForEachStatement statement = 8251 ForEachStatement statement =
8041 ParserTestCase.parse4("parseForStatement", "await for (element in list) {}"); 8252 ParserTestCase.parse4("parseForStatement", "await for (element in list) {}");
8042 expect(statement.awaitKeyword, isNotNull); 8253 expect(statement.awaitKeyword, isNotNull);
8043 expect(statement.forKeyword, isNotNull); 8254 expect(statement.forKeyword, isNotNull);
8044 expect(statement.leftParenthesis, isNotNull); 8255 expect(statement.leftParenthesis, isNotNull);
8045 expect(statement.loopVariable, isNull); 8256 expect(statement.loopVariable, isNull);
8046 expect(statement.identifier, isNotNull); 8257 expect(statement.identifier, isNotNull);
8047 expect(statement.inKeyword, isNotNull); 8258 expect(statement.inKeyword, isNotNull);
8048 expect(statement.iterable, isNotNull); 8259 expect(statement.iterable, isNotNull);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
8266 expect(statement.variables, isNull); 8477 expect(statement.variables, isNull);
8267 expect(statement.initialization, isNull); 8478 expect(statement.initialization, isNull);
8268 expect(statement.leftSeparator, isNotNull); 8479 expect(statement.leftSeparator, isNotNull);
8269 expect(statement.condition, isNull); 8480 expect(statement.condition, isNull);
8270 expect(statement.rightSeparator, isNotNull); 8481 expect(statement.rightSeparator, isNotNull);
8271 expect(statement.updaters, hasLength(1)); 8482 expect(statement.updaters, hasLength(1));
8272 expect(statement.rightParenthesis, isNotNull); 8483 expect(statement.rightParenthesis, isNotNull);
8273 expect(statement.body, isNotNull); 8484 expect(statement.body, isNotNull);
8274 } 8485 }
8275 8486
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
8491 void test_parseFunctionBody_block() { 8487 void test_parseFunctionBody_block() {
8492 BlockFunctionBody functionBody = 8488 BlockFunctionBody functionBody =
8493 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}"); 8489 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}");
8494 expect(functionBody.keyword, isNull); 8490 expect(functionBody.keyword, isNull);
8495 expect(functionBody.star, isNull); 8491 expect(functionBody.star, isNull);
8496 expect(functionBody.block, isNotNull); 8492 expect(functionBody.block, isNotNull);
8497 expect(functionBody.isAsynchronous, isFalse); 8493 expect(functionBody.isAsynchronous, isFalse);
8498 expect(functionBody.isGenerator, isFalse); 8494 expect(functionBody.isGenerator, isFalse);
8499 expect(functionBody.isSynchronous, isTrue); 8495 expect(functionBody.isSynchronous, isTrue);
8500 } 8496 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
8574 expect(functionBody.isAsynchronous, isTrue); 8570 expect(functionBody.isAsynchronous, isTrue);
8575 expect(functionBody.isGenerator, isFalse); 8571 expect(functionBody.isGenerator, isFalse);
8576 expect(functionBody.isSynchronous, isFalse); 8572 expect(functionBody.isSynchronous, isFalse);
8577 } 8573 }
8578 8574
8579 void test_parseFunctionBody_nativeFunctionBody() { 8575 void test_parseFunctionBody_nativeFunctionBody() {
8580 NativeFunctionBody functionBody = ParserTestCase.parse( 8576 NativeFunctionBody functionBody = ParserTestCase.parse(
8581 "parseFunctionBody", 8577 "parseFunctionBody",
8582 <Object>[false, null, false], 8578 <Object>[false, null, false],
8583 "native 'str';"); 8579 "native 'str';");
8584 expect(functionBody.nativeToken, isNotNull); 8580 expect(functionBody.nativeKeyword, isNotNull);
8585 expect(functionBody.stringLiteral, isNotNull); 8581 expect(functionBody.stringLiteral, isNotNull);
8586 expect(functionBody.semicolon, isNotNull); 8582 expect(functionBody.semicolon, isNotNull);
8587 } 8583 }
8588 8584
8589 void test_parseFunctionBody_skip_block() { 8585 void test_parseFunctionBody_skip_block() {
8590 ParserTestCase.parseFunctionBodies = false; 8586 ParserTestCase.parseFunctionBodies = false;
8591 FunctionBody functionBody = 8587 FunctionBody functionBody =
8592 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}"); 8588 ParserTestCase.parse("parseFunctionBody", <Object>[false, null, false], "{}");
8593 EngineTestCase.assertInstanceOf( 8589 EngineTestCase.assertInstanceOf(
8594 (obj) => obj is EmptyFunctionBody, 8590 (obj) => obj is EmptyFunctionBody,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
8626 FunctionBody functionBody = ParserTestCase.parse( 8622 FunctionBody functionBody = ParserTestCase.parse(
8627 "parseFunctionBody", 8623 "parseFunctionBody",
8628 <Object>[false, null, false], 8624 <Object>[false, null, false],
8629 "=> y;"); 8625 "=> y;");
8630 EngineTestCase.assertInstanceOf( 8626 EngineTestCase.assertInstanceOf(
8631 (obj) => obj is EmptyFunctionBody, 8627 (obj) => obj is EmptyFunctionBody,
8632 EmptyFunctionBody, 8628 EmptyFunctionBody,
8633 functionBody); 8629 functionBody);
8634 } 8630 }
8635 8631
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
8643 void test_parseFunctionDeclaration_function() { 8632 void test_parseFunctionDeclaration_function() {
8644 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8633 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8645 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 8634 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8646 FunctionDeclaration declaration = ParserTestCase.parse( 8635 FunctionDeclaration declaration = ParserTestCase.parse(
8647 "parseFunctionDeclaration", 8636 "parseFunctionDeclaration",
8648 <Object>[commentAndMetadata(comment), null, returnType], 8637 <Object>[commentAndMetadata(comment), null, returnType],
8649 "f() {}"); 8638 "f() {}");
8650 expect(declaration.documentationComment, comment); 8639 expect(declaration.documentationComment, comment);
8651 expect(declaration.returnType, returnType); 8640 expect(declaration.returnType, returnType);
8652 expect(declaration.name, isNotNull); 8641 expect(declaration.name, isNotNull);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
8684 expect(declaration.documentationComment, comment); 8673 expect(declaration.documentationComment, comment);
8685 expect(declaration.returnType, returnType); 8674 expect(declaration.returnType, returnType);
8686 expect(declaration.name, isNotNull); 8675 expect(declaration.name, isNotNull);
8687 FunctionExpression expression = declaration.functionExpression; 8676 FunctionExpression expression = declaration.functionExpression;
8688 expect(expression, isNotNull); 8677 expect(expression, isNotNull);
8689 expect(expression.body, isNotNull); 8678 expect(expression.body, isNotNull);
8690 expect(expression.parameters, isNotNull); 8679 expect(expression.parameters, isNotNull);
8691 expect(declaration.propertyKeyword, isNotNull); 8680 expect(declaration.propertyKeyword, isNotNull);
8692 } 8681 }
8693 8682
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
8694 void test_parseFunctionExpression_body_inExpression() { 8690 void test_parseFunctionExpression_body_inExpression() {
8695 FunctionExpression expression = 8691 FunctionExpression expression =
8696 ParserTestCase.parse4("parseFunctionExpression", "(int i) => i++"); 8692 ParserTestCase.parse4("parseFunctionExpression", "(int i) => i++");
8697 expect(expression.body, isNotNull); 8693 expect(expression.body, isNotNull);
8698 expect(expression.parameters, isNotNull); 8694 expect(expression.parameters, isNotNull);
8699 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 8695 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8700 } 8696 }
8701 8697
8702 void test_parseGetter_nonStatic() { 8698 void test_parseGetter_nonStatic() {
8703 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8699 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
8793 expect(statement.rightParenthesis, isNotNull); 8789 expect(statement.rightParenthesis, isNotNull);
8794 expect(statement.thenStatement, isNotNull); 8790 expect(statement.thenStatement, isNotNull);
8795 expect(statement.elseKeyword, isNull); 8791 expect(statement.elseKeyword, isNull);
8796 expect(statement.elseStatement, isNull); 8792 expect(statement.elseStatement, isNull);
8797 } 8793 }
8798 8794
8799 void test_parseImplementsClause_multiple() { 8795 void test_parseImplementsClause_multiple() {
8800 ImplementsClause clause = 8796 ImplementsClause clause =
8801 ParserTestCase.parse4("parseImplementsClause", "implements A, B, C"); 8797 ParserTestCase.parse4("parseImplementsClause", "implements A, B, C");
8802 expect(clause.interfaces, hasLength(3)); 8798 expect(clause.interfaces, hasLength(3));
8803 expect(clause.keyword, isNotNull); 8799 expect(clause.implementsKeyword, isNotNull);
8804 } 8800 }
8805 8801
8806 void test_parseImplementsClause_single() { 8802 void test_parseImplementsClause_single() {
8807 ImplementsClause clause = 8803 ImplementsClause clause =
8808 ParserTestCase.parse4("parseImplementsClause", "implements A"); 8804 ParserTestCase.parse4("parseImplementsClause", "implements A");
8809 expect(clause.interfaces, hasLength(1)); 8805 expect(clause.interfaces, hasLength(1));
8810 expect(clause.keyword, isNotNull); 8806 expect(clause.implementsKeyword, isNotNull);
8811 } 8807 }
8812 8808
8813 void test_parseImportDirective_deferred() { 8809 void test_parseImportDirective_deferred() {
8814 ImportDirective directive = ParserTestCase.parse( 8810 ImportDirective directive = ParserTestCase.parse(
8815 "parseImportDirective", 8811 "parseImportDirective",
8816 <Object>[emptyCommentAndMetadata()], 8812 <Object>[emptyCommentAndMetadata()],
8817 "import 'lib/lib.dart' deferred as a;"); 8813 "import 'lib/lib.dart' deferred as a;");
8818 expect(directive.keyword, isNotNull); 8814 expect(directive.keyword, isNotNull);
8819 expect(directive.uri, isNotNull); 8815 expect(directive.uri, isNotNull);
8820 expect(directive.deferredToken, isNotNull); 8816 expect(directive.deferredKeyword, isNotNull);
8821 expect(directive.asToken, isNotNull); 8817 expect(directive.asKeyword, isNotNull);
8822 expect(directive.prefix, isNotNull); 8818 expect(directive.prefix, isNotNull);
8823 expect(directive.combinators, hasLength(0)); 8819 expect(directive.combinators, hasLength(0));
8824 expect(directive.semicolon, isNotNull); 8820 expect(directive.semicolon, isNotNull);
8825 } 8821 }
8826 8822
8827 void test_parseImportDirective_hide() { 8823 void test_parseImportDirective_hide() {
8828 ImportDirective directive = ParserTestCase.parse( 8824 ImportDirective directive = ParserTestCase.parse(
8829 "parseImportDirective", 8825 "parseImportDirective",
8830 <Object>[emptyCommentAndMetadata()], 8826 <Object>[emptyCommentAndMetadata()],
8831 "import 'lib/lib.dart' hide A, B;"); 8827 "import 'lib/lib.dart' hide A, B;");
8832 expect(directive.keyword, isNotNull); 8828 expect(directive.keyword, isNotNull);
8833 expect(directive.uri, isNotNull); 8829 expect(directive.uri, isNotNull);
8834 expect(directive.deferredToken, isNull); 8830 expect(directive.deferredKeyword, isNull);
8835 expect(directive.asToken, isNull); 8831 expect(directive.asKeyword, isNull);
8836 expect(directive.prefix, isNull); 8832 expect(directive.prefix, isNull);
8837 expect(directive.combinators, hasLength(1)); 8833 expect(directive.combinators, hasLength(1));
8838 expect(directive.semicolon, isNotNull); 8834 expect(directive.semicolon, isNotNull);
8839 } 8835 }
8840 8836
8841 void test_parseImportDirective_noCombinator() { 8837 void test_parseImportDirective_noCombinator() {
8842 ImportDirective directive = ParserTestCase.parse( 8838 ImportDirective directive = ParserTestCase.parse(
8843 "parseImportDirective", 8839 "parseImportDirective",
8844 <Object>[emptyCommentAndMetadata()], 8840 <Object>[emptyCommentAndMetadata()],
8845 "import 'lib/lib.dart';"); 8841 "import 'lib/lib.dart';");
8846 expect(directive.keyword, isNotNull); 8842 expect(directive.keyword, isNotNull);
8847 expect(directive.uri, isNotNull); 8843 expect(directive.uri, isNotNull);
8848 expect(directive.deferredToken, isNull); 8844 expect(directive.deferredKeyword, isNull);
8849 expect(directive.asToken, isNull); 8845 expect(directive.asKeyword, isNull);
8850 expect(directive.prefix, isNull); 8846 expect(directive.prefix, isNull);
8851 expect(directive.combinators, hasLength(0)); 8847 expect(directive.combinators, hasLength(0));
8852 expect(directive.semicolon, isNotNull); 8848 expect(directive.semicolon, isNotNull);
8853 } 8849 }
8854 8850
8855 void test_parseImportDirective_prefix() { 8851 void test_parseImportDirective_prefix() {
8856 ImportDirective directive = ParserTestCase.parse( 8852 ImportDirective directive = ParserTestCase.parse(
8857 "parseImportDirective", 8853 "parseImportDirective",
8858 <Object>[emptyCommentAndMetadata()], 8854 <Object>[emptyCommentAndMetadata()],
8859 "import 'lib/lib.dart' as a;"); 8855 "import 'lib/lib.dart' as a;");
8860 expect(directive.keyword, isNotNull); 8856 expect(directive.keyword, isNotNull);
8861 expect(directive.uri, isNotNull); 8857 expect(directive.uri, isNotNull);
8862 expect(directive.deferredToken, isNull); 8858 expect(directive.deferredKeyword, isNull);
8863 expect(directive.asToken, isNotNull); 8859 expect(directive.asKeyword, isNotNull);
8864 expect(directive.prefix, isNotNull); 8860 expect(directive.prefix, isNotNull);
8865 expect(directive.combinators, hasLength(0)); 8861 expect(directive.combinators, hasLength(0));
8866 expect(directive.semicolon, isNotNull); 8862 expect(directive.semicolon, isNotNull);
8867 } 8863 }
8868 8864
8869 void test_parseImportDirective_prefix_hide_show() { 8865 void test_parseImportDirective_prefix_hide_show() {
8870 ImportDirective directive = ParserTestCase.parse( 8866 ImportDirective directive = ParserTestCase.parse(
8871 "parseImportDirective", 8867 "parseImportDirective",
8872 <Object>[emptyCommentAndMetadata()], 8868 <Object>[emptyCommentAndMetadata()],
8873 "import 'lib/lib.dart' as a hide A show B;"); 8869 "import 'lib/lib.dart' as a hide A show B;");
8874 expect(directive.keyword, isNotNull); 8870 expect(directive.keyword, isNotNull);
8875 expect(directive.uri, isNotNull); 8871 expect(directive.uri, isNotNull);
8876 expect(directive.deferredToken, isNull); 8872 expect(directive.deferredKeyword, isNull);
8877 expect(directive.asToken, isNotNull); 8873 expect(directive.asKeyword, isNotNull);
8878 expect(directive.prefix, isNotNull); 8874 expect(directive.prefix, isNotNull);
8879 expect(directive.combinators, hasLength(2)); 8875 expect(directive.combinators, hasLength(2));
8880 expect(directive.semicolon, isNotNull); 8876 expect(directive.semicolon, isNotNull);
8881 } 8877 }
8882 8878
8883 void test_parseImportDirective_prefix_show_hide() { 8879 void test_parseImportDirective_prefix_show_hide() {
8884 ImportDirective directive = ParserTestCase.parse( 8880 ImportDirective directive = ParserTestCase.parse(
8885 "parseImportDirective", 8881 "parseImportDirective",
8886 <Object>[emptyCommentAndMetadata()], 8882 <Object>[emptyCommentAndMetadata()],
8887 "import 'lib/lib.dart' as a show B hide A;"); 8883 "import 'lib/lib.dart' as a show B hide A;");
8888 expect(directive.keyword, isNotNull); 8884 expect(directive.keyword, isNotNull);
8889 expect(directive.uri, isNotNull); 8885 expect(directive.uri, isNotNull);
8890 expect(directive.deferredToken, isNull); 8886 expect(directive.deferredKeyword, isNull);
8891 expect(directive.asToken, isNotNull); 8887 expect(directive.asKeyword, isNotNull);
8892 expect(directive.prefix, isNotNull); 8888 expect(directive.prefix, isNotNull);
8893 expect(directive.combinators, hasLength(2)); 8889 expect(directive.combinators, hasLength(2));
8894 expect(directive.semicolon, isNotNull); 8890 expect(directive.semicolon, isNotNull);
8895 } 8891 }
8896 8892
8897 void test_parseImportDirective_show() { 8893 void test_parseImportDirective_show() {
8898 ImportDirective directive = ParserTestCase.parse( 8894 ImportDirective directive = ParserTestCase.parse(
8899 "parseImportDirective", 8895 "parseImportDirective",
8900 <Object>[emptyCommentAndMetadata()], 8896 <Object>[emptyCommentAndMetadata()],
8901 "import 'lib/lib.dart' show A, B;"); 8897 "import 'lib/lib.dart' show A, B;");
8902 expect(directive.keyword, isNotNull); 8898 expect(directive.keyword, isNotNull);
8903 expect(directive.uri, isNotNull); 8899 expect(directive.uri, isNotNull);
8904 expect(directive.deferredToken, isNull); 8900 expect(directive.deferredKeyword, isNull);
8905 expect(directive.asToken, isNull); 8901 expect(directive.asKeyword, isNull);
8906 expect(directive.prefix, isNull); 8902 expect(directive.prefix, isNull);
8907 expect(directive.combinators, hasLength(1)); 8903 expect(directive.combinators, hasLength(1));
8908 expect(directive.semicolon, isNotNull); 8904 expect(directive.semicolon, isNotNull);
8909 } 8905 }
8910 8906
8911 void test_parseInitializedIdentifierList_type() { 8907 void test_parseInitializedIdentifierList_type() {
8912 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8908 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8913 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); 8909 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC);
8914 TypeName type = new TypeName(new SimpleIdentifier(null), null); 8910 TypeName type = new TypeName(new SimpleIdentifier(null), null);
8915 FieldDeclaration declaration = ParserTestCase.parse( 8911 FieldDeclaration declaration = ParserTestCase.parse(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
9002 expect(name.period, isNotNull); 8998 expect(name.period, isNotNull);
9003 expect(name.name, isNotNull); 8999 expect(name.name, isNotNull);
9004 expect(expression.argumentList, isNotNull); 9000 expect(expression.argumentList, isNotNull);
9005 } 9001 }
9006 9002
9007 void test_parseLibraryDirective() { 9003 void test_parseLibraryDirective() {
9008 LibraryDirective directive = ParserTestCase.parse( 9004 LibraryDirective directive = ParserTestCase.parse(
9009 "parseLibraryDirective", 9005 "parseLibraryDirective",
9010 <Object>[emptyCommentAndMetadata()], 9006 <Object>[emptyCommentAndMetadata()],
9011 "library l;"); 9007 "library l;");
9012 expect(directive.libraryToken, isNotNull); 9008 expect(directive.libraryKeyword, isNotNull);
9013 expect(directive.name, isNotNull); 9009 expect(directive.name, isNotNull);
9014 expect(directive.semicolon, isNotNull); 9010 expect(directive.semicolon, isNotNull);
9015 } 9011 }
9016 9012
9017 void test_parseLibraryIdentifier_multiple() { 9013 void test_parseLibraryIdentifier_multiple() {
9018 String name = "a.b.c"; 9014 String name = "a.b.c";
9019 LibraryIdentifier identifier = 9015 LibraryIdentifier identifier =
9020 ParserTestCase.parse4("parseLibraryIdentifier", name); 9016 ParserTestCase.parse4("parseLibraryIdentifier", name);
9021 expect(identifier.name, name); 9017 expect(identifier.name, name);
9022 } 9018 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
9143 9139
9144 void test_parseLogicalOrExpression() { 9140 void test_parseLogicalOrExpression() {
9145 BinaryExpression expression = 9141 BinaryExpression expression =
9146 ParserTestCase.parse4("parseLogicalOrExpression", "x || y"); 9142 ParserTestCase.parse4("parseLogicalOrExpression", "x || y");
9147 expect(expression.leftOperand, isNotNull); 9143 expect(expression.leftOperand, isNotNull);
9148 expect(expression.operator, isNotNull); 9144 expect(expression.operator, isNotNull);
9149 expect(expression.operator.type, TokenType.BAR_BAR); 9145 expect(expression.operator.type, TokenType.BAR_BAR);
9150 expect(expression.rightOperand, isNotNull); 9146 expect(expression.rightOperand, isNotNull);
9151 } 9147 }
9152 9148
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
9177 void test_parseMapLiteral_empty() { 9149 void test_parseMapLiteral_empty() {
9178 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST); 9150 Token token = TokenFactory.tokenFromKeyword(Keyword.CONST);
9179 TypeArgumentList typeArguments = AstFactory.typeArgumentList( 9151 TypeArgumentList typeArguments = AstFactory.typeArgumentList(
9180 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]); 9152 [AstFactory.typeName4("String"), AstFactory.typeName4("int")]);
9181 MapLiteral literal = 9153 MapLiteral literal =
9182 ParserTestCase.parse("parseMapLiteral", <Object>[token, typeArguments], "{}"); 9154 ParserTestCase.parse("parseMapLiteral", <Object>[token, typeArguments], "{}");
9183 expect(literal.constKeyword, token); 9155 expect(literal.constKeyword, token);
9184 expect(literal.typeArguments, typeArguments); 9156 expect(literal.typeArguments, typeArguments);
9185 expect(literal.leftBracket, isNotNull); 9157 expect(literal.leftBracket, isNotNull);
9186 expect(literal.entries, hasLength(0)); 9158 expect(literal.entries, hasLength(0));
(...skipping 11 matching lines...) Expand all
9198 } 9170 }
9199 9171
9200 void test_parseMapLiteral_single() { 9172 void test_parseMapLiteral_single() {
9201 MapLiteral literal = 9173 MapLiteral literal =
9202 ParserTestCase.parse("parseMapLiteral", <Object>[null, null], "{'x' : y} "); 9174 ParserTestCase.parse("parseMapLiteral", <Object>[null, null], "{'x' : y} ");
9203 expect(literal.leftBracket, isNotNull); 9175 expect(literal.leftBracket, isNotNull);
9204 expect(literal.entries, hasLength(1)); 9176 expect(literal.entries, hasLength(1));
9205 expect(literal.rightBracket, isNotNull); 9177 expect(literal.rightBracket, isNotNull);
9206 } 9178 }
9207 9179
9180 void test_parseMapLiteralEntry_complex() {
9181 MapLiteralEntry entry =
9182 ParserTestCase.parse4("parseMapLiteralEntry", "2 + 2 : y");
9183 expect(entry.key, isNotNull);
9184 expect(entry.separator, isNotNull);
9185 expect(entry.value, isNotNull);
9186 }
9187
9188 void test_parseMapLiteralEntry_int() {
9189 MapLiteralEntry entry =
9190 ParserTestCase.parse4("parseMapLiteralEntry", "0 : y");
9191 expect(entry.key, isNotNull);
9192 expect(entry.separator, isNotNull);
9193 expect(entry.value, isNotNull);
9194 }
9195
9196 void test_parseMapLiteralEntry_string() {
9197 MapLiteralEntry entry =
9198 ParserTestCase.parse4("parseMapLiteralEntry", "'x' : y");
9199 expect(entry.key, isNotNull);
9200 expect(entry.separator, isNotNull);
9201 expect(entry.value, isNotNull);
9202 }
9203
9208 void test_parseModifiers_abstract() { 9204 void test_parseModifiers_abstract() {
9209 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "abstract A"); 9205 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "abstract A");
9210 expect(modifiers.abstractKeyword, isNotNull); 9206 expect(modifiers.abstractKeyword, isNotNull);
9211 } 9207 }
9212 9208
9213 void test_parseModifiers_const() { 9209 void test_parseModifiers_const() {
9214 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "const A"); 9210 Modifiers modifiers = ParserTestCase.parse4("parseModifiers", "const A");
9215 expect(modifiers.constKeyword, isNotNull); 9211 expect(modifiers.constKeyword, isNotNull);
9216 } 9212 }
9217 9213
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
9562 9558
9563 void test_parseOptionalReturnType() { 9559 void test_parseOptionalReturnType() {
9564 // TODO(brianwilkerson) Implement tests for this method. 9560 // TODO(brianwilkerson) Implement tests for this method.
9565 } 9561 }
9566 9562
9567 void test_parsePartDirective_part() { 9563 void test_parsePartDirective_part() {
9568 PartDirective directive = ParserTestCase.parse( 9564 PartDirective directive = ParserTestCase.parse(
9569 "parsePartDirective", 9565 "parsePartDirective",
9570 <Object>[emptyCommentAndMetadata()], 9566 <Object>[emptyCommentAndMetadata()],
9571 "part 'lib/lib.dart';"); 9567 "part 'lib/lib.dart';");
9572 expect(directive.partToken, isNotNull); 9568 expect(directive.partKeyword, isNotNull);
9573 expect(directive.uri, isNotNull); 9569 expect(directive.uri, isNotNull);
9574 expect(directive.semicolon, isNotNull); 9570 expect(directive.semicolon, isNotNull);
9575 } 9571 }
9576 9572
9577 void test_parsePartDirective_partOf() { 9573 void test_parsePartDirective_partOf() {
9578 PartOfDirective directive = ParserTestCase.parse( 9574 PartOfDirective directive = ParserTestCase.parse(
9579 "parsePartDirective", 9575 "parsePartDirective",
9580 <Object>[emptyCommentAndMetadata()], 9576 <Object>[emptyCommentAndMetadata()],
9581 "part of l;"); 9577 "part of l;");
9582 expect(directive.partToken, isNotNull); 9578 expect(directive.partKeyword, isNotNull);
9583 expect(directive.ofToken, isNotNull); 9579 expect(directive.ofKeyword, isNotNull);
9584 expect(directive.libraryName, isNotNull); 9580 expect(directive.libraryName, isNotNull);
9585 expect(directive.semicolon, isNotNull); 9581 expect(directive.semicolon, isNotNull);
9586 } 9582 }
9587 9583
9588 void test_parsePostfixExpression_decrement() { 9584 void test_parsePostfixExpression_decrement() {
9589 PostfixExpression expression = 9585 PostfixExpression expression =
9590 ParserTestCase.parse4("parsePostfixExpression", "i--"); 9586 ParserTestCase.parse4("parsePostfixExpression", "i--");
9591 expect(expression.operand, isNotNull); 9587 expect(expression.operand, isNotNull);
9592 expect(expression.operator, isNotNull); 9588 expect(expression.operator, isNotNull);
9593 expect(expression.operator.type, TokenType.MINUS_MINUS); 9589 expect(expression.operator.type, TokenType.MINUS_MINUS);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
9774 ParserTestCase.parse4("parsePrimaryExpression", "super.x"); 9770 ParserTestCase.parse4("parsePrimaryExpression", "super.x");
9775 expect(propertyAccess.target is SuperExpression, isTrue); 9771 expect(propertyAccess.target is SuperExpression, isTrue);
9776 expect(propertyAccess.operator, isNotNull); 9772 expect(propertyAccess.operator, isNotNull);
9777 expect(propertyAccess.operator.type, TokenType.PERIOD); 9773 expect(propertyAccess.operator.type, TokenType.PERIOD);
9778 expect(propertyAccess.propertyName, isNotNull); 9774 expect(propertyAccess.propertyName, isNotNull);
9779 } 9775 }
9780 9776
9781 void test_parsePrimaryExpression_this() { 9777 void test_parsePrimaryExpression_this() {
9782 ThisExpression expression = 9778 ThisExpression expression =
9783 ParserTestCase.parse4("parsePrimaryExpression", "this"); 9779 ParserTestCase.parse4("parsePrimaryExpression", "this");
9784 expect(expression.keyword, isNotNull); 9780 expect(expression.thisKeyword, isNotNull);
9785 } 9781 }
9786 9782
9787 void test_parsePrimaryExpression_true() { 9783 void test_parsePrimaryExpression_true() {
9788 BooleanLiteral literal = 9784 BooleanLiteral literal =
9789 ParserTestCase.parse4("parsePrimaryExpression", "true"); 9785 ParserTestCase.parse4("parsePrimaryExpression", "true");
9790 expect(literal.literal, isNotNull); 9786 expect(literal.literal, isNotNull);
9791 expect(literal.value, isTrue); 9787 expect(literal.value, isTrue);
9792 } 9788 }
9793 9789
9790 void test_Parser() {
9791 expect(new Parser(null, null), isNotNull);
9792 }
9793
9794 void test_parseRedirectingConstructorInvocation_named() { 9794 void test_parseRedirectingConstructorInvocation_named() {
9795 RedirectingConstructorInvocation invocation = 9795 RedirectingConstructorInvocation invocation =
9796 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this.a() "); 9796 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this.a() ");
9797 expect(invocation.argumentList, isNotNull); 9797 expect(invocation.argumentList, isNotNull);
9798 expect(invocation.constructorName, isNotNull); 9798 expect(invocation.constructorName, isNotNull);
9799 expect(invocation.keyword, isNotNull); 9799 expect(invocation.thisKeyword, isNotNull);
9800 expect(invocation.period, isNotNull); 9800 expect(invocation.period, isNotNull);
9801 } 9801 }
9802 9802
9803 void test_parseRedirectingConstructorInvocation_unnamed() { 9803 void test_parseRedirectingConstructorInvocation_unnamed() {
9804 RedirectingConstructorInvocation invocation = 9804 RedirectingConstructorInvocation invocation =
9805 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this()") ; 9805 ParserTestCase.parse4("parseRedirectingConstructorInvocation", "this()") ;
9806 expect(invocation.argumentList, isNotNull); 9806 expect(invocation.argumentList, isNotNull);
9807 expect(invocation.constructorName, isNull); 9807 expect(invocation.constructorName, isNull);
9808 expect(invocation.keyword, isNotNull); 9808 expect(invocation.thisKeyword, isNotNull);
9809 expect(invocation.period, isNull); 9809 expect(invocation.period, isNull);
9810 } 9810 }
9811 9811
9812 void test_parseRelationalExpression_as() { 9812 void test_parseRelationalExpression_as() {
9813 AsExpression expression = 9813 AsExpression expression =
9814 ParserTestCase.parse4("parseRelationalExpression", "x as Y"); 9814 ParserTestCase.parse4("parseRelationalExpression", "x as Y");
9815 expect(expression.expression, isNotNull); 9815 expect(expression.expression, isNotNull);
9816 expect(expression.asOperator, isNotNull); 9816 expect(expression.asOperator, isNotNull);
9817 expect(expression.type, isNotNull); 9817 expect(expression.type, isNotNull);
9818 } 9818 }
(...skipping 30 matching lines...) Expand all
9849 ParserTestCase.parse4("parseRelationalExpression", "super < y"); 9849 ParserTestCase.parse4("parseRelationalExpression", "super < y");
9850 expect(expression.leftOperand, isNotNull); 9850 expect(expression.leftOperand, isNotNull);
9851 expect(expression.operator, isNotNull); 9851 expect(expression.operator, isNotNull);
9852 expect(expression.operator.type, TokenType.LT); 9852 expect(expression.operator.type, TokenType.LT);
9853 expect(expression.rightOperand, isNotNull); 9853 expect(expression.rightOperand, isNotNull);
9854 } 9854 }
9855 9855
9856 void test_parseRethrowExpression() { 9856 void test_parseRethrowExpression() {
9857 RethrowExpression expression = 9857 RethrowExpression expression =
9858 ParserTestCase.parse4("parseRethrowExpression", "rethrow;"); 9858 ParserTestCase.parse4("parseRethrowExpression", "rethrow;");
9859 expect(expression.keyword, isNotNull); 9859 expect(expression.rethrowKeyword, isNotNull);
9860 } 9860 }
9861 9861
9862 void test_parseReturnStatement_noValue() { 9862 void test_parseReturnStatement_noValue() {
9863 ReturnStatement statement = 9863 ReturnStatement statement =
9864 ParserTestCase.parse4("parseReturnStatement", "return;"); 9864 ParserTestCase.parse4("parseReturnStatement", "return;");
9865 expect(statement.keyword, isNotNull); 9865 expect(statement.returnKeyword, isNotNull);
9866 expect(statement.expression, isNull); 9866 expect(statement.expression, isNull);
9867 expect(statement.semicolon, isNotNull); 9867 expect(statement.semicolon, isNotNull);
9868 } 9868 }
9869 9869
9870 void test_parseReturnStatement_value() { 9870 void test_parseReturnStatement_value() {
9871 ReturnStatement statement = 9871 ReturnStatement statement =
9872 ParserTestCase.parse4("parseReturnStatement", "return x;"); 9872 ParserTestCase.parse4("parseReturnStatement", "return x;");
9873 expect(statement.keyword, isNotNull); 9873 expect(statement.returnKeyword, isNotNull);
9874 expect(statement.expression, isNotNull); 9874 expect(statement.expression, isNotNull);
9875 expect(statement.semicolon, isNotNull); 9875 expect(statement.semicolon, isNotNull);
9876 } 9876 }
9877 9877
9878 void test_parseReturnType_nonVoid() { 9878 void test_parseReturnType_nonVoid() {
9879 TypeName typeName = ParserTestCase.parse4("parseReturnType", "A<B>"); 9879 TypeName typeName = ParserTestCase.parse4("parseReturnType", "A<B>");
9880 expect(typeName.name, isNotNull); 9880 expect(typeName.name, isNotNull);
9881 expect(typeName.typeArguments, isNotNull); 9881 expect(typeName.typeArguments, isNotNull);
9882 } 9882 }
9883 9883
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
10026 ParserTestCase.parse4("parseStringLiteral", "'a'"); 10026 ParserTestCase.parse4("parseStringLiteral", "'a'");
10027 expect(literal.literal, isNotNull); 10027 expect(literal.literal, isNotNull);
10028 expect(literal.value, "a"); 10028 expect(literal.value, "a");
10029 } 10029 }
10030 10030
10031 void test_parseSuperConstructorInvocation_named() { 10031 void test_parseSuperConstructorInvocation_named() {
10032 SuperConstructorInvocation invocation = 10032 SuperConstructorInvocation invocation =
10033 ParserTestCase.parse4("parseSuperConstructorInvocation", "super.a()"); 10033 ParserTestCase.parse4("parseSuperConstructorInvocation", "super.a()");
10034 expect(invocation.argumentList, isNotNull); 10034 expect(invocation.argumentList, isNotNull);
10035 expect(invocation.constructorName, isNotNull); 10035 expect(invocation.constructorName, isNotNull);
10036 expect(invocation.keyword, isNotNull); 10036 expect(invocation.superKeyword, isNotNull);
10037 expect(invocation.period, isNotNull); 10037 expect(invocation.period, isNotNull);
10038 } 10038 }
10039 10039
10040 void test_parseSuperConstructorInvocation_unnamed() { 10040 void test_parseSuperConstructorInvocation_unnamed() {
10041 SuperConstructorInvocation invocation = 10041 SuperConstructorInvocation invocation =
10042 ParserTestCase.parse4("parseSuperConstructorInvocation", "super()"); 10042 ParserTestCase.parse4("parseSuperConstructorInvocation", "super()");
10043 expect(invocation.argumentList, isNotNull); 10043 expect(invocation.argumentList, isNotNull);
10044 expect(invocation.constructorName, isNull); 10044 expect(invocation.constructorName, isNull);
10045 expect(invocation.keyword, isNotNull); 10045 expect(invocation.superKeyword, isNotNull);
10046 expect(invocation.period, isNull); 10046 expect(invocation.period, isNull);
10047 } 10047 }
10048 10048
10049 void test_parseSwitchStatement_case() { 10049 void test_parseSwitchStatement_case() {
10050 SwitchStatement statement = ParserTestCase.parse4( 10050 SwitchStatement statement = ParserTestCase.parse4(
10051 "parseSwitchStatement", 10051 "parseSwitchStatement",
10052 "switch (a) {case 1: return 'I';}"); 10052 "switch (a) {case 1: return 'I';}");
10053 expect(statement.keyword, isNotNull); 10053 expect(statement.switchKeyword, isNotNull);
10054 expect(statement.leftParenthesis, isNotNull); 10054 expect(statement.leftParenthesis, isNotNull);
10055 expect(statement.expression, isNotNull); 10055 expect(statement.expression, isNotNull);
10056 expect(statement.rightParenthesis, isNotNull); 10056 expect(statement.rightParenthesis, isNotNull);
10057 expect(statement.leftBracket, isNotNull); 10057 expect(statement.leftBracket, isNotNull);
10058 expect(statement.members, hasLength(1)); 10058 expect(statement.members, hasLength(1));
10059 expect(statement.rightBracket, isNotNull); 10059 expect(statement.rightBracket, isNotNull);
10060 } 10060 }
10061 10061
10062 void test_parseSwitchStatement_empty() { 10062 void test_parseSwitchStatement_empty() {
10063 SwitchStatement statement = 10063 SwitchStatement statement =
10064 ParserTestCase.parse4("parseSwitchStatement", "switch (a) {}"); 10064 ParserTestCase.parse4("parseSwitchStatement", "switch (a) {}");
10065 expect(statement.keyword, isNotNull); 10065 expect(statement.switchKeyword, isNotNull);
10066 expect(statement.leftParenthesis, isNotNull); 10066 expect(statement.leftParenthesis, isNotNull);
10067 expect(statement.expression, isNotNull); 10067 expect(statement.expression, isNotNull);
10068 expect(statement.rightParenthesis, isNotNull); 10068 expect(statement.rightParenthesis, isNotNull);
10069 expect(statement.leftBracket, isNotNull); 10069 expect(statement.leftBracket, isNotNull);
10070 expect(statement.members, hasLength(0)); 10070 expect(statement.members, hasLength(0));
10071 expect(statement.rightBracket, isNotNull); 10071 expect(statement.rightBracket, isNotNull);
10072 } 10072 }
10073 10073
10074 void test_parseSwitchStatement_labeledCase() { 10074 void test_parseSwitchStatement_labeledCase() {
10075 SwitchStatement statement = ParserTestCase.parse4( 10075 SwitchStatement statement = ParserTestCase.parse4(
10076 "parseSwitchStatement", 10076 "parseSwitchStatement",
10077 "switch (a) {l1: l2: l3: case(1):}"); 10077 "switch (a) {l1: l2: l3: case(1):}");
10078 expect(statement.keyword, isNotNull); 10078 expect(statement.switchKeyword, isNotNull);
10079 expect(statement.leftParenthesis, isNotNull); 10079 expect(statement.leftParenthesis, isNotNull);
10080 expect(statement.expression, isNotNull); 10080 expect(statement.expression, isNotNull);
10081 expect(statement.rightParenthesis, isNotNull); 10081 expect(statement.rightParenthesis, isNotNull);
10082 expect(statement.leftBracket, isNotNull); 10082 expect(statement.leftBracket, isNotNull);
10083 expect(statement.members, hasLength(1)); 10083 expect(statement.members, hasLength(1));
10084 expect(statement.members[0].labels, hasLength(3)); 10084 expect(statement.members[0].labels, hasLength(3));
10085 expect(statement.rightBracket, isNotNull); 10085 expect(statement.rightBracket, isNotNull);
10086 } 10086 }
10087 10087
10088 void test_parseSwitchStatement_labeledStatementInCase() { 10088 void test_parseSwitchStatement_labeledStatementInCase() {
10089 SwitchStatement statement = ParserTestCase.parse4( 10089 SwitchStatement statement = ParserTestCase.parse4(
10090 "parseSwitchStatement", 10090 "parseSwitchStatement",
10091 "switch (a) {case 0: f(); l1: g(); break;}"); 10091 "switch (a) {case 0: f(); l1: g(); break;}");
10092 expect(statement.keyword, isNotNull); 10092 expect(statement.switchKeyword, isNotNull);
10093 expect(statement.leftParenthesis, isNotNull); 10093 expect(statement.leftParenthesis, isNotNull);
10094 expect(statement.expression, isNotNull); 10094 expect(statement.expression, isNotNull);
10095 expect(statement.rightParenthesis, isNotNull); 10095 expect(statement.rightParenthesis, isNotNull);
10096 expect(statement.leftBracket, isNotNull); 10096 expect(statement.leftBracket, isNotNull);
10097 expect(statement.members, hasLength(1)); 10097 expect(statement.members, hasLength(1));
10098 expect(statement.members[0].statements, hasLength(3)); 10098 expect(statement.members[0].statements, hasLength(3));
10099 expect(statement.rightBracket, isNotNull); 10099 expect(statement.rightBracket, isNotNull);
10100 } 10100 }
10101 10101
10102 void test_parseSymbolLiteral_builtInIdentifier() { 10102 void test_parseSymbolLiteral_builtInIdentifier() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
10142 ParserTestCase.parse4("parseSymbolLiteral", "#void"); 10142 ParserTestCase.parse4("parseSymbolLiteral", "#void");
10143 expect(literal.poundSign, isNotNull); 10143 expect(literal.poundSign, isNotNull);
10144 List<Token> components = literal.components; 10144 List<Token> components = literal.components;
10145 expect(components, hasLength(1)); 10145 expect(components, hasLength(1));
10146 expect(components[0].lexeme, "void"); 10146 expect(components[0].lexeme, "void");
10147 } 10147 }
10148 10148
10149 void test_parseThrowExpression() { 10149 void test_parseThrowExpression() {
10150 ThrowExpression expression = 10150 ThrowExpression expression =
10151 ParserTestCase.parse4("parseThrowExpression", "throw x;"); 10151 ParserTestCase.parse4("parseThrowExpression", "throw x;");
10152 expect(expression.keyword, isNotNull); 10152 expect(expression.throwKeyword, isNotNull);
10153 expect(expression.expression, isNotNull); 10153 expect(expression.expression, isNotNull);
10154 } 10154 }
10155 10155
10156 void test_parseThrowExpressionWithoutCascade() { 10156 void test_parseThrowExpressionWithoutCascade() {
10157 ThrowExpression expression = 10157 ThrowExpression expression =
10158 ParserTestCase.parse4("parseThrowExpressionWithoutCascade", "throw x;"); 10158 ParserTestCase.parse4("parseThrowExpressionWithoutCascade", "throw x;");
10159 expect(expression.keyword, isNotNull); 10159 expect(expression.throwKeyword, isNotNull);
10160 expect(expression.expression, isNotNull); 10160 expect(expression.expression, isNotNull);
10161 } 10161 }
10162 10162
10163 void test_parseTryStatement_catch() { 10163 void test_parseTryStatement_catch() {
10164 TryStatement statement = 10164 TryStatement statement =
10165 ParserTestCase.parse4("parseTryStatement", "try {} catch (e) {}"); 10165 ParserTestCase.parse4("parseTryStatement", "try {} catch (e) {}");
10166 expect(statement.tryKeyword, isNotNull); 10166 expect(statement.tryKeyword, isNotNull);
10167 expect(statement.body, isNotNull); 10167 expect(statement.body, isNotNull);
10168 NodeList<CatchClause> catchClauses = statement.catchClauses; 10168 NodeList<CatchClause> catchClauses = statement.catchClauses;
10169 expect(catchClauses, hasLength(1)); 10169 expect(catchClauses, hasLength(1));
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
10276 expect(clause.body, isNotNull); 10276 expect(clause.body, isNotNull);
10277 expect(statement.finallyKeyword, isNotNull); 10277 expect(statement.finallyKeyword, isNotNull);
10278 expect(statement.finallyBlock, isNotNull); 10278 expect(statement.finallyBlock, isNotNull);
10279 } 10279 }
10280 10280
10281 void test_parseTypeAlias_function_noParameters() { 10281 void test_parseTypeAlias_function_noParameters() {
10282 FunctionTypeAlias typeAlias = ParserTestCase.parse( 10282 FunctionTypeAlias typeAlias = ParserTestCase.parse(
10283 "parseTypeAlias", 10283 "parseTypeAlias",
10284 <Object>[emptyCommentAndMetadata()], 10284 <Object>[emptyCommentAndMetadata()],
10285 "typedef bool F();"); 10285 "typedef bool F();");
10286 expect(typeAlias.keyword, isNotNull); 10286 expect(typeAlias.typedefKeyword, isNotNull);
10287 expect(typeAlias.name, isNotNull); 10287 expect(typeAlias.name, isNotNull);
10288 expect(typeAlias.parameters, isNotNull); 10288 expect(typeAlias.parameters, isNotNull);
10289 expect(typeAlias.returnType, isNotNull); 10289 expect(typeAlias.returnType, isNotNull);
10290 expect(typeAlias.semicolon, isNotNull); 10290 expect(typeAlias.semicolon, isNotNull);
10291 expect(typeAlias.typeParameters, isNull); 10291 expect(typeAlias.typeParameters, isNull);
10292 } 10292 }
10293 10293
10294 void test_parseTypeAlias_function_noReturnType() { 10294 void test_parseTypeAlias_function_noReturnType() {
10295 FunctionTypeAlias typeAlias = ParserTestCase.parse( 10295 FunctionTypeAlias typeAlias = ParserTestCase.parse(
10296 "parseTypeAlias", 10296 "parseTypeAlias",
10297 <Object>[emptyCommentAndMetadata()], 10297 <Object>[emptyCommentAndMetadata()],
10298 "typedef F();"); 10298 "typedef F();");
10299 expect(typeAlias.keyword, isNotNull); 10299 expect(typeAlias.typedefKeyword, isNotNull);
10300 expect(typeAlias.name, isNotNull); 10300 expect(typeAlias.name, isNotNull);
10301 expect(typeAlias.parameters, isNotNull); 10301 expect(typeAlias.parameters, isNotNull);
10302 expect(typeAlias.returnType, isNull); 10302 expect(typeAlias.returnType, isNull);
10303 expect(typeAlias.semicolon, isNotNull); 10303 expect(typeAlias.semicolon, isNotNull);
10304 expect(typeAlias.typeParameters, isNull); 10304 expect(typeAlias.typeParameters, isNull);
10305 } 10305 }
10306 10306
10307 void test_parseTypeAlias_function_parameterizedReturnType() { 10307 void test_parseTypeAlias_function_parameterizedReturnType() {
10308 FunctionTypeAlias typeAlias = ParserTestCase.parse( 10308 FunctionTypeAlias typeAlias = ParserTestCase.parse(
10309 "parseTypeAlias", 10309 "parseTypeAlias",
10310 <Object>[emptyCommentAndMetadata()], 10310 <Object>[emptyCommentAndMetadata()],
10311 "typedef A<B> F();"); 10311 "typedef A<B> F();");
10312 expect(typeAlias.keyword, isNotNull); 10312 expect(typeAlias.typedefKeyword, isNotNull);
10313 expect(typeAlias.name, isNotNull); 10313 expect(typeAlias.name, isNotNull);
10314 expect(typeAlias.parameters, isNotNull); 10314 expect(typeAlias.parameters, isNotNull);
10315 expect(typeAlias.returnType, isNotNull); 10315 expect(typeAlias.returnType, isNotNull);
10316 expect(typeAlias.semicolon, isNotNull); 10316 expect(typeAlias.semicolon, isNotNull);
10317 expect(typeAlias.typeParameters, isNull); 10317 expect(typeAlias.typeParameters, isNull);
10318 } 10318 }
10319 10319
10320 void test_parseTypeAlias_function_parameters() { 10320 void test_parseTypeAlias_function_parameters() {
10321 FunctionTypeAlias typeAlias = ParserTestCase.parse( 10321 FunctionTypeAlias typeAlias = ParserTestCase.parse(
10322 "parseTypeAlias", 10322 "parseTypeAlias",
10323 <Object>[emptyCommentAndMetadata()], 10323 <Object>[emptyCommentAndMetadata()],
10324 "typedef bool F(Object value);"); 10324 "typedef bool F(Object value);");
10325 expect(typeAlias.keyword, isNotNull); 10325 expect(typeAlias.typedefKeyword, isNotNull);
10326 expect(typeAlias.name, isNotNull); 10326 expect(typeAlias.name, isNotNull);
10327 expect(typeAlias.parameters, isNotNull); 10327 expect(typeAlias.parameters, isNotNull);
10328 expect(typeAlias.returnType, isNotNull); 10328 expect(typeAlias.returnType, isNotNull);
10329 expect(typeAlias.semicolon, isNotNull); 10329 expect(typeAlias.semicolon, isNotNull);
10330 expect(typeAlias.typeParameters, isNull); 10330 expect(typeAlias.typeParameters, isNull);
10331 } 10331 }
10332 10332
10333 void test_parseTypeAlias_function_typeParameters() { 10333 void test_parseTypeAlias_function_typeParameters() {
10334 FunctionTypeAlias typeAlias = ParserTestCase.parse( 10334 FunctionTypeAlias typeAlias = ParserTestCase.parse(
10335 "parseTypeAlias", 10335 "parseTypeAlias",
10336 <Object>[emptyCommentAndMetadata()], 10336 <Object>[emptyCommentAndMetadata()],
10337 "typedef bool F<E>();"); 10337 "typedef bool F<E>();");
10338 expect(typeAlias.keyword, isNotNull); 10338 expect(typeAlias.typedefKeyword, isNotNull);
10339 expect(typeAlias.name, isNotNull); 10339 expect(typeAlias.name, isNotNull);
10340 expect(typeAlias.parameters, isNotNull); 10340 expect(typeAlias.parameters, isNotNull);
10341 expect(typeAlias.returnType, isNotNull); 10341 expect(typeAlias.returnType, isNotNull);
10342 expect(typeAlias.semicolon, isNotNull); 10342 expect(typeAlias.semicolon, isNotNull);
10343 expect(typeAlias.typeParameters, isNotNull); 10343 expect(typeAlias.typeParameters, isNotNull);
10344 } 10344 }
10345 10345
10346 void test_parseTypeAlias_function_voidReturnType() { 10346 void test_parseTypeAlias_function_voidReturnType() {
10347 FunctionTypeAlias typeAlias = ParserTestCase.parse( 10347 FunctionTypeAlias typeAlias = ParserTestCase.parse(
10348 "parseTypeAlias", 10348 "parseTypeAlias",
10349 <Object>[emptyCommentAndMetadata()], 10349 <Object>[emptyCommentAndMetadata()],
10350 "typedef void F();"); 10350 "typedef void F();");
10351 expect(typeAlias.keyword, isNotNull); 10351 expect(typeAlias.typedefKeyword, isNotNull);
10352 expect(typeAlias.name, isNotNull); 10352 expect(typeAlias.name, isNotNull);
10353 expect(typeAlias.parameters, isNotNull); 10353 expect(typeAlias.parameters, isNotNull);
10354 expect(typeAlias.returnType, isNotNull); 10354 expect(typeAlias.returnType, isNotNull);
10355 expect(typeAlias.semicolon, isNotNull); 10355 expect(typeAlias.semicolon, isNotNull);
10356 expect(typeAlias.typeParameters, isNull); 10356 expect(typeAlias.typeParameters, isNull);
10357 } 10357 }
10358 10358
10359 void test_parseTypeArgumentList_multiple() { 10359 void test_parseTypeArgumentList_multiple() {
10360 TypeArgumentList argumentList = 10360 TypeArgumentList argumentList =
10361 ParserTestCase.parse4("parseTypeArgumentList", "<int, int, int>"); 10361 ParserTestCase.parse4("parseTypeArgumentList", "<int, int, int>");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
10435 expect(typeName.name, isNotNull); 10435 expect(typeName.name, isNotNull);
10436 expect(typeName.typeArguments, isNotNull); 10436 expect(typeName.typeArguments, isNotNull);
10437 } 10437 }
10438 10438
10439 void test_parseTypeName_simple() { 10439 void test_parseTypeName_simple() {
10440 TypeName typeName = ParserTestCase.parse4("parseTypeName", "int"); 10440 TypeName typeName = ParserTestCase.parse4("parseTypeName", "int");
10441 expect(typeName.name, isNotNull); 10441 expect(typeName.name, isNotNull);
10442 expect(typeName.typeArguments, isNull); 10442 expect(typeName.typeArguments, isNull);
10443 } 10443 }
10444 10444
10445 void test_parseTypeParameter_bounded() {
10446 TypeParameter parameter =
10447 ParserTestCase.parse4("parseTypeParameter", "A extends B");
10448 expect(parameter.bound, isNotNull);
10449 expect(parameter.extendsKeyword, isNotNull);
10450 expect(parameter.name, isNotNull);
10451 }
10452
10453 void test_parseTypeParameter_simple() {
10454 TypeParameter parameter = ParserTestCase.parse4("parseTypeParameter", "A");
10455 expect(parameter.bound, isNull);
10456 expect(parameter.extendsKeyword, isNull);
10457 expect(parameter.name, isNotNull);
10458 }
10459
10445 void test_parseTypeParameterList_multiple() { 10460 void test_parseTypeParameterList_multiple() {
10446 TypeParameterList parameterList = 10461 TypeParameterList parameterList =
10447 ParserTestCase.parse4("parseTypeParameterList", "<A, B extends C, D>"); 10462 ParserTestCase.parse4("parseTypeParameterList", "<A, B extends C, D>");
10448 expect(parameterList.leftBracket, isNotNull); 10463 expect(parameterList.leftBracket, isNotNull);
10449 expect(parameterList.rightBracket, isNotNull); 10464 expect(parameterList.rightBracket, isNotNull);
10450 expect(parameterList.typeParameters, hasLength(3)); 10465 expect(parameterList.typeParameters, hasLength(3));
10451 } 10466 }
10452 10467
10453 void test_parseTypeParameterList_parameterizedWithTrailingEquals() { 10468 void test_parseTypeParameterList_parameterizedWithTrailingEquals() {
10454 TypeParameterList parameterList = 10469 TypeParameterList parameterList =
(...skipping 12 matching lines...) Expand all
10467 } 10482 }
10468 10483
10469 void test_parseTypeParameterList_withTrailingEquals() { 10484 void test_parseTypeParameterList_withTrailingEquals() {
10470 TypeParameterList parameterList = 10485 TypeParameterList parameterList =
10471 ParserTestCase.parse4("parseTypeParameterList", "<A>="); 10486 ParserTestCase.parse4("parseTypeParameterList", "<A>=");
10472 expect(parameterList.leftBracket, isNotNull); 10487 expect(parameterList.leftBracket, isNotNull);
10473 expect(parameterList.rightBracket, isNotNull); 10488 expect(parameterList.rightBracket, isNotNull);
10474 expect(parameterList.typeParameters, hasLength(1)); 10489 expect(parameterList.typeParameters, hasLength(1));
10475 } 10490 }
10476 10491
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
10492 void test_parseUnaryExpression_decrement_normal() { 10492 void test_parseUnaryExpression_decrement_normal() {
10493 PrefixExpression expression = 10493 PrefixExpression expression =
10494 ParserTestCase.parse4("parseUnaryExpression", "--x"); 10494 ParserTestCase.parse4("parseUnaryExpression", "--x");
10495 expect(expression.operator, isNotNull); 10495 expect(expression.operator, isNotNull);
10496 expect(expression.operator.type, TokenType.MINUS_MINUS); 10496 expect(expression.operator.type, TokenType.MINUS_MINUS);
10497 expect(expression.operand, isNotNull); 10497 expect(expression.operand, isNotNull);
10498 } 10498 }
10499 10499
10500 void test_parseUnaryExpression_decrement_super() { 10500 void test_parseUnaryExpression_decrement_super() {
10501 PrefixExpression expression = 10501 PrefixExpression expression =
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
10608 } 10608 }
10609 10609
10610 void test_parseUnaryExpression_tilda_super() { 10610 void test_parseUnaryExpression_tilda_super() {
10611 PrefixExpression expression = 10611 PrefixExpression expression =
10612 ParserTestCase.parse4("parseUnaryExpression", "~super"); 10612 ParserTestCase.parse4("parseUnaryExpression", "~super");
10613 expect(expression.operator, isNotNull); 10613 expect(expression.operator, isNotNull);
10614 expect(expression.operator.type, TokenType.TILDE); 10614 expect(expression.operator.type, TokenType.TILDE);
10615 expect(expression.operand, isNotNull); 10615 expect(expression.operand, isNotNull);
10616 } 10616 }
10617 10617
10618 void test_parseVariableDeclaration_equals() {
10619 VariableDeclaration declaration =
10620 ParserTestCase.parse4("parseVariableDeclaration", "a = b");
10621 expect(declaration.name, isNotNull);
10622 expect(declaration.equals, isNotNull);
10623 expect(declaration.initializer, isNotNull);
10624 }
10625
10626 void test_parseVariableDeclaration_noEquals() {
10627 VariableDeclaration declaration =
10628 ParserTestCase.parse4("parseVariableDeclaration", "a");
10629 expect(declaration.name, isNotNull);
10630 expect(declaration.equals, isNull);
10631 expect(declaration.initializer, isNull);
10632 }
10633
10618 void test_parseVariableDeclarationListAfterMetadata_const_noType() { 10634 void test_parseVariableDeclarationListAfterMetadata_const_noType() {
10619 VariableDeclarationList declarationList = ParserTestCase.parse( 10635 VariableDeclarationList declarationList = ParserTestCase.parse(
10620 "parseVariableDeclarationListAfterMetadata", 10636 "parseVariableDeclarationListAfterMetadata",
10621 <Object>[emptyCommentAndMetadata()], 10637 <Object>[emptyCommentAndMetadata()],
10622 "const a"); 10638 "const a");
10623 expect(declarationList.keyword, isNotNull); 10639 expect(declarationList.keyword, isNotNull);
10624 expect(declarationList.type, isNull); 10640 expect(declarationList.type, isNull);
10625 expect(declarationList.variables, hasLength(1)); 10641 expect(declarationList.variables, hasLength(1));
10626 } 10642 }
10627 10643
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
10732 VariableDeclarationStatement statement = ParserTestCase.parse( 10748 VariableDeclarationStatement statement = ParserTestCase.parse(
10733 "parseVariableDeclarationStatementAfterMetadata", 10749 "parseVariableDeclarationStatementAfterMetadata",
10734 <Object>[emptyCommentAndMetadata()], 10750 <Object>[emptyCommentAndMetadata()],
10735 "var x;"); 10751 "var x;");
10736 expect(statement.semicolon, isNotNull); 10752 expect(statement.semicolon, isNotNull);
10737 VariableDeclarationList variableList = statement.variables; 10753 VariableDeclarationList variableList = statement.variables;
10738 expect(variableList, isNotNull); 10754 expect(variableList, isNotNull);
10739 expect(variableList.variables, hasLength(1)); 10755 expect(variableList.variables, hasLength(1));
10740 } 10756 }
10741 10757
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
10758 void test_parseWhileStatement() { 10758 void test_parseWhileStatement() {
10759 WhileStatement statement = 10759 WhileStatement statement =
10760 ParserTestCase.parse4("parseWhileStatement", "while (x) {}"); 10760 ParserTestCase.parse4("parseWhileStatement", "while (x) {}");
10761 expect(statement.keyword, isNotNull); 10761 expect(statement.whileKeyword, isNotNull);
10762 expect(statement.leftParenthesis, isNotNull); 10762 expect(statement.leftParenthesis, isNotNull);
10763 expect(statement.condition, isNotNull); 10763 expect(statement.condition, isNotNull);
10764 expect(statement.rightParenthesis, isNotNull); 10764 expect(statement.rightParenthesis, isNotNull);
10765 expect(statement.body, isNotNull); 10765 expect(statement.body, isNotNull);
10766 } 10766 }
10767 10767
10768 void test_parseWithClause_multiple() { 10768 void test_parseWithClause_multiple() {
10769 WithClause clause = 10769 WithClause clause =
10770 ParserTestCase.parse4("parseWithClause", "with A, B, C"); 10770 ParserTestCase.parse4("parseWithClause", "with A, B, C");
10771 expect(clause.withKeyword, isNotNull); 10771 expect(clause.withKeyword, isNotNull);
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
11077 // Parse the source. 11077 // Parse the source.
11078 // 11078 //
11079 Parser parser = new Parser(null, listener); 11079 Parser parser = new Parser(null, listener);
11080 return invokeParserMethodImpl( 11080 return invokeParserMethodImpl(
11081 parser, 11081 parser,
11082 methodName, 11082 methodName,
11083 <Object>[tokenStream], 11083 <Object>[tokenStream],
11084 tokenStream) as Token; 11084 tokenStream) as Token;
11085 } 11085 }
11086 } 11086 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/ast_test.dart ('k') | pkg/analyzer/test/generated/utilities_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698