| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| 9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 defineReflectiveTests(RecoveryParserTest); | 31 defineReflectiveTests(RecoveryParserTest); |
| 32 defineReflectiveTests(SimpleParserTest); | 32 defineReflectiveTests(SimpleParserTest); |
| 33 defineReflectiveTests(TopLevelParserTest); | 33 defineReflectiveTests(TopLevelParserTest); |
| 34 }); | 34 }); |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * Abstract base class for parser tests, which does not make assumptions about | 38 * Abstract base class for parser tests, which does not make assumptions about |
| 39 * which parser is used. | 39 * which parser is used. |
| 40 */ | 40 */ |
| 41 abstract class AbstractParserTestCase { | 41 abstract class AbstractParserTestCase implements ParserTestHelpers { |
| 42 void set enableGenericMethodComments(bool value); | 42 void set enableGenericMethodComments(bool value); |
| 43 | 43 |
| 44 void set enableNnbd(bool value); | 44 void set enableNnbd(bool value); |
| 45 | 45 |
| 46 /** |
| 47 * Set a flag indicating whether the parser is to parse part-of directives |
| 48 * that specify a URI rather than a library name. |
| 49 */ |
| 50 void set enableUriInPartOf(bool value); |
| 51 |
| 52 /** |
| 53 * Get the parser used by the test. |
| 54 * |
| 55 * Caller must first invoke [createParser]. |
| 56 */ |
| 57 Parser get parser; |
| 58 |
| 59 /** |
| 60 * Asserts that no errors occurred during parsing. |
| 61 */ |
| 62 void assertNoErrors(); |
| 63 |
| 64 /** |
| 65 * Prepares to parse using tokens scanned from the given [content] string. |
| 66 */ |
| 67 void createParser(String content); |
| 68 |
| 46 CompilationUnit parseCompilationUnit(String source, | 69 CompilationUnit parseCompilationUnit(String source, |
| 47 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); | 70 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 48 | 71 |
| 49 /// TODO(paulberry): merge with [parseCompilationUnit] | 72 /// TODO(paulberry): merge with [parseCompilationUnit] |
| 50 CompilationUnit parseCompilationUnitWithOptions(String source, | 73 CompilationUnit parseCompilationUnitWithOptions(String source, |
| 51 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); | 74 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 52 | 75 |
| 76 /** |
| 77 * Parse the given source as a compilation unit. |
| 78 * |
| 79 * @param source the source to be parsed |
| 80 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 81 * @return the compilation unit that was parsed |
| 82 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 83 * not match those that are expected, or if the result would have be
en `null` |
| 84 */ |
| 85 CompilationUnit parseDirectives(String source, |
| 86 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 87 |
| 53 Expression parseExpression(String source, | 88 Expression parseExpression(String source, |
| 54 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); | 89 [List<ErrorCode> errorCodes = const <ErrorCode>[]]); |
| 55 | 90 |
| 91 /** |
| 92 * Parses a single top level member of a compilation unit (other than a |
| 93 * directive), including any comment and/or metadata that precedes it. |
| 94 */ |
| 95 CompilationUnitMember parseFullCompilationUnitMember(); |
| 96 |
| 97 /** |
| 98 * Parses a single top level directive, including any comment and/or metadata |
| 99 * that precedes it. |
| 100 */ |
| 101 Directive parseFullDirective(); |
| 102 |
| 56 Statement parseStatement(String source, | 103 Statement parseStatement(String source, |
| 57 [List<ErrorCode> errorCodes = const <ErrorCode>[], | 104 [List<ErrorCode> errorCodes = const <ErrorCode>[], |
| 58 bool enableLazyAssignmentOperators]); | 105 bool enableLazyAssignmentOperators]); |
| 59 } | 106 } |
| 60 | 107 |
| 61 /** | 108 /** |
| 62 * Instances of the class `AstValidator` are used to validate the correct constr
uction of an | 109 * Instances of the class `AstValidator` are used to validate the correct constr
uction of an |
| 63 * AST structure. | 110 * AST structure. |
| 64 */ | 111 */ |
| 65 class AstValidator extends UnifyingAstVisitor<Object> { | 112 class AstValidator extends UnifyingAstVisitor<Object> { |
| (...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2992 */ | 3039 */ |
| 2993 GatheringErrorListener listener; | 3040 GatheringErrorListener listener; |
| 2994 | 3041 |
| 2995 /** | 3042 /** |
| 2996 * The parser used by the test. | 3043 * The parser used by the test. |
| 2997 * | 3044 * |
| 2998 * This field is typically initialized by invoking [createParser]. | 3045 * This field is typically initialized by invoking [createParser]. |
| 2999 */ | 3046 */ |
| 3000 Parser parser; | 3047 Parser parser; |
| 3001 | 3048 |
| 3049 @override |
| 3050 void assertNoErrors() { |
| 3051 listener.assertNoErrors(); |
| 3052 } |
| 3053 |
| 3002 /** | 3054 /** |
| 3003 * Create the [parser] and [listener] used by a test. The [parser] will be | 3055 * Create the [parser] and [listener] used by a test. The [parser] will be |
| 3004 * prepared to parse the tokens scanned from the given [content]. | 3056 * prepared to parse the tokens scanned from the given [content]. |
| 3005 */ | 3057 */ |
| 3006 void createParser(String content) { | 3058 void createParser(String content) { |
| 3007 listener = new GatheringErrorListener(); | 3059 listener = new GatheringErrorListener(); |
| 3008 // | 3060 // |
| 3009 // Scan the source. | 3061 // Scan the source. |
| 3010 // | 3062 // |
| 3011 TestSource source = new TestSource(); | 3063 TestSource source = new TestSource(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3077 */ | 3129 */ |
| 3078 CompilationUnit parseCompilationUnitWithOptions(String source, | 3130 CompilationUnit parseCompilationUnitWithOptions(String source, |
| 3079 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 3131 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 3080 createParser(source); | 3132 createParser(source); |
| 3081 CompilationUnit unit = parser.parseCompilationUnit2(); | 3133 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 3082 expect(unit, isNotNull); | 3134 expect(unit, isNotNull); |
| 3083 listener.assertErrorsWithCodes(errorCodes); | 3135 listener.assertErrorsWithCodes(errorCodes); |
| 3084 return unit; | 3136 return unit; |
| 3085 } | 3137 } |
| 3086 | 3138 |
| 3139 @override |
| 3140 CompilationUnit parseDirectives(String source, |
| 3141 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 3142 createParser(source); |
| 3143 CompilationUnit unit = parser.parseDirectives2(); |
| 3144 expect(unit, isNotNull); |
| 3145 expect(unit.declarations, hasLength(0)); |
| 3146 listener.assertErrorsWithCodes(errorCodes); |
| 3147 return unit; |
| 3148 } |
| 3149 |
| 3087 /** | 3150 /** |
| 3088 * Parse the given source as an expression. | 3151 * Parse the given source as an expression. |
| 3089 * | 3152 * |
| 3090 * @param source the source to be parsed | 3153 * @param source the source to be parsed |
| 3091 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 3154 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 3092 * @return the expression that was parsed | 3155 * @return the expression that was parsed |
| 3093 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 3156 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 3094 * not match those that are expected, or if the result would have be
en `null` | 3157 * not match those that are expected, or if the result would have be
en `null` |
| 3095 */ | 3158 */ |
| 3096 Expression parseExpression(String source, | 3159 Expression parseExpression(String source, |
| 3097 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 3160 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 3098 createParser(source); | 3161 createParser(source); |
| 3099 Expression expression = parser.parseExpression2(); | 3162 Expression expression = parser.parseExpression2(); |
| 3100 expectNotNullIfNoErrors(expression); | 3163 expectNotNullIfNoErrors(expression); |
| 3101 listener.assertErrorsWithCodes(errorCodes); | 3164 listener.assertErrorsWithCodes(errorCodes); |
| 3102 return expression; | 3165 return expression; |
| 3103 } | 3166 } |
| 3104 | 3167 |
| 3105 /** | 3168 /** |
| 3106 * Parses a single top level member of a compilation unit (other than a | 3169 * Parses a single top level member of a compilation unit (other than a |
| 3107 * directive), including any comment and/or metadata that precedes it. | 3170 * directive), including any comment and/or metadata that precedes it. |
| 3108 */ | 3171 */ |
| 3109 CompilationUnitMember parseFullCompilationUnitMember() => | 3172 CompilationUnitMember parseFullCompilationUnitMember() => |
| 3110 parser.parseCompilationUnitMember(parser.parseCommentAndMetadata()); | 3173 parser.parseCompilationUnitMember(parser.parseCommentAndMetadata()); |
| 3111 | 3174 |
| 3112 /** | 3175 @override |
| 3113 * Parses a single top level directive, including any comment and/or metadata | |
| 3114 * that precedes it. | |
| 3115 */ | |
| 3116 Directive parseFullDirective() => | 3176 Directive parseFullDirective() => |
| 3117 parser.parseDirective(parser.parseCommentAndMetadata()); | 3177 parser.parseDirective(parser.parseCommentAndMetadata()); |
| 3118 | 3178 |
| 3119 /** | 3179 /** |
| 3120 * Parses a variable declaration list (equivalent to a variable declaration | 3180 * Parses a variable declaration list (equivalent to a variable declaration |
| 3121 * statement, but without the final comma). | 3181 * statement, but without the final comma). |
| 3122 */ | 3182 */ |
| 3123 VariableDeclarationList parseFullVariableDeclarationList() => | 3183 VariableDeclarationList parseFullVariableDeclarationList() => |
| 3124 parser.parseVariableDeclarationListAfterMetadata( | 3184 parser.parseVariableDeclarationListAfterMetadata( |
| 3125 parser.parseCommentAndMetadata()); | 3185 parser.parseCommentAndMetadata()); |
| (...skipping 9761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12887 * @throws Exception if the method could not be invoked or throws an exception | 12947 * @throws Exception if the method could not be invoked or throws an exception |
| 12888 */ | 12948 */ |
| 12889 bool _isSwitchMember(String source) { | 12949 bool _isSwitchMember(String source) { |
| 12890 createParser(source); | 12950 createParser(source); |
| 12891 bool result = parser.isSwitchMember(); | 12951 bool result = parser.isSwitchMember(); |
| 12892 expectNotNullIfNoErrors(result); | 12952 expectNotNullIfNoErrors(result); |
| 12893 return result; | 12953 return result; |
| 12894 } | 12954 } |
| 12895 } | 12955 } |
| 12896 | 12956 |
| 12957 @reflectiveTest |
| 12958 class TopLevelParserTest extends ParserTestCase with TopLevelParserTestMixin {} |
| 12959 |
| 12897 /** | 12960 /** |
| 12898 * Tests which exercise the parser using a complete compilation unit or | 12961 * Tests which exercise the parser using a complete compilation unit or |
| 12899 * compilation unit member. | 12962 * compilation unit member. |
| 12900 */ | 12963 */ |
| 12901 @reflectiveTest | 12964 abstract class TopLevelParserTestMixin implements AbstractParserTestCase { |
| 12902 class TopLevelParserTest extends ParserTestCase { | |
| 12903 void test_function_literal_allowed_at_toplevel() { | 12965 void test_function_literal_allowed_at_toplevel() { |
| 12904 parseCompilationUnit("var x = () {};"); | 12966 parseCompilationUnit("var x = () {};"); |
| 12905 } | 12967 } |
| 12906 | 12968 |
| 12907 void | 12969 void |
| 12908 test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitializ
er() { | 12970 test_function_literal_allowed_in_ArgumentList_in_ConstructorFieldInitializ
er() { |
| 12909 parseCompilationUnit("class C { C() : a = f(() {}); }"); | 12971 parseCompilationUnit("class C { C() : a = f(() {}); }"); |
| 12910 } | 12972 } |
| 12911 | 12973 |
| 12912 void | 12974 void |
| (...skipping 26 matching lines...) Expand all Loading... |
| 12939 } | 13001 } |
| 12940 | 13002 |
| 12941 void test_import_show_hide() { | 13003 void test_import_show_hide() { |
| 12942 parseCompilationUnit( | 13004 parseCompilationUnit( |
| 12943 "import 'import1_lib.dart' show hide, show hide ugly;"); | 13005 "import 'import1_lib.dart' show hide, show hide ugly;"); |
| 12944 } | 13006 } |
| 12945 | 13007 |
| 12946 void test_parseClassDeclaration_abstract() { | 13008 void test_parseClassDeclaration_abstract() { |
| 12947 createParser('abstract class A {}'); | 13009 createParser('abstract class A {}'); |
| 12948 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13010 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 12949 expectNotNullIfNoErrors(member); | 13011 expect(member, isNotNull); |
| 12950 listener.assertNoErrors(); | 13012 assertNoErrors(); |
| 12951 expect(member, new isInstanceOf<ClassDeclaration>()); | 13013 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 12952 ClassDeclaration declaration = member; | 13014 ClassDeclaration declaration = member; |
| 12953 expect(declaration.documentationComment, isNull); | 13015 expect(declaration.documentationComment, isNull); |
| 12954 expect(declaration.abstractKeyword, isNotNull); | 13016 expect(declaration.abstractKeyword, isNotNull); |
| 12955 expect(declaration.extendsClause, isNull); | 13017 expect(declaration.extendsClause, isNull); |
| 12956 expect(declaration.implementsClause, isNull); | 13018 expect(declaration.implementsClause, isNull); |
| 12957 expect(declaration.classKeyword, isNotNull); | 13019 expect(declaration.classKeyword, isNotNull); |
| 12958 expect(declaration.leftBracket, isNotNull); | 13020 expect(declaration.leftBracket, isNotNull); |
| 12959 expect(declaration.name, isNotNull); | 13021 expect(declaration.name, isNotNull); |
| 12960 expect(declaration.members, hasLength(0)); | 13022 expect(declaration.members, hasLength(0)); |
| 12961 expect(declaration.rightBracket, isNotNull); | 13023 expect(declaration.rightBracket, isNotNull); |
| 12962 expect(declaration.typeParameters, isNull); | 13024 expect(declaration.typeParameters, isNull); |
| 12963 } | 13025 } |
| 12964 | 13026 |
| 12965 void test_parseClassDeclaration_empty() { | 13027 void test_parseClassDeclaration_empty() { |
| 12966 createParser('class A {}'); | 13028 createParser('class A {}'); |
| 12967 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13029 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 12968 expectNotNullIfNoErrors(member); | 13030 expect(member, isNotNull); |
| 12969 listener.assertNoErrors(); | 13031 assertNoErrors(); |
| 12970 expect(member, new isInstanceOf<ClassDeclaration>()); | 13032 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 12971 ClassDeclaration declaration = member; | 13033 ClassDeclaration declaration = member; |
| 12972 expect(declaration.documentationComment, isNull); | 13034 expect(declaration.documentationComment, isNull); |
| 12973 expect(declaration.abstractKeyword, isNull); | 13035 expect(declaration.abstractKeyword, isNull); |
| 12974 expect(declaration.extendsClause, isNull); | 13036 expect(declaration.extendsClause, isNull); |
| 12975 expect(declaration.implementsClause, isNull); | 13037 expect(declaration.implementsClause, isNull); |
| 12976 expect(declaration.classKeyword, isNotNull); | 13038 expect(declaration.classKeyword, isNotNull); |
| 12977 expect(declaration.leftBracket, isNotNull); | 13039 expect(declaration.leftBracket, isNotNull); |
| 12978 expect(declaration.name, isNotNull); | 13040 expect(declaration.name, isNotNull); |
| 12979 expect(declaration.members, hasLength(0)); | 13041 expect(declaration.members, hasLength(0)); |
| 12980 expect(declaration.rightBracket, isNotNull); | 13042 expect(declaration.rightBracket, isNotNull); |
| 12981 expect(declaration.typeParameters, isNull); | 13043 expect(declaration.typeParameters, isNull); |
| 12982 } | 13044 } |
| 12983 | 13045 |
| 12984 void test_parseClassDeclaration_extends() { | 13046 void test_parseClassDeclaration_extends() { |
| 12985 createParser('class A extends B {}'); | 13047 createParser('class A extends B {}'); |
| 12986 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13048 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 12987 expectNotNullIfNoErrors(member); | 13049 expect(member, isNotNull); |
| 12988 listener.assertNoErrors(); | 13050 assertNoErrors(); |
| 12989 expect(member, new isInstanceOf<ClassDeclaration>()); | 13051 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 12990 ClassDeclaration declaration = member; | 13052 ClassDeclaration declaration = member; |
| 12991 expect(declaration.documentationComment, isNull); | 13053 expect(declaration.documentationComment, isNull); |
| 12992 expect(declaration.abstractKeyword, isNull); | 13054 expect(declaration.abstractKeyword, isNull); |
| 12993 expect(declaration.extendsClause, isNotNull); | 13055 expect(declaration.extendsClause, isNotNull); |
| 12994 expect(declaration.implementsClause, isNull); | 13056 expect(declaration.implementsClause, isNull); |
| 12995 expect(declaration.classKeyword, isNotNull); | 13057 expect(declaration.classKeyword, isNotNull); |
| 12996 expect(declaration.leftBracket, isNotNull); | 13058 expect(declaration.leftBracket, isNotNull); |
| 12997 expect(declaration.name, isNotNull); | 13059 expect(declaration.name, isNotNull); |
| 12998 expect(declaration.members, hasLength(0)); | 13060 expect(declaration.members, hasLength(0)); |
| 12999 expect(declaration.rightBracket, isNotNull); | 13061 expect(declaration.rightBracket, isNotNull); |
| 13000 expect(declaration.typeParameters, isNull); | 13062 expect(declaration.typeParameters, isNull); |
| 13001 } | 13063 } |
| 13002 | 13064 |
| 13003 void test_parseClassDeclaration_extendsAndImplements() { | 13065 void test_parseClassDeclaration_extendsAndImplements() { |
| 13004 createParser('class A extends B implements C {}'); | 13066 createParser('class A extends B implements C {}'); |
| 13005 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13067 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13006 expectNotNullIfNoErrors(member); | 13068 expect(member, isNotNull); |
| 13007 listener.assertNoErrors(); | 13069 assertNoErrors(); |
| 13008 expect(member, new isInstanceOf<ClassDeclaration>()); | 13070 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13009 ClassDeclaration declaration = member; | 13071 ClassDeclaration declaration = member; |
| 13010 expect(declaration.documentationComment, isNull); | 13072 expect(declaration.documentationComment, isNull); |
| 13011 expect(declaration.abstractKeyword, isNull); | 13073 expect(declaration.abstractKeyword, isNull); |
| 13012 expect(declaration.extendsClause, isNotNull); | 13074 expect(declaration.extendsClause, isNotNull); |
| 13013 expect(declaration.implementsClause, isNotNull); | 13075 expect(declaration.implementsClause, isNotNull); |
| 13014 expect(declaration.classKeyword, isNotNull); | 13076 expect(declaration.classKeyword, isNotNull); |
| 13015 expect(declaration.leftBracket, isNotNull); | 13077 expect(declaration.leftBracket, isNotNull); |
| 13016 expect(declaration.name, isNotNull); | 13078 expect(declaration.name, isNotNull); |
| 13017 expect(declaration.members, hasLength(0)); | 13079 expect(declaration.members, hasLength(0)); |
| 13018 expect(declaration.rightBracket, isNotNull); | 13080 expect(declaration.rightBracket, isNotNull); |
| 13019 expect(declaration.typeParameters, isNull); | 13081 expect(declaration.typeParameters, isNull); |
| 13020 } | 13082 } |
| 13021 | 13083 |
| 13022 void test_parseClassDeclaration_extendsAndWith() { | 13084 void test_parseClassDeclaration_extendsAndWith() { |
| 13023 createParser('class A extends B with C {}'); | 13085 createParser('class A extends B with C {}'); |
| 13024 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13086 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13025 expectNotNullIfNoErrors(member); | 13087 expect(member, isNotNull); |
| 13026 listener.assertNoErrors(); | 13088 assertNoErrors(); |
| 13027 expect(member, new isInstanceOf<ClassDeclaration>()); | 13089 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13028 ClassDeclaration declaration = member; | 13090 ClassDeclaration declaration = member; |
| 13029 expect(declaration.documentationComment, isNull); | 13091 expect(declaration.documentationComment, isNull); |
| 13030 expect(declaration.abstractKeyword, isNull); | 13092 expect(declaration.abstractKeyword, isNull); |
| 13031 expect(declaration.classKeyword, isNotNull); | 13093 expect(declaration.classKeyword, isNotNull); |
| 13032 expect(declaration.name, isNotNull); | 13094 expect(declaration.name, isNotNull); |
| 13033 expect(declaration.typeParameters, isNull); | 13095 expect(declaration.typeParameters, isNull); |
| 13034 expect(declaration.extendsClause, isNotNull); | 13096 expect(declaration.extendsClause, isNotNull); |
| 13035 expect(declaration.withClause, isNotNull); | 13097 expect(declaration.withClause, isNotNull); |
| 13036 expect(declaration.implementsClause, isNull); | 13098 expect(declaration.implementsClause, isNull); |
| 13037 expect(declaration.leftBracket, isNotNull); | 13099 expect(declaration.leftBracket, isNotNull); |
| 13038 expect(declaration.members, hasLength(0)); | 13100 expect(declaration.members, hasLength(0)); |
| 13039 expect(declaration.rightBracket, isNotNull); | 13101 expect(declaration.rightBracket, isNotNull); |
| 13040 } | 13102 } |
| 13041 | 13103 |
| 13042 void test_parseClassDeclaration_extendsAndWithAndImplements() { | 13104 void test_parseClassDeclaration_extendsAndWithAndImplements() { |
| 13043 createParser('class A extends B with C implements D {}'); | 13105 createParser('class A extends B with C implements D {}'); |
| 13044 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13106 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13045 expectNotNullIfNoErrors(member); | 13107 expect(member, isNotNull); |
| 13046 listener.assertNoErrors(); | 13108 assertNoErrors(); |
| 13047 expect(member, new isInstanceOf<ClassDeclaration>()); | 13109 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13048 ClassDeclaration declaration = member; | 13110 ClassDeclaration declaration = member; |
| 13049 expect(declaration.documentationComment, isNull); | 13111 expect(declaration.documentationComment, isNull); |
| 13050 expect(declaration.abstractKeyword, isNull); | 13112 expect(declaration.abstractKeyword, isNull); |
| 13051 expect(declaration.classKeyword, isNotNull); | 13113 expect(declaration.classKeyword, isNotNull); |
| 13052 expect(declaration.name, isNotNull); | 13114 expect(declaration.name, isNotNull); |
| 13053 expect(declaration.typeParameters, isNull); | 13115 expect(declaration.typeParameters, isNull); |
| 13054 expect(declaration.extendsClause, isNotNull); | 13116 expect(declaration.extendsClause, isNotNull); |
| 13055 expect(declaration.withClause, isNotNull); | 13117 expect(declaration.withClause, isNotNull); |
| 13056 expect(declaration.implementsClause, isNotNull); | 13118 expect(declaration.implementsClause, isNotNull); |
| 13057 expect(declaration.leftBracket, isNotNull); | 13119 expect(declaration.leftBracket, isNotNull); |
| 13058 expect(declaration.members, hasLength(0)); | 13120 expect(declaration.members, hasLength(0)); |
| 13059 expect(declaration.rightBracket, isNotNull); | 13121 expect(declaration.rightBracket, isNotNull); |
| 13060 } | 13122 } |
| 13061 | 13123 |
| 13062 void test_parseClassDeclaration_implements() { | 13124 void test_parseClassDeclaration_implements() { |
| 13063 createParser('class A implements C {}'); | 13125 createParser('class A implements C {}'); |
| 13064 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13126 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13065 expectNotNullIfNoErrors(member); | 13127 expect(member, isNotNull); |
| 13066 listener.assertNoErrors(); | 13128 assertNoErrors(); |
| 13067 expect(member, new isInstanceOf<ClassDeclaration>()); | 13129 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13068 ClassDeclaration declaration = member; | 13130 ClassDeclaration declaration = member; |
| 13069 expect(declaration.documentationComment, isNull); | 13131 expect(declaration.documentationComment, isNull); |
| 13070 expect(declaration.abstractKeyword, isNull); | 13132 expect(declaration.abstractKeyword, isNull); |
| 13071 expect(declaration.extendsClause, isNull); | 13133 expect(declaration.extendsClause, isNull); |
| 13072 expect(declaration.implementsClause, isNotNull); | 13134 expect(declaration.implementsClause, isNotNull); |
| 13073 expect(declaration.classKeyword, isNotNull); | 13135 expect(declaration.classKeyword, isNotNull); |
| 13074 expect(declaration.leftBracket, isNotNull); | 13136 expect(declaration.leftBracket, isNotNull); |
| 13075 expect(declaration.name, isNotNull); | 13137 expect(declaration.name, isNotNull); |
| 13076 expect(declaration.members, hasLength(0)); | 13138 expect(declaration.members, hasLength(0)); |
| 13077 expect(declaration.rightBracket, isNotNull); | 13139 expect(declaration.rightBracket, isNotNull); |
| 13078 expect(declaration.typeParameters, isNull); | 13140 expect(declaration.typeParameters, isNull); |
| 13079 } | 13141 } |
| 13080 | 13142 |
| 13081 void test_parseClassDeclaration_native() { | 13143 void test_parseClassDeclaration_native() { |
| 13082 createParser('class A native "nativeValue" {}'); | 13144 createParser('class A native "nativeValue" {}'); |
| 13083 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13145 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13084 expectNotNullIfNoErrors(member); | 13146 expect(member, isNotNull); |
| 13085 listener.assertNoErrors(); | 13147 assertNoErrors(); |
| 13086 expect(member, new isInstanceOf<ClassDeclaration>()); | 13148 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13087 ClassDeclaration declaration = member; | 13149 ClassDeclaration declaration = member; |
| 13088 NativeClause nativeClause = declaration.nativeClause; | 13150 NativeClause nativeClause = declaration.nativeClause; |
| 13089 expect(nativeClause, isNotNull); | 13151 expect(nativeClause, isNotNull); |
| 13090 expect(nativeClause.nativeKeyword, isNotNull); | 13152 expect(nativeClause.nativeKeyword, isNotNull); |
| 13091 expect(nativeClause.name.stringValue, "nativeValue"); | 13153 expect(nativeClause.name.stringValue, "nativeValue"); |
| 13092 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); | 13154 expect(nativeClause.beginToken, same(nativeClause.nativeKeyword)); |
| 13093 expect(nativeClause.endToken, same(nativeClause.name.endToken)); | 13155 expect(nativeClause.endToken, same(nativeClause.name.endToken)); |
| 13094 } | 13156 } |
| 13095 | 13157 |
| 13096 void test_parseClassDeclaration_nonEmpty() { | 13158 void test_parseClassDeclaration_nonEmpty() { |
| 13097 createParser('class A {var f;}'); | 13159 createParser('class A {var f;}'); |
| 13098 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13160 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13099 expectNotNullIfNoErrors(member); | 13161 expect(member, isNotNull); |
| 13100 listener.assertNoErrors(); | 13162 assertNoErrors(); |
| 13101 expect(member, new isInstanceOf<ClassDeclaration>()); | 13163 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13102 ClassDeclaration declaration = member; | 13164 ClassDeclaration declaration = member; |
| 13103 expect(declaration.documentationComment, isNull); | 13165 expect(declaration.documentationComment, isNull); |
| 13104 expect(declaration.abstractKeyword, isNull); | 13166 expect(declaration.abstractKeyword, isNull); |
| 13105 expect(declaration.extendsClause, isNull); | 13167 expect(declaration.extendsClause, isNull); |
| 13106 expect(declaration.implementsClause, isNull); | 13168 expect(declaration.implementsClause, isNull); |
| 13107 expect(declaration.classKeyword, isNotNull); | 13169 expect(declaration.classKeyword, isNotNull); |
| 13108 expect(declaration.leftBracket, isNotNull); | 13170 expect(declaration.leftBracket, isNotNull); |
| 13109 expect(declaration.name, isNotNull); | 13171 expect(declaration.name, isNotNull); |
| 13110 expect(declaration.members, hasLength(1)); | 13172 expect(declaration.members, hasLength(1)); |
| 13111 expect(declaration.rightBracket, isNotNull); | 13173 expect(declaration.rightBracket, isNotNull); |
| 13112 expect(declaration.typeParameters, isNull); | 13174 expect(declaration.typeParameters, isNull); |
| 13113 } | 13175 } |
| 13114 | 13176 |
| 13115 void test_parseClassDeclaration_typeAlias_implementsC() { | 13177 void test_parseClassDeclaration_typeAlias_implementsC() { |
| 13116 createParser('class A = Object with B implements C;'); | 13178 createParser('class A = Object with B implements C;'); |
| 13117 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13179 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13118 expectNotNullIfNoErrors(member); | 13180 expect(member, isNotNull); |
| 13119 listener.assertNoErrors(); | 13181 assertNoErrors(); |
| 13120 expect(member, new isInstanceOf<ClassTypeAlias>()); | 13182 expect(member, new isInstanceOf<ClassTypeAlias>()); |
| 13121 ClassTypeAlias typeAlias = member; | 13183 ClassTypeAlias typeAlias = member; |
| 13122 expect(typeAlias.typedefKeyword, isNotNull); | 13184 expect(typeAlias.typedefKeyword, isNotNull); |
| 13123 expect(typeAlias.name, isNotNull); | 13185 expect(typeAlias.name, isNotNull); |
| 13124 expect(typeAlias.typeParameters, isNull); | 13186 expect(typeAlias.typeParameters, isNull); |
| 13125 expect(typeAlias.withClause, isNotNull); | 13187 expect(typeAlias.withClause, isNotNull); |
| 13126 expect(typeAlias.implementsClause, isNotNull); | 13188 expect(typeAlias.implementsClause, isNotNull); |
| 13127 expect(typeAlias.implementsClause.implementsKeyword, isNotNull); | 13189 expect(typeAlias.implementsClause.implementsKeyword, isNotNull); |
| 13128 expect(typeAlias.implementsClause.interfaces.length, 1); | 13190 expect(typeAlias.implementsClause.interfaces.length, 1); |
| 13129 expect(typeAlias.semicolon, isNotNull); | 13191 expect(typeAlias.semicolon, isNotNull); |
| 13130 } | 13192 } |
| 13131 | 13193 |
| 13132 void test_parseClassDeclaration_typeAlias_withB() { | 13194 void test_parseClassDeclaration_typeAlias_withB() { |
| 13133 createParser('class A = Object with B;'); | 13195 createParser('class A = Object with B;'); |
| 13134 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13196 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13135 expectNotNullIfNoErrors(member); | 13197 expect(member, isNotNull); |
| 13136 listener.assertNoErrors(); | 13198 assertNoErrors(); |
| 13137 expect(member, new isInstanceOf<ClassTypeAlias>()); | 13199 expect(member, new isInstanceOf<ClassTypeAlias>()); |
| 13138 ClassTypeAlias typeAlias = member; | 13200 ClassTypeAlias typeAlias = member; |
| 13139 expect(typeAlias.typedefKeyword, isNotNull); | 13201 expect(typeAlias.typedefKeyword, isNotNull); |
| 13140 expect(typeAlias.name, isNotNull); | 13202 expect(typeAlias.name, isNotNull); |
| 13141 expect(typeAlias.typeParameters, isNull); | 13203 expect(typeAlias.typeParameters, isNull); |
| 13142 expect(typeAlias.withClause, isNotNull); | 13204 expect(typeAlias.withClause, isNotNull); |
| 13143 expect(typeAlias.withClause.withKeyword, isNotNull); | 13205 expect(typeAlias.withClause.withKeyword, isNotNull); |
| 13144 expect(typeAlias.withClause.mixinTypes.length, 1); | 13206 expect(typeAlias.withClause.mixinTypes.length, 1); |
| 13145 expect(typeAlias.implementsClause, isNull); | 13207 expect(typeAlias.implementsClause, isNull); |
| 13146 expect(typeAlias.semicolon, isNotNull); | 13208 expect(typeAlias.semicolon, isNotNull); |
| 13147 } | 13209 } |
| 13148 | 13210 |
| 13149 void test_parseClassDeclaration_typeParameters() { | 13211 void test_parseClassDeclaration_typeParameters() { |
| 13150 createParser('class A<B> {}'); | 13212 createParser('class A<B> {}'); |
| 13151 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13213 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13152 expectNotNullIfNoErrors(member); | 13214 expect(member, isNotNull); |
| 13153 listener.assertNoErrors(); | 13215 assertNoErrors(); |
| 13154 expect(member, new isInstanceOf<ClassDeclaration>()); | 13216 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13155 ClassDeclaration declaration = member; | 13217 ClassDeclaration declaration = member; |
| 13156 expect(declaration.documentationComment, isNull); | 13218 expect(declaration.documentationComment, isNull); |
| 13157 expect(declaration.abstractKeyword, isNull); | 13219 expect(declaration.abstractKeyword, isNull); |
| 13158 expect(declaration.extendsClause, isNull); | 13220 expect(declaration.extendsClause, isNull); |
| 13159 expect(declaration.implementsClause, isNull); | 13221 expect(declaration.implementsClause, isNull); |
| 13160 expect(declaration.classKeyword, isNotNull); | 13222 expect(declaration.classKeyword, isNotNull); |
| 13161 expect(declaration.leftBracket, isNotNull); | 13223 expect(declaration.leftBracket, isNotNull); |
| 13162 expect(declaration.name, isNotNull); | 13224 expect(declaration.name, isNotNull); |
| 13163 expect(declaration.members, hasLength(0)); | 13225 expect(declaration.members, hasLength(0)); |
| 13164 expect(declaration.rightBracket, isNotNull); | 13226 expect(declaration.rightBracket, isNotNull); |
| 13165 expect(declaration.typeParameters, isNotNull); | 13227 expect(declaration.typeParameters, isNotNull); |
| 13166 expect(declaration.typeParameters.typeParameters, hasLength(1)); | 13228 expect(declaration.typeParameters.typeParameters, hasLength(1)); |
| 13167 } | 13229 } |
| 13168 | 13230 |
| 13169 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { | 13231 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { |
| 13170 createParser('abstract<dynamic> _abstract = new abstract.A();'); | 13232 createParser('abstract<dynamic> _abstract = new abstract.A();'); |
| 13171 CompilationUnit unit = parser.parseCompilationUnit2(); | 13233 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13172 expectNotNullIfNoErrors(unit); | 13234 expect(unit, isNotNull); |
| 13173 listener.assertNoErrors(); | 13235 assertNoErrors(); |
| 13174 expect(unit.scriptTag, isNull); | 13236 expect(unit.scriptTag, isNull); |
| 13175 expect(unit.directives, hasLength(0)); | 13237 expect(unit.directives, hasLength(0)); |
| 13176 expect(unit.declarations, hasLength(1)); | 13238 expect(unit.declarations, hasLength(1)); |
| 13177 } | 13239 } |
| 13178 | 13240 |
| 13179 void test_parseCompilationUnit_builtIn_asFunctionName() { | 13241 void test_parseCompilationUnit_builtIn_asFunctionName() { |
| 13180 parseCompilationUnit('abstract(x) => 0;'); | 13242 parseCompilationUnit('abstract(x) => 0;'); |
| 13181 parseCompilationUnit('as(x) => 0;'); | 13243 parseCompilationUnit('as(x) => 0;'); |
| 13182 parseCompilationUnit('dynamic(x) => 0;'); | 13244 parseCompilationUnit('dynamic(x) => 0;'); |
| 13183 parseCompilationUnit('export(x) => 0;'); | 13245 parseCompilationUnit('export(x) => 0;'); |
| 13184 parseCompilationUnit('external(x) => 0;'); | 13246 parseCompilationUnit('external(x) => 0;'); |
| 13185 parseCompilationUnit('factory(x) => 0;'); | 13247 parseCompilationUnit('factory(x) => 0;'); |
| 13186 parseCompilationUnit('get(x) => 0;'); | 13248 parseCompilationUnit('get(x) => 0;'); |
| 13187 parseCompilationUnit('implements(x) => 0;'); | 13249 parseCompilationUnit('implements(x) => 0;'); |
| 13188 parseCompilationUnit('import(x) => 0;'); | 13250 parseCompilationUnit('import(x) => 0;'); |
| 13189 parseCompilationUnit('library(x) => 0;'); | 13251 parseCompilationUnit('library(x) => 0;'); |
| 13190 parseCompilationUnit('operator(x) => 0;'); | 13252 parseCompilationUnit('operator(x) => 0;'); |
| 13191 parseCompilationUnit('part(x) => 0;'); | 13253 parseCompilationUnit('part(x) => 0;'); |
| 13192 parseCompilationUnit('set(x) => 0;'); | 13254 parseCompilationUnit('set(x) => 0;'); |
| 13193 parseCompilationUnit('static(x) => 0;'); | 13255 parseCompilationUnit('static(x) => 0;'); |
| 13194 parseCompilationUnit('typedef(x) => 0;'); | 13256 parseCompilationUnit('typedef(x) => 0;'); |
| 13195 } | 13257 } |
| 13196 | 13258 |
| 13197 void test_parseCompilationUnit_directives_multiple() { | 13259 void test_parseCompilationUnit_directives_multiple() { |
| 13198 createParser("library l;\npart 'a.dart';"); | 13260 createParser("library l;\npart 'a.dart';"); |
| 13199 CompilationUnit unit = parser.parseCompilationUnit2(); | 13261 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13200 expectNotNullIfNoErrors(unit); | 13262 expect(unit, isNotNull); |
| 13201 listener.assertNoErrors(); | 13263 assertNoErrors(); |
| 13202 expect(unit.scriptTag, isNull); | 13264 expect(unit.scriptTag, isNull); |
| 13203 expect(unit.directives, hasLength(2)); | 13265 expect(unit.directives, hasLength(2)); |
| 13204 expect(unit.declarations, hasLength(0)); | 13266 expect(unit.declarations, hasLength(0)); |
| 13205 } | 13267 } |
| 13206 | 13268 |
| 13207 void test_parseCompilationUnit_directives_single() { | 13269 void test_parseCompilationUnit_directives_single() { |
| 13208 createParser('library l;'); | 13270 createParser('library l;'); |
| 13209 CompilationUnit unit = parser.parseCompilationUnit2(); | 13271 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13210 expectNotNullIfNoErrors(unit); | 13272 expect(unit, isNotNull); |
| 13211 listener.assertNoErrors(); | 13273 assertNoErrors(); |
| 13212 expect(unit.scriptTag, isNull); | 13274 expect(unit.scriptTag, isNull); |
| 13213 expect(unit.directives, hasLength(1)); | 13275 expect(unit.directives, hasLength(1)); |
| 13214 expect(unit.declarations, hasLength(0)); | 13276 expect(unit.declarations, hasLength(0)); |
| 13215 } | 13277 } |
| 13216 | 13278 |
| 13217 void test_parseCompilationUnit_empty() { | 13279 void test_parseCompilationUnit_empty() { |
| 13218 createParser(''); | 13280 createParser(''); |
| 13219 CompilationUnit unit = parser.parseCompilationUnit2(); | 13281 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13220 expectNotNullIfNoErrors(unit); | 13282 expect(unit, isNotNull); |
| 13221 listener.assertNoErrors(); | 13283 assertNoErrors(); |
| 13222 expect(unit.scriptTag, isNull); | 13284 expect(unit.scriptTag, isNull); |
| 13223 expect(unit.directives, hasLength(0)); | 13285 expect(unit.directives, hasLength(0)); |
| 13224 expect(unit.declarations, hasLength(0)); | 13286 expect(unit.declarations, hasLength(0)); |
| 13225 } | 13287 } |
| 13226 | 13288 |
| 13227 void test_parseCompilationUnit_exportAsPrefix() { | 13289 void test_parseCompilationUnit_exportAsPrefix() { |
| 13228 createParser('export.A _export = new export.A();'); | 13290 createParser('export.A _export = new export.A();'); |
| 13229 CompilationUnit unit = parser.parseCompilationUnit2(); | 13291 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13230 expectNotNullIfNoErrors(unit); | 13292 expect(unit, isNotNull); |
| 13231 listener.assertNoErrors(); | 13293 assertNoErrors(); |
| 13232 expect(unit.scriptTag, isNull); | 13294 expect(unit.scriptTag, isNull); |
| 13233 expect(unit.directives, hasLength(0)); | 13295 expect(unit.directives, hasLength(0)); |
| 13234 expect(unit.declarations, hasLength(1)); | 13296 expect(unit.declarations, hasLength(1)); |
| 13235 } | 13297 } |
| 13236 | 13298 |
| 13237 void test_parseCompilationUnit_exportAsPrefix_parameterized() { | 13299 void test_parseCompilationUnit_exportAsPrefix_parameterized() { |
| 13238 createParser('export<dynamic> _export = new export.A();'); | 13300 createParser('export<dynamic> _export = new export.A();'); |
| 13239 CompilationUnit unit = parser.parseCompilationUnit2(); | 13301 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13240 expectNotNullIfNoErrors(unit); | 13302 expect(unit, isNotNull); |
| 13241 listener.assertNoErrors(); | 13303 assertNoErrors(); |
| 13242 expect(unit.scriptTag, isNull); | 13304 expect(unit.scriptTag, isNull); |
| 13243 expect(unit.directives, hasLength(0)); | 13305 expect(unit.directives, hasLength(0)); |
| 13244 expect(unit.declarations, hasLength(1)); | 13306 expect(unit.declarations, hasLength(1)); |
| 13245 } | 13307 } |
| 13246 | 13308 |
| 13247 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { | 13309 void test_parseCompilationUnit_operatorAsPrefix_parameterized() { |
| 13248 createParser('operator<dynamic> _operator = new operator.A();'); | 13310 createParser('operator<dynamic> _operator = new operator.A();'); |
| 13249 CompilationUnit unit = parser.parseCompilationUnit2(); | 13311 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13250 expectNotNullIfNoErrors(unit); | 13312 expect(unit, isNotNull); |
| 13251 listener.assertNoErrors(); | 13313 assertNoErrors(); |
| 13252 expect(unit.scriptTag, isNull); | 13314 expect(unit.scriptTag, isNull); |
| 13253 expect(unit.directives, hasLength(0)); | 13315 expect(unit.directives, hasLength(0)); |
| 13254 expect(unit.declarations, hasLength(1)); | 13316 expect(unit.declarations, hasLength(1)); |
| 13255 } | 13317 } |
| 13256 | 13318 |
| 13257 void test_parseCompilationUnit_script() { | 13319 void test_parseCompilationUnit_script() { |
| 13258 createParser('#! /bin/dart'); | 13320 createParser('#! /bin/dart'); |
| 13259 CompilationUnit unit = parser.parseCompilationUnit2(); | 13321 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13260 expectNotNullIfNoErrors(unit); | 13322 expect(unit, isNotNull); |
| 13261 listener.assertNoErrors(); | 13323 assertNoErrors(); |
| 13262 expect(unit.scriptTag, isNotNull); | 13324 expect(unit.scriptTag, isNotNull); |
| 13263 expect(unit.directives, hasLength(0)); | 13325 expect(unit.directives, hasLength(0)); |
| 13264 expect(unit.declarations, hasLength(0)); | 13326 expect(unit.declarations, hasLength(0)); |
| 13265 } | 13327 } |
| 13266 | 13328 |
| 13267 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { | 13329 void test_parseCompilationUnit_skipFunctionBody_withInterpolation() { |
| 13268 ParserTestCase.parseFunctionBodies = false; | 13330 ParserTestCase.parseFunctionBodies = false; |
| 13269 createParser('f() { "\${n}"; }'); | 13331 createParser('f() { "\${n}"; }'); |
| 13270 CompilationUnit unit = parser.parseCompilationUnit2(); | 13332 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13271 expectNotNullIfNoErrors(unit); | 13333 expect(unit, isNotNull); |
| 13272 listener.assertNoErrors(); | 13334 assertNoErrors(); |
| 13273 expect(unit.scriptTag, isNull); | 13335 expect(unit.scriptTag, isNull); |
| 13274 expect(unit.declarations, hasLength(1)); | 13336 expect(unit.declarations, hasLength(1)); |
| 13275 } | 13337 } |
| 13276 | 13338 |
| 13277 void test_parseCompilationUnit_topLevelDeclaration() { | 13339 void test_parseCompilationUnit_topLevelDeclaration() { |
| 13278 createParser('class A {}'); | 13340 createParser('class A {}'); |
| 13279 CompilationUnit unit = parser.parseCompilationUnit2(); | 13341 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13280 expectNotNullIfNoErrors(unit); | 13342 expect(unit, isNotNull); |
| 13281 listener.assertNoErrors(); | 13343 assertNoErrors(); |
| 13282 expect(unit.scriptTag, isNull); | 13344 expect(unit.scriptTag, isNull); |
| 13283 expect(unit.directives, hasLength(0)); | 13345 expect(unit.directives, hasLength(0)); |
| 13284 expect(unit.declarations, hasLength(1)); | 13346 expect(unit.declarations, hasLength(1)); |
| 13285 } | 13347 } |
| 13286 | 13348 |
| 13287 void test_parseCompilationUnit_typedefAsPrefix() { | 13349 void test_parseCompilationUnit_typedefAsPrefix() { |
| 13288 createParser('typedef.A _typedef = new typedef.A();'); | 13350 createParser('typedef.A _typedef = new typedef.A();'); |
| 13289 CompilationUnit unit = parser.parseCompilationUnit2(); | 13351 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13290 expectNotNullIfNoErrors(unit); | 13352 expect(unit, isNotNull); |
| 13291 listener.assertNoErrors(); | 13353 assertNoErrors(); |
| 13292 expect(unit.scriptTag, isNull); | 13354 expect(unit.scriptTag, isNull); |
| 13293 expect(unit.directives, hasLength(0)); | 13355 expect(unit.directives, hasLength(0)); |
| 13294 expect(unit.declarations, hasLength(1)); | 13356 expect(unit.declarations, hasLength(1)); |
| 13295 } | 13357 } |
| 13296 | 13358 |
| 13297 void test_parseCompilationUnitMember_abstractAsPrefix() { | 13359 void test_parseCompilationUnitMember_abstractAsPrefix() { |
| 13298 createParser('abstract.A _abstract = new abstract.A();'); | 13360 createParser('abstract.A _abstract = new abstract.A();'); |
| 13299 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13361 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13300 expectNotNullIfNoErrors(member); | 13362 expect(member, isNotNull); |
| 13301 listener.assertNoErrors(); | 13363 assertNoErrors(); |
| 13302 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13364 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13303 TopLevelVariableDeclaration declaration = member; | 13365 TopLevelVariableDeclaration declaration = member; |
| 13304 expect(declaration.semicolon, isNotNull); | 13366 expect(declaration.semicolon, isNotNull); |
| 13305 expect(declaration.variables, isNotNull); | 13367 expect(declaration.variables, isNotNull); |
| 13306 } | 13368 } |
| 13307 | 13369 |
| 13308 void test_parseCompilationUnitMember_class() { | 13370 void test_parseCompilationUnitMember_class() { |
| 13309 createParser('class A {}'); | 13371 createParser('class A {}'); |
| 13310 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13372 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13311 expectNotNullIfNoErrors(member); | 13373 expect(member, isNotNull); |
| 13312 listener.assertNoErrors(); | 13374 assertNoErrors(); |
| 13313 expect(member, new isInstanceOf<ClassDeclaration>()); | 13375 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13314 ClassDeclaration declaration = member; | 13376 ClassDeclaration declaration = member; |
| 13315 expect(declaration.name.name, "A"); | 13377 expect(declaration.name.name, "A"); |
| 13316 expect(declaration.members, hasLength(0)); | 13378 expect(declaration.members, hasLength(0)); |
| 13317 } | 13379 } |
| 13318 | 13380 |
| 13319 void test_parseCompilationUnitMember_classTypeAlias() { | 13381 void test_parseCompilationUnitMember_classTypeAlias() { |
| 13320 createParser('abstract class A = B with C;'); | 13382 createParser('abstract class A = B with C;'); |
| 13321 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13383 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13322 expectNotNullIfNoErrors(member); | 13384 expect(member, isNotNull); |
| 13323 listener.assertNoErrors(); | 13385 assertNoErrors(); |
| 13324 expect(member, new isInstanceOf<ClassTypeAlias>()); | 13386 expect(member, new isInstanceOf<ClassTypeAlias>()); |
| 13325 ClassTypeAlias declaration = member; | 13387 ClassTypeAlias declaration = member; |
| 13326 expect(declaration.name.name, "A"); | 13388 expect(declaration.name.name, "A"); |
| 13327 expect(declaration.abstractKeyword, isNotNull); | 13389 expect(declaration.abstractKeyword, isNotNull); |
| 13328 } | 13390 } |
| 13329 | 13391 |
| 13330 void test_parseCompilationUnitMember_constVariable() { | 13392 void test_parseCompilationUnitMember_constVariable() { |
| 13331 createParser('const int x = 0;'); | 13393 createParser('const int x = 0;'); |
| 13332 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13394 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13333 expectNotNullIfNoErrors(member); | 13395 expect(member, isNotNull); |
| 13334 listener.assertNoErrors(); | 13396 assertNoErrors(); |
| 13335 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13397 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13336 TopLevelVariableDeclaration declaration = member; | 13398 TopLevelVariableDeclaration declaration = member; |
| 13337 expect(declaration.semicolon, isNotNull); | 13399 expect(declaration.semicolon, isNotNull); |
| 13338 expect(declaration.variables, isNotNull); | 13400 expect(declaration.variables, isNotNull); |
| 13339 } | 13401 } |
| 13340 | 13402 |
| 13341 void test_parseCompilationUnitMember_finalVariable() { | 13403 void test_parseCompilationUnitMember_finalVariable() { |
| 13342 createParser('final x = 0;'); | 13404 createParser('final x = 0;'); |
| 13343 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13405 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13344 expectNotNullIfNoErrors(member); | 13406 expect(member, isNotNull); |
| 13345 listener.assertNoErrors(); | 13407 assertNoErrors(); |
| 13346 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13408 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13347 TopLevelVariableDeclaration declaration = member; | 13409 TopLevelVariableDeclaration declaration = member; |
| 13348 expect(declaration.semicolon, isNotNull); | 13410 expect(declaration.semicolon, isNotNull); |
| 13349 expect(declaration.variables, isNotNull); | 13411 expect(declaration.variables, isNotNull); |
| 13350 } | 13412 } |
| 13351 | 13413 |
| 13352 void test_parseCompilationUnitMember_function_external_noType() { | 13414 void test_parseCompilationUnitMember_function_external_noType() { |
| 13353 createParser('external f();'); | 13415 createParser('external f();'); |
| 13354 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13416 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13355 expectNotNullIfNoErrors(member); | 13417 expect(member, isNotNull); |
| 13356 listener.assertNoErrors(); | 13418 assertNoErrors(); |
| 13357 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13419 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13358 FunctionDeclaration declaration = member; | 13420 FunctionDeclaration declaration = member; |
| 13359 expect(declaration.externalKeyword, isNotNull); | 13421 expect(declaration.externalKeyword, isNotNull); |
| 13360 expect(declaration.functionExpression, isNotNull); | 13422 expect(declaration.functionExpression, isNotNull); |
| 13361 expect(declaration.propertyKeyword, isNull); | 13423 expect(declaration.propertyKeyword, isNull); |
| 13362 } | 13424 } |
| 13363 | 13425 |
| 13364 void test_parseCompilationUnitMember_function_external_type() { | 13426 void test_parseCompilationUnitMember_function_external_type() { |
| 13365 createParser('external int f();'); | 13427 createParser('external int f();'); |
| 13366 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13428 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13367 expectNotNullIfNoErrors(member); | 13429 expect(member, isNotNull); |
| 13368 listener.assertNoErrors(); | 13430 assertNoErrors(); |
| 13369 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13431 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13370 FunctionDeclaration declaration = member; | 13432 FunctionDeclaration declaration = member; |
| 13371 expect(declaration.externalKeyword, isNotNull); | 13433 expect(declaration.externalKeyword, isNotNull); |
| 13372 expect(declaration.functionExpression, isNotNull); | 13434 expect(declaration.functionExpression, isNotNull); |
| 13373 expect(declaration.propertyKeyword, isNull); | 13435 expect(declaration.propertyKeyword, isNull); |
| 13374 } | 13436 } |
| 13375 | 13437 |
| 13376 void test_parseCompilationUnitMember_function_generic_noReturnType() { | 13438 void test_parseCompilationUnitMember_function_generic_noReturnType() { |
| 13377 createParser('f<E>() {}'); | 13439 createParser('f<E>() {}'); |
| 13378 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13440 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13379 expectNotNullIfNoErrors(member); | 13441 expect(member, isNotNull); |
| 13380 listener.assertNoErrors(); | 13442 assertNoErrors(); |
| 13381 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13443 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13382 FunctionDeclaration declaration = member; | 13444 FunctionDeclaration declaration = member; |
| 13383 expect(declaration.returnType, isNull); | 13445 expect(declaration.returnType, isNull); |
| 13384 expect(declaration.functionExpression.typeParameters, isNotNull); | 13446 expect(declaration.functionExpression.typeParameters, isNotNull); |
| 13385 } | 13447 } |
| 13386 | 13448 |
| 13387 void | 13449 void |
| 13388 test_parseCompilationUnitMember_function_generic_noReturnType_annotated()
{ | 13450 test_parseCompilationUnitMember_function_generic_noReturnType_annotated()
{ |
| 13389 createParser('f<@a E>() {}'); | 13451 createParser('f<@a E>() {}'); |
| 13390 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13452 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13391 expectNotNullIfNoErrors(member); | 13453 expect(member, isNotNull); |
| 13392 listener.assertNoErrors(); | 13454 assertNoErrors(); |
| 13393 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13455 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13394 FunctionDeclaration declaration = member; | 13456 FunctionDeclaration declaration = member; |
| 13395 expect(declaration.returnType, isNull); | 13457 expect(declaration.returnType, isNull); |
| 13396 expect(declaration.functionExpression.typeParameters, isNotNull); | 13458 expect(declaration.functionExpression.typeParameters, isNotNull); |
| 13397 } | 13459 } |
| 13398 | 13460 |
| 13399 void test_parseCompilationUnitMember_function_generic_returnType() { | 13461 void test_parseCompilationUnitMember_function_generic_returnType() { |
| 13400 createParser('E f<E>() {}'); | 13462 createParser('E f<E>() {}'); |
| 13401 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13463 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13402 expectNotNullIfNoErrors(member); | 13464 expect(member, isNotNull); |
| 13403 listener.assertNoErrors(); | 13465 assertNoErrors(); |
| 13404 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13466 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13405 FunctionDeclaration declaration = member; | 13467 FunctionDeclaration declaration = member; |
| 13406 expect(declaration.returnType, isNotNull); | 13468 expect(declaration.returnType, isNotNull); |
| 13407 expect(declaration.functionExpression.typeParameters, isNotNull); | 13469 expect(declaration.functionExpression.typeParameters, isNotNull); |
| 13408 } | 13470 } |
| 13409 | 13471 |
| 13410 void test_parseCompilationUnitMember_function_generic_void() { | 13472 void test_parseCompilationUnitMember_function_generic_void() { |
| 13411 createParser('void f<T>(T t) {}'); | 13473 createParser('void f<T>(T t) {}'); |
| 13412 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13474 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13413 expectNotNullIfNoErrors(member); | 13475 expect(member, isNotNull); |
| 13414 listener.assertNoErrors(); | 13476 assertNoErrors(); |
| 13415 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13477 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13416 FunctionDeclaration declaration = member; | 13478 FunctionDeclaration declaration = member; |
| 13417 expect(declaration.functionExpression, isNotNull); | 13479 expect(declaration.functionExpression, isNotNull); |
| 13418 expect(declaration.propertyKeyword, isNull); | 13480 expect(declaration.propertyKeyword, isNull); |
| 13419 } | 13481 } |
| 13420 | 13482 |
| 13421 void test_parseCompilationUnitMember_function_noType() { | 13483 void test_parseCompilationUnitMember_function_noType() { |
| 13422 createParser('f() {}'); | 13484 createParser('f() {}'); |
| 13423 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13485 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13424 expectNotNullIfNoErrors(member); | 13486 expect(member, isNotNull); |
| 13425 listener.assertNoErrors(); | 13487 assertNoErrors(); |
| 13426 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13488 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13427 FunctionDeclaration declaration = member; | 13489 FunctionDeclaration declaration = member; |
| 13428 expect(declaration.functionExpression, isNotNull); | 13490 expect(declaration.functionExpression, isNotNull); |
| 13429 expect(declaration.propertyKeyword, isNull); | 13491 expect(declaration.propertyKeyword, isNull); |
| 13430 } | 13492 } |
| 13431 | 13493 |
| 13432 void test_parseCompilationUnitMember_function_type() { | 13494 void test_parseCompilationUnitMember_function_type() { |
| 13433 createParser('int f() {}'); | 13495 createParser('int f() {}'); |
| 13434 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13496 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13435 expectNotNullIfNoErrors(member); | 13497 expect(member, isNotNull); |
| 13436 listener.assertNoErrors(); | 13498 assertNoErrors(); |
| 13437 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13499 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13438 FunctionDeclaration declaration = member; | 13500 FunctionDeclaration declaration = member; |
| 13439 expect(declaration.functionExpression, isNotNull); | 13501 expect(declaration.functionExpression, isNotNull); |
| 13440 expect(declaration.propertyKeyword, isNull); | 13502 expect(declaration.propertyKeyword, isNull); |
| 13441 } | 13503 } |
| 13442 | 13504 |
| 13443 void test_parseCompilationUnitMember_function_void() { | 13505 void test_parseCompilationUnitMember_function_void() { |
| 13444 createParser('void f() {}'); | 13506 createParser('void f() {}'); |
| 13445 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13507 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13446 expectNotNullIfNoErrors(member); | 13508 expect(member, isNotNull); |
| 13447 listener.assertNoErrors(); | 13509 assertNoErrors(); |
| 13448 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13510 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13449 FunctionDeclaration declaration = member; | 13511 FunctionDeclaration declaration = member; |
| 13450 expect(declaration.returnType, isNotNull); | 13512 expect(declaration.returnType, isNotNull); |
| 13451 } | 13513 } |
| 13452 | 13514 |
| 13453 void test_parseCompilationUnitMember_getter_external_noType() { | 13515 void test_parseCompilationUnitMember_getter_external_noType() { |
| 13454 createParser('external get p;'); | 13516 createParser('external get p;'); |
| 13455 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13517 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13456 expectNotNullIfNoErrors(member); | 13518 expect(member, isNotNull); |
| 13457 listener.assertNoErrors(); | 13519 assertNoErrors(); |
| 13458 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13520 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13459 FunctionDeclaration declaration = member; | 13521 FunctionDeclaration declaration = member; |
| 13460 expect(declaration.externalKeyword, isNotNull); | 13522 expect(declaration.externalKeyword, isNotNull); |
| 13461 expect(declaration.functionExpression, isNotNull); | 13523 expect(declaration.functionExpression, isNotNull); |
| 13462 expect(declaration.propertyKeyword, isNotNull); | 13524 expect(declaration.propertyKeyword, isNotNull); |
| 13463 } | 13525 } |
| 13464 | 13526 |
| 13465 void test_parseCompilationUnitMember_getter_external_type() { | 13527 void test_parseCompilationUnitMember_getter_external_type() { |
| 13466 createParser('external int get p;'); | 13528 createParser('external int get p;'); |
| 13467 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13529 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13468 expectNotNullIfNoErrors(member); | 13530 expect(member, isNotNull); |
| 13469 listener.assertNoErrors(); | 13531 assertNoErrors(); |
| 13470 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13532 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13471 FunctionDeclaration declaration = member; | 13533 FunctionDeclaration declaration = member; |
| 13472 expect(declaration.externalKeyword, isNotNull); | 13534 expect(declaration.externalKeyword, isNotNull); |
| 13473 expect(declaration.functionExpression, isNotNull); | 13535 expect(declaration.functionExpression, isNotNull); |
| 13474 expect(declaration.propertyKeyword, isNotNull); | 13536 expect(declaration.propertyKeyword, isNotNull); |
| 13475 } | 13537 } |
| 13476 | 13538 |
| 13477 void test_parseCompilationUnitMember_getter_noType() { | 13539 void test_parseCompilationUnitMember_getter_noType() { |
| 13478 createParser('get p => 0;'); | 13540 createParser('get p => 0;'); |
| 13479 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13541 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13480 expectNotNullIfNoErrors(member); | 13542 expect(member, isNotNull); |
| 13481 listener.assertNoErrors(); | 13543 assertNoErrors(); |
| 13482 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13544 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13483 FunctionDeclaration declaration = member; | 13545 FunctionDeclaration declaration = member; |
| 13484 expect(declaration.functionExpression, isNotNull); | 13546 expect(declaration.functionExpression, isNotNull); |
| 13485 expect(declaration.propertyKeyword, isNotNull); | 13547 expect(declaration.propertyKeyword, isNotNull); |
| 13486 } | 13548 } |
| 13487 | 13549 |
| 13488 void test_parseCompilationUnitMember_getter_type() { | 13550 void test_parseCompilationUnitMember_getter_type() { |
| 13489 createParser('int get p => 0;'); | 13551 createParser('int get p => 0;'); |
| 13490 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13552 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13491 expectNotNullIfNoErrors(member); | 13553 expect(member, isNotNull); |
| 13492 listener.assertNoErrors(); | 13554 assertNoErrors(); |
| 13493 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13555 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13494 FunctionDeclaration declaration = member; | 13556 FunctionDeclaration declaration = member; |
| 13495 expect(declaration.functionExpression, isNotNull); | 13557 expect(declaration.functionExpression, isNotNull); |
| 13496 expect(declaration.propertyKeyword, isNotNull); | 13558 expect(declaration.propertyKeyword, isNotNull); |
| 13497 } | 13559 } |
| 13498 | 13560 |
| 13499 void test_parseCompilationUnitMember_setter_external_noType() { | 13561 void test_parseCompilationUnitMember_setter_external_noType() { |
| 13500 createParser('external set p(v);'); | 13562 createParser('external set p(v);'); |
| 13501 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13563 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13502 expectNotNullIfNoErrors(member); | 13564 expect(member, isNotNull); |
| 13503 listener.assertNoErrors(); | 13565 assertNoErrors(); |
| 13504 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13566 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13505 FunctionDeclaration declaration = member; | 13567 FunctionDeclaration declaration = member; |
| 13506 expect(declaration.externalKeyword, isNotNull); | 13568 expect(declaration.externalKeyword, isNotNull); |
| 13507 expect(declaration.functionExpression, isNotNull); | 13569 expect(declaration.functionExpression, isNotNull); |
| 13508 expect(declaration.propertyKeyword, isNotNull); | 13570 expect(declaration.propertyKeyword, isNotNull); |
| 13509 } | 13571 } |
| 13510 | 13572 |
| 13511 void test_parseCompilationUnitMember_setter_external_type() { | 13573 void test_parseCompilationUnitMember_setter_external_type() { |
| 13512 createParser('external void set p(int v);'); | 13574 createParser('external void set p(int v);'); |
| 13513 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13575 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13514 expectNotNullIfNoErrors(member); | 13576 expect(member, isNotNull); |
| 13515 listener.assertNoErrors(); | 13577 assertNoErrors(); |
| 13516 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13578 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13517 FunctionDeclaration declaration = member; | 13579 FunctionDeclaration declaration = member; |
| 13518 expect(declaration.externalKeyword, isNotNull); | 13580 expect(declaration.externalKeyword, isNotNull); |
| 13519 expect(declaration.functionExpression, isNotNull); | 13581 expect(declaration.functionExpression, isNotNull); |
| 13520 expect(declaration.propertyKeyword, isNotNull); | 13582 expect(declaration.propertyKeyword, isNotNull); |
| 13521 } | 13583 } |
| 13522 | 13584 |
| 13523 void test_parseCompilationUnitMember_setter_noType() { | 13585 void test_parseCompilationUnitMember_setter_noType() { |
| 13524 createParser('set p(v) {}'); | 13586 createParser('set p(v) {}'); |
| 13525 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13587 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13526 expectNotNullIfNoErrors(member); | 13588 expect(member, isNotNull); |
| 13527 listener.assertNoErrors(); | 13589 assertNoErrors(); |
| 13528 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13590 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13529 FunctionDeclaration declaration = member; | 13591 FunctionDeclaration declaration = member; |
| 13530 expect(declaration.functionExpression, isNotNull); | 13592 expect(declaration.functionExpression, isNotNull); |
| 13531 expect(declaration.propertyKeyword, isNotNull); | 13593 expect(declaration.propertyKeyword, isNotNull); |
| 13532 } | 13594 } |
| 13533 | 13595 |
| 13534 void test_parseCompilationUnitMember_setter_type() { | 13596 void test_parseCompilationUnitMember_setter_type() { |
| 13535 createParser('void set p(int v) {}'); | 13597 createParser('void set p(int v) {}'); |
| 13536 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13598 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13537 expectNotNullIfNoErrors(member); | 13599 expect(member, isNotNull); |
| 13538 listener.assertNoErrors(); | 13600 assertNoErrors(); |
| 13539 expect(member, new isInstanceOf<FunctionDeclaration>()); | 13601 expect(member, new isInstanceOf<FunctionDeclaration>()); |
| 13540 FunctionDeclaration declaration = member; | 13602 FunctionDeclaration declaration = member; |
| 13541 expect(declaration.functionExpression, isNotNull); | 13603 expect(declaration.functionExpression, isNotNull); |
| 13542 expect(declaration.propertyKeyword, isNotNull); | 13604 expect(declaration.propertyKeyword, isNotNull); |
| 13543 expect(declaration.returnType, isNotNull); | 13605 expect(declaration.returnType, isNotNull); |
| 13544 } | 13606 } |
| 13545 | 13607 |
| 13546 void test_parseCompilationUnitMember_typeAlias_abstract() { | 13608 void test_parseCompilationUnitMember_typeAlias_abstract() { |
| 13547 createParser('abstract class C = S with M;'); | 13609 createParser('abstract class C = S with M;'); |
| 13548 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13610 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13549 expectNotNullIfNoErrors(member); | 13611 expect(member, isNotNull); |
| 13550 listener.assertNoErrors(); | 13612 assertNoErrors(); |
| 13551 expect(member, new isInstanceOf<ClassTypeAlias>()); | 13613 expect(member, new isInstanceOf<ClassTypeAlias>()); |
| 13552 ClassTypeAlias typeAlias = member; | 13614 ClassTypeAlias typeAlias = member; |
| 13553 expect(typeAlias.typedefKeyword, isNotNull); | 13615 expect(typeAlias.typedefKeyword, isNotNull); |
| 13554 expect(typeAlias.name.name, "C"); | 13616 expect(typeAlias.name.name, "C"); |
| 13555 expect(typeAlias.typeParameters, isNull); | 13617 expect(typeAlias.typeParameters, isNull); |
| 13556 expect(typeAlias.equals, isNotNull); | 13618 expect(typeAlias.equals, isNotNull); |
| 13557 expect(typeAlias.abstractKeyword, isNotNull); | 13619 expect(typeAlias.abstractKeyword, isNotNull); |
| 13558 expect(typeAlias.superclass.name.name, "S"); | 13620 expect(typeAlias.superclass.name.name, "S"); |
| 13559 expect(typeAlias.withClause, isNotNull); | 13621 expect(typeAlias.withClause, isNotNull); |
| 13560 expect(typeAlias.implementsClause, isNull); | 13622 expect(typeAlias.implementsClause, isNull); |
| 13561 expect(typeAlias.semicolon, isNotNull); | 13623 expect(typeAlias.semicolon, isNotNull); |
| 13562 } | 13624 } |
| 13563 | 13625 |
| 13564 void test_parseCompilationUnitMember_typeAlias_generic() { | 13626 void test_parseCompilationUnitMember_typeAlias_generic() { |
| 13565 createParser('class C<E> = S<E> with M<E> implements I<E>;'); | 13627 createParser('class C<E> = S<E> with M<E> implements I<E>;'); |
| 13566 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13628 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13567 expectNotNullIfNoErrors(member); | 13629 expect(member, isNotNull); |
| 13568 listener.assertNoErrors(); | 13630 assertNoErrors(); |
| 13569 expect(member, new isInstanceOf<ClassTypeAlias>()); | 13631 expect(member, new isInstanceOf<ClassTypeAlias>()); |
| 13570 ClassTypeAlias typeAlias = member; | 13632 ClassTypeAlias typeAlias = member; |
| 13571 expect(typeAlias.typedefKeyword, isNotNull); | 13633 expect(typeAlias.typedefKeyword, isNotNull); |
| 13572 expect(typeAlias.name.name, "C"); | 13634 expect(typeAlias.name.name, "C"); |
| 13573 expect(typeAlias.typeParameters.typeParameters, hasLength(1)); | 13635 expect(typeAlias.typeParameters.typeParameters, hasLength(1)); |
| 13574 expect(typeAlias.equals, isNotNull); | 13636 expect(typeAlias.equals, isNotNull); |
| 13575 expect(typeAlias.abstractKeyword, isNull); | 13637 expect(typeAlias.abstractKeyword, isNull); |
| 13576 expect(typeAlias.superclass.name.name, "S"); | 13638 expect(typeAlias.superclass.name.name, "S"); |
| 13577 expect(typeAlias.withClause, isNotNull); | 13639 expect(typeAlias.withClause, isNotNull); |
| 13578 expect(typeAlias.implementsClause, isNotNull); | 13640 expect(typeAlias.implementsClause, isNotNull); |
| 13579 expect(typeAlias.semicolon, isNotNull); | 13641 expect(typeAlias.semicolon, isNotNull); |
| 13580 } | 13642 } |
| 13581 | 13643 |
| 13582 void test_parseCompilationUnitMember_typeAlias_implements() { | 13644 void test_parseCompilationUnitMember_typeAlias_implements() { |
| 13583 createParser('class C = S with M implements I;'); | 13645 createParser('class C = S with M implements I;'); |
| 13584 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13646 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13585 expectNotNullIfNoErrors(member); | 13647 expect(member, isNotNull); |
| 13586 listener.assertNoErrors(); | 13648 assertNoErrors(); |
| 13587 expect(member, new isInstanceOf<ClassTypeAlias>()); | 13649 expect(member, new isInstanceOf<ClassTypeAlias>()); |
| 13588 ClassTypeAlias typeAlias = member; | 13650 ClassTypeAlias typeAlias = member; |
| 13589 expect(typeAlias.typedefKeyword, isNotNull); | 13651 expect(typeAlias.typedefKeyword, isNotNull); |
| 13590 expect(typeAlias.name.name, "C"); | 13652 expect(typeAlias.name.name, "C"); |
| 13591 expect(typeAlias.typeParameters, isNull); | 13653 expect(typeAlias.typeParameters, isNull); |
| 13592 expect(typeAlias.equals, isNotNull); | 13654 expect(typeAlias.equals, isNotNull); |
| 13593 expect(typeAlias.abstractKeyword, isNull); | 13655 expect(typeAlias.abstractKeyword, isNull); |
| 13594 expect(typeAlias.superclass.name.name, "S"); | 13656 expect(typeAlias.superclass.name.name, "S"); |
| 13595 expect(typeAlias.withClause, isNotNull); | 13657 expect(typeAlias.withClause, isNotNull); |
| 13596 expect(typeAlias.implementsClause, isNotNull); | 13658 expect(typeAlias.implementsClause, isNotNull); |
| 13597 expect(typeAlias.semicolon, isNotNull); | 13659 expect(typeAlias.semicolon, isNotNull); |
| 13598 } | 13660 } |
| 13599 | 13661 |
| 13600 void test_parseCompilationUnitMember_typeAlias_noImplements() { | 13662 void test_parseCompilationUnitMember_typeAlias_noImplements() { |
| 13601 createParser('class C = S with M;'); | 13663 createParser('class C = S with M;'); |
| 13602 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13664 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13603 expectNotNullIfNoErrors(member); | 13665 expect(member, isNotNull); |
| 13604 listener.assertNoErrors(); | 13666 assertNoErrors(); |
| 13605 expect(member, new isInstanceOf<ClassTypeAlias>()); | 13667 expect(member, new isInstanceOf<ClassTypeAlias>()); |
| 13606 ClassTypeAlias typeAlias = member; | 13668 ClassTypeAlias typeAlias = member; |
| 13607 expect(typeAlias.typedefKeyword, isNotNull); | 13669 expect(typeAlias.typedefKeyword, isNotNull); |
| 13608 expect(typeAlias.name.name, "C"); | 13670 expect(typeAlias.name.name, "C"); |
| 13609 expect(typeAlias.typeParameters, isNull); | 13671 expect(typeAlias.typeParameters, isNull); |
| 13610 expect(typeAlias.equals, isNotNull); | 13672 expect(typeAlias.equals, isNotNull); |
| 13611 expect(typeAlias.abstractKeyword, isNull); | 13673 expect(typeAlias.abstractKeyword, isNull); |
| 13612 expect(typeAlias.superclass.name.name, "S"); | 13674 expect(typeAlias.superclass.name.name, "S"); |
| 13613 expect(typeAlias.withClause, isNotNull); | 13675 expect(typeAlias.withClause, isNotNull); |
| 13614 expect(typeAlias.implementsClause, isNull); | 13676 expect(typeAlias.implementsClause, isNull); |
| 13615 expect(typeAlias.semicolon, isNotNull); | 13677 expect(typeAlias.semicolon, isNotNull); |
| 13616 } | 13678 } |
| 13617 | 13679 |
| 13618 void test_parseCompilationUnitMember_typedef() { | 13680 void test_parseCompilationUnitMember_typedef() { |
| 13619 createParser('typedef F();'); | 13681 createParser('typedef F();'); |
| 13620 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13682 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13621 expectNotNullIfNoErrors(member); | 13683 expect(member, isNotNull); |
| 13622 listener.assertNoErrors(); | 13684 assertNoErrors(); |
| 13623 expect(member, new isInstanceOf<FunctionTypeAlias>()); | 13685 expect(member, new isInstanceOf<FunctionTypeAlias>()); |
| 13624 FunctionTypeAlias typeAlias = member; | 13686 FunctionTypeAlias typeAlias = member; |
| 13625 expect(typeAlias.name.name, "F"); | 13687 expect(typeAlias.name.name, "F"); |
| 13626 expect(typeAlias.parameters.parameters, hasLength(0)); | 13688 expect(typeAlias.parameters.parameters, hasLength(0)); |
| 13627 } | 13689 } |
| 13628 | 13690 |
| 13629 void test_parseCompilationUnitMember_variable() { | 13691 void test_parseCompilationUnitMember_variable() { |
| 13630 createParser('var x = 0;'); | 13692 createParser('var x = 0;'); |
| 13631 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13693 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13632 expectNotNullIfNoErrors(member); | 13694 expect(member, isNotNull); |
| 13633 listener.assertNoErrors(); | 13695 assertNoErrors(); |
| 13634 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13696 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13635 TopLevelVariableDeclaration declaration = member; | 13697 TopLevelVariableDeclaration declaration = member; |
| 13636 expect(declaration.semicolon, isNotNull); | 13698 expect(declaration.semicolon, isNotNull); |
| 13637 expect(declaration.variables, isNotNull); | 13699 expect(declaration.variables, isNotNull); |
| 13638 } | 13700 } |
| 13639 | 13701 |
| 13640 void test_parseCompilationUnitMember_variableGet() { | 13702 void test_parseCompilationUnitMember_variableGet() { |
| 13641 createParser('String get = null;'); | 13703 createParser('String get = null;'); |
| 13642 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13704 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13643 expectNotNullIfNoErrors(member); | 13705 expect(member, isNotNull); |
| 13644 listener.assertNoErrors(); | 13706 assertNoErrors(); |
| 13645 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13707 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13646 TopLevelVariableDeclaration declaration = member; | 13708 TopLevelVariableDeclaration declaration = member; |
| 13647 expect(declaration.semicolon, isNotNull); | 13709 expect(declaration.semicolon, isNotNull); |
| 13648 expect(declaration.variables, isNotNull); | 13710 expect(declaration.variables, isNotNull); |
| 13649 } | 13711 } |
| 13650 | 13712 |
| 13651 void test_parseCompilationUnitMember_variableSet() { | 13713 void test_parseCompilationUnitMember_variableSet() { |
| 13652 createParser('String set = null;'); | 13714 createParser('String set = null;'); |
| 13653 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13715 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13654 expectNotNullIfNoErrors(member); | 13716 expect(member, isNotNull); |
| 13655 listener.assertNoErrors(); | 13717 assertNoErrors(); |
| 13656 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13718 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13657 TopLevelVariableDeclaration declaration = member; | 13719 TopLevelVariableDeclaration declaration = member; |
| 13658 expect(declaration.semicolon, isNotNull); | 13720 expect(declaration.semicolon, isNotNull); |
| 13659 expect(declaration.variables, isNotNull); | 13721 expect(declaration.variables, isNotNull); |
| 13660 } | 13722 } |
| 13661 | 13723 |
| 13662 void test_parseDirective_export() { | 13724 void test_parseDirective_export() { |
| 13663 createParser("export 'lib/lib.dart';"); | 13725 createParser("export 'lib/lib.dart';"); |
| 13664 Directive directive = parseFullDirective(); | 13726 Directive directive = parseFullDirective(); |
| 13665 expectNotNullIfNoErrors(directive); | 13727 expect(directive, isNotNull); |
| 13666 listener.assertNoErrors(); | 13728 assertNoErrors(); |
| 13667 expect(directive, new isInstanceOf<ExportDirective>()); | 13729 expect(directive, new isInstanceOf<ExportDirective>()); |
| 13668 ExportDirective exportDirective = directive; | 13730 ExportDirective exportDirective = directive; |
| 13669 expect(exportDirective.keyword, isNotNull); | 13731 expect(exportDirective.keyword, isNotNull); |
| 13670 expect(exportDirective.uri, isNotNull); | 13732 expect(exportDirective.uri, isNotNull); |
| 13671 expect(exportDirective.combinators, hasLength(0)); | 13733 expect(exportDirective.combinators, hasLength(0)); |
| 13672 expect(exportDirective.semicolon, isNotNull); | 13734 expect(exportDirective.semicolon, isNotNull); |
| 13673 } | 13735 } |
| 13674 | 13736 |
| 13675 void test_parseDirective_import() { | 13737 void test_parseDirective_import() { |
| 13676 createParser("import 'lib/lib.dart';"); | 13738 createParser("import 'lib/lib.dart';"); |
| 13677 Directive directive = parseFullDirective(); | 13739 Directive directive = parseFullDirective(); |
| 13678 expectNotNullIfNoErrors(directive); | 13740 expect(directive, isNotNull); |
| 13679 listener.assertNoErrors(); | 13741 assertNoErrors(); |
| 13680 expect(directive, new isInstanceOf<ImportDirective>()); | 13742 expect(directive, new isInstanceOf<ImportDirective>()); |
| 13681 ImportDirective importDirective = directive; | 13743 ImportDirective importDirective = directive; |
| 13682 expect(importDirective.keyword, isNotNull); | 13744 expect(importDirective.keyword, isNotNull); |
| 13683 expect(importDirective.uri, isNotNull); | 13745 expect(importDirective.uri, isNotNull); |
| 13684 expect(importDirective.asKeyword, isNull); | 13746 expect(importDirective.asKeyword, isNull); |
| 13685 expect(importDirective.prefix, isNull); | 13747 expect(importDirective.prefix, isNull); |
| 13686 expect(importDirective.combinators, hasLength(0)); | 13748 expect(importDirective.combinators, hasLength(0)); |
| 13687 expect(importDirective.semicolon, isNotNull); | 13749 expect(importDirective.semicolon, isNotNull); |
| 13688 } | 13750 } |
| 13689 | 13751 |
| 13690 void test_parseDirective_library() { | 13752 void test_parseDirective_library() { |
| 13691 createParser("library l;"); | 13753 createParser("library l;"); |
| 13692 Directive directive = parseFullDirective(); | 13754 Directive directive = parseFullDirective(); |
| 13693 expectNotNullIfNoErrors(directive); | 13755 expect(directive, isNotNull); |
| 13694 listener.assertNoErrors(); | 13756 assertNoErrors(); |
| 13695 expect(directive, new isInstanceOf<LibraryDirective>()); | 13757 expect(directive, new isInstanceOf<LibraryDirective>()); |
| 13696 LibraryDirective libraryDirective = directive; | 13758 LibraryDirective libraryDirective = directive; |
| 13697 expect(libraryDirective.libraryKeyword, isNotNull); | 13759 expect(libraryDirective.libraryKeyword, isNotNull); |
| 13698 expect(libraryDirective.name, isNotNull); | 13760 expect(libraryDirective.name, isNotNull); |
| 13699 expect(libraryDirective.semicolon, isNotNull); | 13761 expect(libraryDirective.semicolon, isNotNull); |
| 13700 } | 13762 } |
| 13701 | 13763 |
| 13702 void test_parseDirective_part() { | 13764 void test_parseDirective_part() { |
| 13703 createParser("part 'lib/lib.dart';"); | 13765 createParser("part 'lib/lib.dart';"); |
| 13704 Directive directive = parseFullDirective(); | 13766 Directive directive = parseFullDirective(); |
| 13705 expectNotNullIfNoErrors(directive); | 13767 expect(directive, isNotNull); |
| 13706 listener.assertNoErrors(); | 13768 assertNoErrors(); |
| 13707 expect(directive, new isInstanceOf<PartDirective>()); | 13769 expect(directive, new isInstanceOf<PartDirective>()); |
| 13708 PartDirective partDirective = directive; | 13770 PartDirective partDirective = directive; |
| 13709 expect(partDirective.partKeyword, isNotNull); | 13771 expect(partDirective.partKeyword, isNotNull); |
| 13710 expect(partDirective.uri, isNotNull); | 13772 expect(partDirective.uri, isNotNull); |
| 13711 expect(partDirective.semicolon, isNotNull); | 13773 expect(partDirective.semicolon, isNotNull); |
| 13712 } | 13774 } |
| 13713 | 13775 |
| 13714 void test_parseDirective_partOf() { | 13776 void test_parseDirective_partOf() { |
| 13715 createParser("part of l;"); | 13777 createParser("part of l;"); |
| 13716 Directive directive = parseFullDirective(); | 13778 Directive directive = parseFullDirective(); |
| 13717 expectNotNullIfNoErrors(directive); | 13779 expect(directive, isNotNull); |
| 13718 listener.assertNoErrors(); | 13780 assertNoErrors(); |
| 13719 expect(directive, new isInstanceOf<PartOfDirective>()); | 13781 expect(directive, new isInstanceOf<PartOfDirective>()); |
| 13720 PartOfDirective partOfDirective = directive; | 13782 PartOfDirective partOfDirective = directive; |
| 13721 expect(partOfDirective.partKeyword, isNotNull); | 13783 expect(partOfDirective.partKeyword, isNotNull); |
| 13722 expect(partOfDirective.ofKeyword, isNotNull); | 13784 expect(partOfDirective.ofKeyword, isNotNull); |
| 13723 expect(partOfDirective.libraryName, isNotNull); | 13785 expect(partOfDirective.libraryName, isNotNull); |
| 13724 expect(partOfDirective.semicolon, isNotNull); | 13786 expect(partOfDirective.semicolon, isNotNull); |
| 13725 } | 13787 } |
| 13726 | 13788 |
| 13727 void test_parseDirectives_complete() { | 13789 void test_parseDirectives_complete() { |
| 13728 CompilationUnit unit = | 13790 CompilationUnit unit = |
| 13729 _parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}"); | 13791 parseDirectives("#! /bin/dart\nlibrary l;\nclass A {}"); |
| 13730 expect(unit.scriptTag, isNotNull); | 13792 expect(unit.scriptTag, isNotNull); |
| 13731 expect(unit.directives, hasLength(1)); | 13793 expect(unit.directives, hasLength(1)); |
| 13732 } | 13794 } |
| 13733 | 13795 |
| 13734 void test_parseDirectives_empty() { | 13796 void test_parseDirectives_empty() { |
| 13735 CompilationUnit unit = _parseDirectives(""); | 13797 CompilationUnit unit = parseDirectives(""); |
| 13736 expect(unit.scriptTag, isNull); | 13798 expect(unit.scriptTag, isNull); |
| 13737 expect(unit.directives, hasLength(0)); | 13799 expect(unit.directives, hasLength(0)); |
| 13738 } | 13800 } |
| 13739 | 13801 |
| 13740 void test_parseDirectives_mixed() { | 13802 void test_parseDirectives_mixed() { |
| 13741 CompilationUnit unit = | 13803 CompilationUnit unit = |
| 13742 _parseDirectives("library l; class A {} part 'foo.dart';"); | 13804 parseDirectives("library l; class A {} part 'foo.dart';"); |
| 13743 expect(unit.scriptTag, isNull); | 13805 expect(unit.scriptTag, isNull); |
| 13744 expect(unit.directives, hasLength(1)); | 13806 expect(unit.directives, hasLength(1)); |
| 13745 } | 13807 } |
| 13746 | 13808 |
| 13747 void test_parseDirectives_multiple() { | 13809 void test_parseDirectives_multiple() { |
| 13748 CompilationUnit unit = _parseDirectives("library l;\npart 'a.dart';"); | 13810 CompilationUnit unit = parseDirectives("library l;\npart 'a.dart';"); |
| 13749 expect(unit.scriptTag, isNull); | 13811 expect(unit.scriptTag, isNull); |
| 13750 expect(unit.directives, hasLength(2)); | 13812 expect(unit.directives, hasLength(2)); |
| 13751 } | 13813 } |
| 13752 | 13814 |
| 13753 void test_parseDirectives_script() { | 13815 void test_parseDirectives_script() { |
| 13754 CompilationUnit unit = _parseDirectives("#! /bin/dart"); | 13816 CompilationUnit unit = parseDirectives("#! /bin/dart"); |
| 13755 expect(unit.scriptTag, isNotNull); | 13817 expect(unit.scriptTag, isNotNull); |
| 13756 expect(unit.directives, hasLength(0)); | 13818 expect(unit.directives, hasLength(0)); |
| 13757 } | 13819 } |
| 13758 | 13820 |
| 13759 void test_parseDirectives_single() { | 13821 void test_parseDirectives_single() { |
| 13760 CompilationUnit unit = _parseDirectives("library l;"); | 13822 CompilationUnit unit = parseDirectives("library l;"); |
| 13761 expect(unit.scriptTag, isNull); | 13823 expect(unit.scriptTag, isNull); |
| 13762 expect(unit.directives, hasLength(1)); | 13824 expect(unit.directives, hasLength(1)); |
| 13763 } | 13825 } |
| 13764 | 13826 |
| 13765 void test_parseDirectives_topLevelDeclaration() { | 13827 void test_parseDirectives_topLevelDeclaration() { |
| 13766 CompilationUnit unit = _parseDirectives("class A {}"); | 13828 CompilationUnit unit = parseDirectives("class A {}"); |
| 13767 expect(unit.scriptTag, isNull); | 13829 expect(unit.scriptTag, isNull); |
| 13768 expect(unit.directives, hasLength(0)); | 13830 expect(unit.directives, hasLength(0)); |
| 13769 } | 13831 } |
| 13770 | 13832 |
| 13771 void test_parseEnumDeclaration_one() { | 13833 void test_parseEnumDeclaration_one() { |
| 13772 createParser("enum E {ONE}"); | 13834 createParser("enum E {ONE}"); |
| 13773 EnumDeclaration declaration = parseFullCompilationUnitMember(); | 13835 EnumDeclaration declaration = parseFullCompilationUnitMember(); |
| 13774 expectNotNullIfNoErrors(declaration); | 13836 expect(declaration, isNotNull); |
| 13775 listener.assertNoErrors(); | 13837 assertNoErrors(); |
| 13776 expect(declaration.documentationComment, isNull); | 13838 expect(declaration.documentationComment, isNull); |
| 13777 expect(declaration.enumKeyword, isNotNull); | 13839 expect(declaration.enumKeyword, isNotNull); |
| 13778 expect(declaration.leftBracket, isNotNull); | 13840 expect(declaration.leftBracket, isNotNull); |
| 13779 expect(declaration.name, isNotNull); | 13841 expect(declaration.name, isNotNull); |
| 13780 expect(declaration.constants, hasLength(1)); | 13842 expect(declaration.constants, hasLength(1)); |
| 13781 expect(declaration.rightBracket, isNotNull); | 13843 expect(declaration.rightBracket, isNotNull); |
| 13782 } | 13844 } |
| 13783 | 13845 |
| 13784 void test_parseEnumDeclaration_trailingComma() { | 13846 void test_parseEnumDeclaration_trailingComma() { |
| 13785 createParser("enum E {ONE,}"); | 13847 createParser("enum E {ONE,}"); |
| 13786 EnumDeclaration declaration = parseFullCompilationUnitMember(); | 13848 EnumDeclaration declaration = parseFullCompilationUnitMember(); |
| 13787 expectNotNullIfNoErrors(declaration); | 13849 expect(declaration, isNotNull); |
| 13788 listener.assertNoErrors(); | 13850 assertNoErrors(); |
| 13789 expect(declaration.documentationComment, isNull); | 13851 expect(declaration.documentationComment, isNull); |
| 13790 expect(declaration.enumKeyword, isNotNull); | 13852 expect(declaration.enumKeyword, isNotNull); |
| 13791 expect(declaration.leftBracket, isNotNull); | 13853 expect(declaration.leftBracket, isNotNull); |
| 13792 expect(declaration.name, isNotNull); | 13854 expect(declaration.name, isNotNull); |
| 13793 expect(declaration.constants, hasLength(1)); | 13855 expect(declaration.constants, hasLength(1)); |
| 13794 expect(declaration.rightBracket, isNotNull); | 13856 expect(declaration.rightBracket, isNotNull); |
| 13795 } | 13857 } |
| 13796 | 13858 |
| 13797 void test_parseEnumDeclaration_two() { | 13859 void test_parseEnumDeclaration_two() { |
| 13798 createParser("enum E {ONE, TWO}"); | 13860 createParser("enum E {ONE, TWO}"); |
| 13799 EnumDeclaration declaration = parseFullCompilationUnitMember(); | 13861 EnumDeclaration declaration = parseFullCompilationUnitMember(); |
| 13800 expectNotNullIfNoErrors(declaration); | 13862 expect(declaration, isNotNull); |
| 13801 listener.assertNoErrors(); | 13863 assertNoErrors(); |
| 13802 expect(declaration.documentationComment, isNull); | 13864 expect(declaration.documentationComment, isNull); |
| 13803 expect(declaration.enumKeyword, isNotNull); | 13865 expect(declaration.enumKeyword, isNotNull); |
| 13804 expect(declaration.leftBracket, isNotNull); | 13866 expect(declaration.leftBracket, isNotNull); |
| 13805 expect(declaration.name, isNotNull); | 13867 expect(declaration.name, isNotNull); |
| 13806 expect(declaration.constants, hasLength(2)); | 13868 expect(declaration.constants, hasLength(2)); |
| 13807 expect(declaration.rightBracket, isNotNull); | 13869 expect(declaration.rightBracket, isNotNull); |
| 13808 } | 13870 } |
| 13809 | 13871 |
| 13810 void test_parseExportDirective_configuration_multiple() { | 13872 void test_parseExportDirective_configuration_multiple() { |
| 13811 createParser("export 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); | 13873 createParser("export 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); |
| 13812 ExportDirective directive = parseFullDirective(); | 13874 ExportDirective directive = parseFullDirective(); |
| 13813 expectNotNullIfNoErrors(directive); | 13875 expect(directive, isNotNull); |
| 13814 listener.assertNoErrors(); | 13876 assertNoErrors(); |
| 13815 expect(directive.keyword, isNotNull); | 13877 expect(directive.keyword, isNotNull); |
| 13816 expect(directive.uri, isNotNull); | 13878 expect(directive.uri, isNotNull); |
| 13817 expect(directive.configurations, hasLength(2)); | 13879 expect(directive.configurations, hasLength(2)); |
| 13818 expectDottedName(directive.configurations[0].name, ['a']); | 13880 expectDottedName(directive.configurations[0].name, ['a']); |
| 13819 expectDottedName(directive.configurations[1].name, ['c']); | 13881 expectDottedName(directive.configurations[1].name, ['c']); |
| 13820 expect(directive.combinators, hasLength(0)); | 13882 expect(directive.combinators, hasLength(0)); |
| 13821 expect(directive.semicolon, isNotNull); | 13883 expect(directive.semicolon, isNotNull); |
| 13822 } | 13884 } |
| 13823 | 13885 |
| 13824 void test_parseExportDirective_configuration_single() { | 13886 void test_parseExportDirective_configuration_single() { |
| 13825 createParser("export 'lib/lib.dart' if (a.b == 'c.dart') '';"); | 13887 createParser("export 'lib/lib.dart' if (a.b == 'c.dart') '';"); |
| 13826 ExportDirective directive = parseFullDirective(); | 13888 ExportDirective directive = parseFullDirective(); |
| 13827 expectNotNullIfNoErrors(directive); | 13889 expect(directive, isNotNull); |
| 13828 listener.assertNoErrors(); | 13890 assertNoErrors(); |
| 13829 expect(directive.keyword, isNotNull); | 13891 expect(directive.keyword, isNotNull); |
| 13830 expect(directive.uri, isNotNull); | 13892 expect(directive.uri, isNotNull); |
| 13831 expect(directive.configurations, hasLength(1)); | 13893 expect(directive.configurations, hasLength(1)); |
| 13832 expectDottedName(directive.configurations[0].name, ['a', 'b']); | 13894 expectDottedName(directive.configurations[0].name, ['a', 'b']); |
| 13833 expect(directive.combinators, hasLength(0)); | 13895 expect(directive.combinators, hasLength(0)); |
| 13834 expect(directive.semicolon, isNotNull); | 13896 expect(directive.semicolon, isNotNull); |
| 13835 } | 13897 } |
| 13836 | 13898 |
| 13837 void test_parseExportDirective_hide() { | 13899 void test_parseExportDirective_hide() { |
| 13838 createParser("export 'lib/lib.dart' hide A, B;"); | 13900 createParser("export 'lib/lib.dart' hide A, B;"); |
| 13839 ExportDirective directive = parseFullDirective(); | 13901 ExportDirective directive = parseFullDirective(); |
| 13840 expectNotNullIfNoErrors(directive); | 13902 expect(directive, isNotNull); |
| 13841 listener.assertNoErrors(); | 13903 assertNoErrors(); |
| 13842 expect(directive.keyword, isNotNull); | 13904 expect(directive.keyword, isNotNull); |
| 13843 expect(directive.uri, isNotNull); | 13905 expect(directive.uri, isNotNull); |
| 13844 expect(directive.combinators, hasLength(1)); | 13906 expect(directive.combinators, hasLength(1)); |
| 13845 expect(directive.semicolon, isNotNull); | 13907 expect(directive.semicolon, isNotNull); |
| 13846 } | 13908 } |
| 13847 | 13909 |
| 13848 void test_parseExportDirective_hide_show() { | 13910 void test_parseExportDirective_hide_show() { |
| 13849 createParser("export 'lib/lib.dart' hide A show B;"); | 13911 createParser("export 'lib/lib.dart' hide A show B;"); |
| 13850 ExportDirective directive = parseFullDirective(); | 13912 ExportDirective directive = parseFullDirective(); |
| 13851 expectNotNullIfNoErrors(directive); | 13913 expect(directive, isNotNull); |
| 13852 listener.assertNoErrors(); | 13914 assertNoErrors(); |
| 13853 expect(directive.keyword, isNotNull); | 13915 expect(directive.keyword, isNotNull); |
| 13854 expect(directive.uri, isNotNull); | 13916 expect(directive.uri, isNotNull); |
| 13855 expect(directive.combinators, hasLength(2)); | 13917 expect(directive.combinators, hasLength(2)); |
| 13856 expect(directive.semicolon, isNotNull); | 13918 expect(directive.semicolon, isNotNull); |
| 13857 } | 13919 } |
| 13858 | 13920 |
| 13859 void test_parseExportDirective_noCombinator() { | 13921 void test_parseExportDirective_noCombinator() { |
| 13860 createParser("export 'lib/lib.dart';"); | 13922 createParser("export 'lib/lib.dart';"); |
| 13861 ExportDirective directive = parseFullDirective(); | 13923 ExportDirective directive = parseFullDirective(); |
| 13862 expectNotNullIfNoErrors(directive); | 13924 expect(directive, isNotNull); |
| 13863 listener.assertNoErrors(); | 13925 assertNoErrors(); |
| 13864 expect(directive.keyword, isNotNull); | 13926 expect(directive.keyword, isNotNull); |
| 13865 expect(directive.uri, isNotNull); | 13927 expect(directive.uri, isNotNull); |
| 13866 expect(directive.combinators, hasLength(0)); | 13928 expect(directive.combinators, hasLength(0)); |
| 13867 expect(directive.semicolon, isNotNull); | 13929 expect(directive.semicolon, isNotNull); |
| 13868 } | 13930 } |
| 13869 | 13931 |
| 13870 void test_parseExportDirective_show() { | 13932 void test_parseExportDirective_show() { |
| 13871 createParser("export 'lib/lib.dart' show A, B;"); | 13933 createParser("export 'lib/lib.dart' show A, B;"); |
| 13872 ExportDirective directive = parseFullDirective(); | 13934 ExportDirective directive = parseFullDirective(); |
| 13873 expectNotNullIfNoErrors(directive); | 13935 expect(directive, isNotNull); |
| 13874 listener.assertNoErrors(); | 13936 assertNoErrors(); |
| 13875 expect(directive.keyword, isNotNull); | 13937 expect(directive.keyword, isNotNull); |
| 13876 expect(directive.uri, isNotNull); | 13938 expect(directive.uri, isNotNull); |
| 13877 expect(directive.combinators, hasLength(1)); | 13939 expect(directive.combinators, hasLength(1)); |
| 13878 expect(directive.semicolon, isNotNull); | 13940 expect(directive.semicolon, isNotNull); |
| 13879 } | 13941 } |
| 13880 | 13942 |
| 13881 void test_parseExportDirective_show_hide() { | 13943 void test_parseExportDirective_show_hide() { |
| 13882 createParser("export 'lib/lib.dart' show B hide A;"); | 13944 createParser("export 'lib/lib.dart' show B hide A;"); |
| 13883 ExportDirective directive = parseFullDirective(); | 13945 ExportDirective directive = parseFullDirective(); |
| 13884 expectNotNullIfNoErrors(directive); | 13946 expect(directive, isNotNull); |
| 13885 listener.assertNoErrors(); | 13947 assertNoErrors(); |
| 13886 expect(directive.keyword, isNotNull); | 13948 expect(directive.keyword, isNotNull); |
| 13887 expect(directive.uri, isNotNull); | 13949 expect(directive.uri, isNotNull); |
| 13888 expect(directive.combinators, hasLength(2)); | 13950 expect(directive.combinators, hasLength(2)); |
| 13889 expect(directive.semicolon, isNotNull); | 13951 expect(directive.semicolon, isNotNull); |
| 13890 } | 13952 } |
| 13891 | 13953 |
| 13892 void test_parseFunctionDeclaration_function() { | 13954 void test_parseFunctionDeclaration_function() { |
| 13893 createParser('/// Doc\nT f() {}'); | 13955 createParser('/// Doc\nT f() {}'); |
| 13894 FunctionDeclaration declaration = parseFullCompilationUnitMember(); | 13956 FunctionDeclaration declaration = parseFullCompilationUnitMember(); |
| 13895 expectNotNullIfNoErrors(declaration); | 13957 expect(declaration, isNotNull); |
| 13896 listener.assertNoErrors(); | 13958 assertNoErrors(); |
| 13897 expectCommentText(declaration.documentationComment, '/// Doc'); | 13959 expectCommentText(declaration.documentationComment, '/// Doc'); |
| 13898 expect((declaration.returnType as TypeName).name.name, 'T'); | 13960 expect((declaration.returnType as TypeName).name.name, 'T'); |
| 13899 expect(declaration.name, isNotNull); | 13961 expect(declaration.name, isNotNull); |
| 13900 FunctionExpression expression = declaration.functionExpression; | 13962 FunctionExpression expression = declaration.functionExpression; |
| 13901 expect(expression, isNotNull); | 13963 expect(expression, isNotNull); |
| 13902 expect(expression.body, isNotNull); | 13964 expect(expression.body, isNotNull); |
| 13903 expect(expression.typeParameters, isNull); | 13965 expect(expression.typeParameters, isNull); |
| 13904 expect(expression.parameters, isNotNull); | 13966 expect(expression.parameters, isNotNull); |
| 13905 expect(declaration.propertyKeyword, isNull); | 13967 expect(declaration.propertyKeyword, isNull); |
| 13906 } | 13968 } |
| 13907 | 13969 |
| 13908 void test_parseFunctionDeclaration_functionWithTypeParameters() { | 13970 void test_parseFunctionDeclaration_functionWithTypeParameters() { |
| 13909 createParser('/// Doc\nT f<E>() {}'); | 13971 createParser('/// Doc\nT f<E>() {}'); |
| 13910 FunctionDeclaration declaration = parseFullCompilationUnitMember(); | 13972 FunctionDeclaration declaration = parseFullCompilationUnitMember(); |
| 13911 expectNotNullIfNoErrors(declaration); | 13973 expect(declaration, isNotNull); |
| 13912 listener.assertNoErrors(); | 13974 assertNoErrors(); |
| 13913 expectCommentText(declaration.documentationComment, '/// Doc'); | 13975 expectCommentText(declaration.documentationComment, '/// Doc'); |
| 13914 expect((declaration.returnType as TypeName).name.name, 'T'); | 13976 expect((declaration.returnType as TypeName).name.name, 'T'); |
| 13915 expect(declaration.name, isNotNull); | 13977 expect(declaration.name, isNotNull); |
| 13916 FunctionExpression expression = declaration.functionExpression; | 13978 FunctionExpression expression = declaration.functionExpression; |
| 13917 expect(expression, isNotNull); | 13979 expect(expression, isNotNull); |
| 13918 expect(expression.body, isNotNull); | 13980 expect(expression.body, isNotNull); |
| 13919 expect(expression.typeParameters, isNotNull); | 13981 expect(expression.typeParameters, isNotNull); |
| 13920 expect(expression.parameters, isNotNull); | 13982 expect(expression.parameters, isNotNull); |
| 13921 expect(declaration.propertyKeyword, isNull); | 13983 expect(declaration.propertyKeyword, isNull); |
| 13922 } | 13984 } |
| 13923 | 13985 |
| 13924 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() { | 13986 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() { |
| 13925 enableGenericMethodComments = true; | 13987 enableGenericMethodComments = true; |
| 13926 createParser('/// Doc\nT f/*<E>*/() {}'); | 13988 createParser('/// Doc\nT f/*<E>*/() {}'); |
| 13927 FunctionDeclaration declaration = parseFullCompilationUnitMember(); | 13989 FunctionDeclaration declaration = parseFullCompilationUnitMember(); |
| 13928 expectNotNullIfNoErrors(declaration); | 13990 expect(declaration, isNotNull); |
| 13929 listener.assertNoErrors(); | 13991 assertNoErrors(); |
| 13930 expectCommentText(declaration.documentationComment, '/// Doc'); | 13992 expectCommentText(declaration.documentationComment, '/// Doc'); |
| 13931 expect((declaration.returnType as TypeName).name.name, 'T'); | 13993 expect((declaration.returnType as TypeName).name.name, 'T'); |
| 13932 expect(declaration.name, isNotNull); | 13994 expect(declaration.name, isNotNull); |
| 13933 FunctionExpression expression = declaration.functionExpression; | 13995 FunctionExpression expression = declaration.functionExpression; |
| 13934 expect(expression, isNotNull); | 13996 expect(expression, isNotNull); |
| 13935 expect(expression.body, isNotNull); | 13997 expect(expression.body, isNotNull); |
| 13936 expect(expression.typeParameters, isNotNull); | 13998 expect(expression.typeParameters, isNotNull); |
| 13937 expect(expression.parameters, isNotNull); | 13999 expect(expression.parameters, isNotNull); |
| 13938 expect(declaration.propertyKeyword, isNull); | 14000 expect(declaration.propertyKeyword, isNull); |
| 13939 } | 14001 } |
| 13940 | 14002 |
| 13941 void test_parseFunctionDeclaration_getter() { | 14003 void test_parseFunctionDeclaration_getter() { |
| 13942 createParser('/// Doc\nT get p => 0;'); | 14004 createParser('/// Doc\nT get p => 0;'); |
| 13943 FunctionDeclaration declaration = parseFullCompilationUnitMember(); | 14005 FunctionDeclaration declaration = parseFullCompilationUnitMember(); |
| 13944 expectNotNullIfNoErrors(declaration); | 14006 expect(declaration, isNotNull); |
| 13945 listener.assertNoErrors(); | 14007 assertNoErrors(); |
| 13946 expectCommentText(declaration.documentationComment, '/// Doc'); | 14008 expectCommentText(declaration.documentationComment, '/// Doc'); |
| 13947 expect((declaration.returnType as TypeName).name.name, 'T'); | 14009 expect((declaration.returnType as TypeName).name.name, 'T'); |
| 13948 expect(declaration.name, isNotNull); | 14010 expect(declaration.name, isNotNull); |
| 13949 FunctionExpression expression = declaration.functionExpression; | 14011 FunctionExpression expression = declaration.functionExpression; |
| 13950 expect(expression, isNotNull); | 14012 expect(expression, isNotNull); |
| 13951 expect(expression.body, isNotNull); | 14013 expect(expression.body, isNotNull); |
| 13952 expect(expression.typeParameters, isNull); | 14014 expect(expression.typeParameters, isNull); |
| 13953 expect(expression.parameters, isNull); | 14015 expect(expression.parameters, isNull); |
| 13954 expect(declaration.propertyKeyword, isNotNull); | 14016 expect(declaration.propertyKeyword, isNotNull); |
| 13955 } | 14017 } |
| 13956 | 14018 |
| 13957 void test_parseFunctionDeclaration_setter() { | 14019 void test_parseFunctionDeclaration_setter() { |
| 13958 createParser('/// Doc\nT set p(v) {}'); | 14020 createParser('/// Doc\nT set p(v) {}'); |
| 13959 FunctionDeclaration declaration = parseFullCompilationUnitMember(); | 14021 FunctionDeclaration declaration = parseFullCompilationUnitMember(); |
| 13960 expectNotNullIfNoErrors(declaration); | 14022 expect(declaration, isNotNull); |
| 13961 listener.assertNoErrors(); | 14023 assertNoErrors(); |
| 13962 expectCommentText(declaration.documentationComment, '/// Doc'); | 14024 expectCommentText(declaration.documentationComment, '/// Doc'); |
| 13963 expect((declaration.returnType as TypeName).name.name, 'T'); | 14025 expect((declaration.returnType as TypeName).name.name, 'T'); |
| 13964 expect(declaration.name, isNotNull); | 14026 expect(declaration.name, isNotNull); |
| 13965 FunctionExpression expression = declaration.functionExpression; | 14027 FunctionExpression expression = declaration.functionExpression; |
| 13966 expect(expression, isNotNull); | 14028 expect(expression, isNotNull); |
| 13967 expect(expression.body, isNotNull); | 14029 expect(expression.body, isNotNull); |
| 13968 expect(expression.typeParameters, isNull); | 14030 expect(expression.typeParameters, isNull); |
| 13969 expect(expression.parameters, isNotNull); | 14031 expect(expression.parameters, isNotNull); |
| 13970 expect(declaration.propertyKeyword, isNotNull); | 14032 expect(declaration.propertyKeyword, isNotNull); |
| 13971 } | 14033 } |
| 13972 | 14034 |
| 13973 @failingTest | 14035 @failingTest |
| 13974 void test_parseGenericTypeAlias_noTypeParameters() { | 14036 void test_parseGenericTypeAlias_noTypeParameters() { |
| 13975 createParser('F = int Function(int);'); | 14037 createParser('F = int Function(int);'); |
| 13976 GenericTypeAlias alias = parseFullCompilationUnitMember(); | 14038 GenericTypeAlias alias = parseFullCompilationUnitMember(); |
| 13977 expectNotNullIfNoErrors(alias); | 14039 expect(alias, isNotNull); |
| 13978 listener.assertNoErrors(); | 14040 assertNoErrors(); |
| 13979 expect(alias.name, isNotNull); | 14041 expect(alias.name, isNotNull); |
| 13980 expect(alias.name.name, 'F'); | 14042 expect(alias.name.name, 'F'); |
| 13981 expect(alias.typeParameters, isNull); | 14043 expect(alias.typeParameters, isNull); |
| 13982 expect(alias.equals, isNotNull); | 14044 expect(alias.equals, isNotNull); |
| 13983 expect(alias.functionType, isNotNull); | 14045 expect(alias.functionType, isNotNull); |
| 13984 expect(alias.semicolon, isNotNull); | 14046 expect(alias.semicolon, isNotNull); |
| 13985 } | 14047 } |
| 13986 | 14048 |
| 13987 @failingTest | 14049 @failingTest |
| 13988 void test_parseGenericTypeAlias_typeParameters() { | 14050 void test_parseGenericTypeAlias_typeParameters() { |
| 13989 createParser('F<T> = T Function(T);'); | 14051 createParser('F<T> = T Function(T);'); |
| 13990 GenericTypeAlias alias = parseFullCompilationUnitMember(); | 14052 GenericTypeAlias alias = parseFullCompilationUnitMember(); |
| 13991 expectNotNullIfNoErrors(alias); | 14053 expect(alias, isNotNull); |
| 13992 listener.assertNoErrors(); | 14054 assertNoErrors(); |
| 13993 expect(alias.name, isNotNull); | 14055 expect(alias.name, isNotNull); |
| 13994 expect(alias.name.name, 'F'); | 14056 expect(alias.name.name, 'F'); |
| 13995 expect(alias.typeParameters, isNotNull); | 14057 expect(alias.typeParameters, isNotNull); |
| 13996 expect(alias.equals, isNotNull); | 14058 expect(alias.equals, isNotNull); |
| 13997 expect(alias.functionType, isNotNull); | 14059 expect(alias.functionType, isNotNull); |
| 13998 expect(alias.semicolon, isNotNull); | 14060 expect(alias.semicolon, isNotNull); |
| 13999 } | 14061 } |
| 14000 | 14062 |
| 14001 void test_parseImportDirective_configuration_multiple() { | 14063 void test_parseImportDirective_configuration_multiple() { |
| 14002 createParser("import 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); | 14064 createParser("import 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); |
| 14003 ImportDirective directive = parseFullDirective(); | 14065 ImportDirective directive = parseFullDirective(); |
| 14004 expectNotNullIfNoErrors(directive); | 14066 expect(directive, isNotNull); |
| 14005 listener.assertNoErrors(); | 14067 assertNoErrors(); |
| 14006 expect(directive.keyword, isNotNull); | 14068 expect(directive.keyword, isNotNull); |
| 14007 expect(directive.uri, isNotNull); | 14069 expect(directive.uri, isNotNull); |
| 14008 expect(directive.configurations, hasLength(2)); | 14070 expect(directive.configurations, hasLength(2)); |
| 14009 expectDottedName(directive.configurations[0].name, ['a']); | 14071 expectDottedName(directive.configurations[0].name, ['a']); |
| 14010 expectDottedName(directive.configurations[1].name, ['c']); | 14072 expectDottedName(directive.configurations[1].name, ['c']); |
| 14011 expect(directive.deferredKeyword, isNull); | 14073 expect(directive.deferredKeyword, isNull); |
| 14012 expect(directive.asKeyword, isNull); | 14074 expect(directive.asKeyword, isNull); |
| 14013 expect(directive.prefix, isNull); | 14075 expect(directive.prefix, isNull); |
| 14014 expect(directive.combinators, hasLength(0)); | 14076 expect(directive.combinators, hasLength(0)); |
| 14015 expect(directive.semicolon, isNotNull); | 14077 expect(directive.semicolon, isNotNull); |
| 14016 } | 14078 } |
| 14017 | 14079 |
| 14018 void test_parseImportDirective_configuration_single() { | 14080 void test_parseImportDirective_configuration_single() { |
| 14019 createParser("import 'lib/lib.dart' if (a.b == 'c.dart') '';"); | 14081 createParser("import 'lib/lib.dart' if (a.b == 'c.dart') '';"); |
| 14020 ImportDirective directive = parseFullDirective(); | 14082 ImportDirective directive = parseFullDirective(); |
| 14021 expectNotNullIfNoErrors(directive); | 14083 expect(directive, isNotNull); |
| 14022 listener.assertNoErrors(); | 14084 assertNoErrors(); |
| 14023 expect(directive.keyword, isNotNull); | 14085 expect(directive.keyword, isNotNull); |
| 14024 expect(directive.uri, isNotNull); | 14086 expect(directive.uri, isNotNull); |
| 14025 expect(directive.configurations, hasLength(1)); | 14087 expect(directive.configurations, hasLength(1)); |
| 14026 expectDottedName(directive.configurations[0].name, ['a', 'b']); | 14088 expectDottedName(directive.configurations[0].name, ['a', 'b']); |
| 14027 expect(directive.deferredKeyword, isNull); | 14089 expect(directive.deferredKeyword, isNull); |
| 14028 expect(directive.asKeyword, isNull); | 14090 expect(directive.asKeyword, isNull); |
| 14029 expect(directive.prefix, isNull); | 14091 expect(directive.prefix, isNull); |
| 14030 expect(directive.combinators, hasLength(0)); | 14092 expect(directive.combinators, hasLength(0)); |
| 14031 expect(directive.semicolon, isNotNull); | 14093 expect(directive.semicolon, isNotNull); |
| 14032 } | 14094 } |
| 14033 | 14095 |
| 14034 void test_parseImportDirective_deferred() { | 14096 void test_parseImportDirective_deferred() { |
| 14035 createParser("import 'lib/lib.dart' deferred as a;"); | 14097 createParser("import 'lib/lib.dart' deferred as a;"); |
| 14036 ImportDirective directive = parseFullDirective(); | 14098 ImportDirective directive = parseFullDirective(); |
| 14037 expectNotNullIfNoErrors(directive); | 14099 expect(directive, isNotNull); |
| 14038 listener.assertNoErrors(); | 14100 assertNoErrors(); |
| 14039 expect(directive.keyword, isNotNull); | 14101 expect(directive.keyword, isNotNull); |
| 14040 expect(directive.uri, isNotNull); | 14102 expect(directive.uri, isNotNull); |
| 14041 expect(directive.deferredKeyword, isNotNull); | 14103 expect(directive.deferredKeyword, isNotNull); |
| 14042 expect(directive.asKeyword, isNotNull); | 14104 expect(directive.asKeyword, isNotNull); |
| 14043 expect(directive.prefix, isNotNull); | 14105 expect(directive.prefix, isNotNull); |
| 14044 expect(directive.combinators, hasLength(0)); | 14106 expect(directive.combinators, hasLength(0)); |
| 14045 expect(directive.semicolon, isNotNull); | 14107 expect(directive.semicolon, isNotNull); |
| 14046 } | 14108 } |
| 14047 | 14109 |
| 14048 void test_parseImportDirective_hide() { | 14110 void test_parseImportDirective_hide() { |
| 14049 createParser("import 'lib/lib.dart' hide A, B;"); | 14111 createParser("import 'lib/lib.dart' hide A, B;"); |
| 14050 ImportDirective directive = parseFullDirective(); | 14112 ImportDirective directive = parseFullDirective(); |
| 14051 expectNotNullIfNoErrors(directive); | 14113 expect(directive, isNotNull); |
| 14052 listener.assertNoErrors(); | 14114 assertNoErrors(); |
| 14053 expect(directive.keyword, isNotNull); | 14115 expect(directive.keyword, isNotNull); |
| 14054 expect(directive.uri, isNotNull); | 14116 expect(directive.uri, isNotNull); |
| 14055 expect(directive.deferredKeyword, isNull); | 14117 expect(directive.deferredKeyword, isNull); |
| 14056 expect(directive.asKeyword, isNull); | 14118 expect(directive.asKeyword, isNull); |
| 14057 expect(directive.prefix, isNull); | 14119 expect(directive.prefix, isNull); |
| 14058 expect(directive.combinators, hasLength(1)); | 14120 expect(directive.combinators, hasLength(1)); |
| 14059 expect(directive.semicolon, isNotNull); | 14121 expect(directive.semicolon, isNotNull); |
| 14060 } | 14122 } |
| 14061 | 14123 |
| 14062 void test_parseImportDirective_noCombinator() { | 14124 void test_parseImportDirective_noCombinator() { |
| 14063 createParser("import 'lib/lib.dart';"); | 14125 createParser("import 'lib/lib.dart';"); |
| 14064 ImportDirective directive = parseFullDirective(); | 14126 ImportDirective directive = parseFullDirective(); |
| 14065 expectNotNullIfNoErrors(directive); | 14127 expect(directive, isNotNull); |
| 14066 listener.assertNoErrors(); | 14128 assertNoErrors(); |
| 14067 expect(directive.keyword, isNotNull); | 14129 expect(directive.keyword, isNotNull); |
| 14068 expect(directive.uri, isNotNull); | 14130 expect(directive.uri, isNotNull); |
| 14069 expect(directive.deferredKeyword, isNull); | 14131 expect(directive.deferredKeyword, isNull); |
| 14070 expect(directive.asKeyword, isNull); | 14132 expect(directive.asKeyword, isNull); |
| 14071 expect(directive.prefix, isNull); | 14133 expect(directive.prefix, isNull); |
| 14072 expect(directive.combinators, hasLength(0)); | 14134 expect(directive.combinators, hasLength(0)); |
| 14073 expect(directive.semicolon, isNotNull); | 14135 expect(directive.semicolon, isNotNull); |
| 14074 } | 14136 } |
| 14075 | 14137 |
| 14076 void test_parseImportDirective_prefix() { | 14138 void test_parseImportDirective_prefix() { |
| 14077 createParser("import 'lib/lib.dart' as a;"); | 14139 createParser("import 'lib/lib.dart' as a;"); |
| 14078 ImportDirective directive = parseFullDirective(); | 14140 ImportDirective directive = parseFullDirective(); |
| 14079 expectNotNullIfNoErrors(directive); | 14141 expect(directive, isNotNull); |
| 14080 listener.assertNoErrors(); | 14142 assertNoErrors(); |
| 14081 expect(directive.keyword, isNotNull); | 14143 expect(directive.keyword, isNotNull); |
| 14082 expect(directive.uri, isNotNull); | 14144 expect(directive.uri, isNotNull); |
| 14083 expect(directive.deferredKeyword, isNull); | 14145 expect(directive.deferredKeyword, isNull); |
| 14084 expect(directive.asKeyword, isNotNull); | 14146 expect(directive.asKeyword, isNotNull); |
| 14085 expect(directive.prefix, isNotNull); | 14147 expect(directive.prefix, isNotNull); |
| 14086 expect(directive.combinators, hasLength(0)); | 14148 expect(directive.combinators, hasLength(0)); |
| 14087 expect(directive.semicolon, isNotNull); | 14149 expect(directive.semicolon, isNotNull); |
| 14088 } | 14150 } |
| 14089 | 14151 |
| 14090 void test_parseImportDirective_prefix_hide_show() { | 14152 void test_parseImportDirective_prefix_hide_show() { |
| 14091 createParser("import 'lib/lib.dart' as a hide A show B;"); | 14153 createParser("import 'lib/lib.dart' as a hide A show B;"); |
| 14092 ImportDirective directive = parseFullDirective(); | 14154 ImportDirective directive = parseFullDirective(); |
| 14093 expectNotNullIfNoErrors(directive); | 14155 expect(directive, isNotNull); |
| 14094 listener.assertNoErrors(); | 14156 assertNoErrors(); |
| 14095 expect(directive.keyword, isNotNull); | 14157 expect(directive.keyword, isNotNull); |
| 14096 expect(directive.uri, isNotNull); | 14158 expect(directive.uri, isNotNull); |
| 14097 expect(directive.deferredKeyword, isNull); | 14159 expect(directive.deferredKeyword, isNull); |
| 14098 expect(directive.asKeyword, isNotNull); | 14160 expect(directive.asKeyword, isNotNull); |
| 14099 expect(directive.prefix, isNotNull); | 14161 expect(directive.prefix, isNotNull); |
| 14100 expect(directive.combinators, hasLength(2)); | 14162 expect(directive.combinators, hasLength(2)); |
| 14101 expect(directive.semicolon, isNotNull); | 14163 expect(directive.semicolon, isNotNull); |
| 14102 } | 14164 } |
| 14103 | 14165 |
| 14104 void test_parseImportDirective_prefix_show_hide() { | 14166 void test_parseImportDirective_prefix_show_hide() { |
| 14105 createParser("import 'lib/lib.dart' as a show B hide A;"); | 14167 createParser("import 'lib/lib.dart' as a show B hide A;"); |
| 14106 ImportDirective directive = parseFullDirective(); | 14168 ImportDirective directive = parseFullDirective(); |
| 14107 expectNotNullIfNoErrors(directive); | 14169 expect(directive, isNotNull); |
| 14108 listener.assertNoErrors(); | 14170 assertNoErrors(); |
| 14109 expect(directive.keyword, isNotNull); | 14171 expect(directive.keyword, isNotNull); |
| 14110 expect(directive.uri, isNotNull); | 14172 expect(directive.uri, isNotNull); |
| 14111 expect(directive.deferredKeyword, isNull); | 14173 expect(directive.deferredKeyword, isNull); |
| 14112 expect(directive.asKeyword, isNotNull); | 14174 expect(directive.asKeyword, isNotNull); |
| 14113 expect(directive.prefix, isNotNull); | 14175 expect(directive.prefix, isNotNull); |
| 14114 expect(directive.combinators, hasLength(2)); | 14176 expect(directive.combinators, hasLength(2)); |
| 14115 expect(directive.semicolon, isNotNull); | 14177 expect(directive.semicolon, isNotNull); |
| 14116 } | 14178 } |
| 14117 | 14179 |
| 14118 void test_parseImportDirective_show() { | 14180 void test_parseImportDirective_show() { |
| 14119 createParser("import 'lib/lib.dart' show A, B;"); | 14181 createParser("import 'lib/lib.dart' show A, B;"); |
| 14120 ImportDirective directive = parseFullDirective(); | 14182 ImportDirective directive = parseFullDirective(); |
| 14121 expectNotNullIfNoErrors(directive); | 14183 expect(directive, isNotNull); |
| 14122 listener.assertNoErrors(); | 14184 assertNoErrors(); |
| 14123 expect(directive.keyword, isNotNull); | 14185 expect(directive.keyword, isNotNull); |
| 14124 expect(directive.uri, isNotNull); | 14186 expect(directive.uri, isNotNull); |
| 14125 expect(directive.deferredKeyword, isNull); | 14187 expect(directive.deferredKeyword, isNull); |
| 14126 expect(directive.asKeyword, isNull); | 14188 expect(directive.asKeyword, isNull); |
| 14127 expect(directive.prefix, isNull); | 14189 expect(directive.prefix, isNull); |
| 14128 expect(directive.combinators, hasLength(1)); | 14190 expect(directive.combinators, hasLength(1)); |
| 14129 expect(directive.semicolon, isNotNull); | 14191 expect(directive.semicolon, isNotNull); |
| 14130 } | 14192 } |
| 14131 | 14193 |
| 14132 void test_parseLibraryDirective() { | 14194 void test_parseLibraryDirective() { |
| 14133 createParser('library l;'); | 14195 createParser('library l;'); |
| 14134 LibraryDirective directive = parseFullDirective(); | 14196 LibraryDirective directive = parseFullDirective(); |
| 14135 expectNotNullIfNoErrors(directive); | 14197 expect(directive, isNotNull); |
| 14136 listener.assertNoErrors(); | 14198 assertNoErrors(); |
| 14137 expect(directive.libraryKeyword, isNotNull); | 14199 expect(directive.libraryKeyword, isNotNull); |
| 14138 expect(directive.name, isNotNull); | 14200 expect(directive.name, isNotNull); |
| 14139 expect(directive.semicolon, isNotNull); | 14201 expect(directive.semicolon, isNotNull); |
| 14140 } | 14202 } |
| 14141 | 14203 |
| 14142 void test_parsePartDirective() { | 14204 void test_parsePartDirective() { |
| 14143 createParser("part 'lib/lib.dart';"); | 14205 createParser("part 'lib/lib.dart';"); |
| 14144 PartDirective directive = parseFullDirective(); | 14206 PartDirective directive = parseFullDirective(); |
| 14145 expectNotNullIfNoErrors(directive); | 14207 expect(directive, isNotNull); |
| 14146 listener.assertNoErrors(); | 14208 assertNoErrors(); |
| 14147 expect(directive.partKeyword, isNotNull); | 14209 expect(directive.partKeyword, isNotNull); |
| 14148 expect(directive.uri, isNotNull); | 14210 expect(directive.uri, isNotNull); |
| 14149 expect(directive.semicolon, isNotNull); | 14211 expect(directive.semicolon, isNotNull); |
| 14150 } | 14212 } |
| 14151 | 14213 |
| 14152 void test_parsePartOfDirective_name() { | 14214 void test_parsePartOfDirective_name() { |
| 14153 enableUriInPartOf = true; | 14215 enableUriInPartOf = true; |
| 14154 createParser("part of l;"); | 14216 createParser("part of l;"); |
| 14155 PartOfDirective directive = parseFullDirective(); | 14217 PartOfDirective directive = parseFullDirective(); |
| 14156 expect(directive.partKeyword, isNotNull); | 14218 expect(directive.partKeyword, isNotNull); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 14167 expect(directive.partKeyword, isNotNull); | 14229 expect(directive.partKeyword, isNotNull); |
| 14168 expect(directive.ofKeyword, isNotNull); | 14230 expect(directive.ofKeyword, isNotNull); |
| 14169 expect(directive.libraryName, isNull); | 14231 expect(directive.libraryName, isNull); |
| 14170 expect(directive.uri, isNotNull); | 14232 expect(directive.uri, isNotNull); |
| 14171 expect(directive.semicolon, isNotNull); | 14233 expect(directive.semicolon, isNotNull); |
| 14172 } | 14234 } |
| 14173 | 14235 |
| 14174 void test_parseTypeAlias_function_noParameters() { | 14236 void test_parseTypeAlias_function_noParameters() { |
| 14175 createParser('typedef bool F();'); | 14237 createParser('typedef bool F();'); |
| 14176 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14238 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14177 expectNotNullIfNoErrors(typeAlias); | 14239 expect(typeAlias, isNotNull); |
| 14178 listener.assertNoErrors(); | 14240 assertNoErrors(); |
| 14179 expect(typeAlias.typedefKeyword, isNotNull); | 14241 expect(typeAlias.typedefKeyword, isNotNull); |
| 14180 expect(typeAlias.name, isNotNull); | 14242 expect(typeAlias.name, isNotNull); |
| 14181 expect(typeAlias.parameters, isNotNull); | 14243 expect(typeAlias.parameters, isNotNull); |
| 14182 expect(typeAlias.returnType, isNotNull); | 14244 expect(typeAlias.returnType, isNotNull); |
| 14183 expect(typeAlias.semicolon, isNotNull); | 14245 expect(typeAlias.semicolon, isNotNull); |
| 14184 expect(typeAlias.typeParameters, isNull); | 14246 expect(typeAlias.typeParameters, isNull); |
| 14185 } | 14247 } |
| 14186 | 14248 |
| 14187 void test_parseTypeAlias_function_noReturnType() { | 14249 void test_parseTypeAlias_function_noReturnType() { |
| 14188 createParser('typedef F();'); | 14250 createParser('typedef F();'); |
| 14189 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14251 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14190 expectNotNullIfNoErrors(typeAlias); | 14252 expect(typeAlias, isNotNull); |
| 14191 listener.assertNoErrors(); | 14253 assertNoErrors(); |
| 14192 expect(typeAlias.typedefKeyword, isNotNull); | 14254 expect(typeAlias.typedefKeyword, isNotNull); |
| 14193 expect(typeAlias.name, isNotNull); | 14255 expect(typeAlias.name, isNotNull); |
| 14194 expect(typeAlias.parameters, isNotNull); | 14256 expect(typeAlias.parameters, isNotNull); |
| 14195 expect(typeAlias.returnType, isNull); | 14257 expect(typeAlias.returnType, isNull); |
| 14196 expect(typeAlias.semicolon, isNotNull); | 14258 expect(typeAlias.semicolon, isNotNull); |
| 14197 expect(typeAlias.typeParameters, isNull); | 14259 expect(typeAlias.typeParameters, isNull); |
| 14198 } | 14260 } |
| 14199 | 14261 |
| 14200 void test_parseTypeAlias_function_parameterizedReturnType() { | 14262 void test_parseTypeAlias_function_parameterizedReturnType() { |
| 14201 createParser('typedef A<B> F();'); | 14263 createParser('typedef A<B> F();'); |
| 14202 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14264 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14203 expectNotNullIfNoErrors(typeAlias); | 14265 expect(typeAlias, isNotNull); |
| 14204 listener.assertNoErrors(); | 14266 assertNoErrors(); |
| 14205 expect(typeAlias.typedefKeyword, isNotNull); | 14267 expect(typeAlias.typedefKeyword, isNotNull); |
| 14206 expect(typeAlias.name, isNotNull); | 14268 expect(typeAlias.name, isNotNull); |
| 14207 expect(typeAlias.parameters, isNotNull); | 14269 expect(typeAlias.parameters, isNotNull); |
| 14208 expect(typeAlias.returnType, isNotNull); | 14270 expect(typeAlias.returnType, isNotNull); |
| 14209 expect(typeAlias.semicolon, isNotNull); | 14271 expect(typeAlias.semicolon, isNotNull); |
| 14210 expect(typeAlias.typeParameters, isNull); | 14272 expect(typeAlias.typeParameters, isNull); |
| 14211 } | 14273 } |
| 14212 | 14274 |
| 14213 void test_parseTypeAlias_function_parameters() { | 14275 void test_parseTypeAlias_function_parameters() { |
| 14214 createParser('typedef bool F(Object value);'); | 14276 createParser('typedef bool F(Object value);'); |
| 14215 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14277 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14216 expectNotNullIfNoErrors(typeAlias); | 14278 expect(typeAlias, isNotNull); |
| 14217 listener.assertNoErrors(); | 14279 assertNoErrors(); |
| 14218 expect(typeAlias.typedefKeyword, isNotNull); | 14280 expect(typeAlias.typedefKeyword, isNotNull); |
| 14219 expect(typeAlias.name, isNotNull); | 14281 expect(typeAlias.name, isNotNull); |
| 14220 expect(typeAlias.parameters, isNotNull); | 14282 expect(typeAlias.parameters, isNotNull); |
| 14221 expect(typeAlias.returnType, isNotNull); | 14283 expect(typeAlias.returnType, isNotNull); |
| 14222 expect(typeAlias.semicolon, isNotNull); | 14284 expect(typeAlias.semicolon, isNotNull); |
| 14223 expect(typeAlias.typeParameters, isNull); | 14285 expect(typeAlias.typeParameters, isNull); |
| 14224 } | 14286 } |
| 14225 | 14287 |
| 14226 void test_parseTypeAlias_function_typeParameters() { | 14288 void test_parseTypeAlias_function_typeParameters() { |
| 14227 createParser('typedef bool F<E>();'); | 14289 createParser('typedef bool F<E>();'); |
| 14228 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14290 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14229 expectNotNullIfNoErrors(typeAlias); | 14291 expect(typeAlias, isNotNull); |
| 14230 listener.assertNoErrors(); | 14292 assertNoErrors(); |
| 14231 expect(typeAlias.typedefKeyword, isNotNull); | 14293 expect(typeAlias.typedefKeyword, isNotNull); |
| 14232 expect(typeAlias.name, isNotNull); | 14294 expect(typeAlias.name, isNotNull); |
| 14233 expect(typeAlias.parameters, isNotNull); | 14295 expect(typeAlias.parameters, isNotNull); |
| 14234 expect(typeAlias.returnType, isNotNull); | 14296 expect(typeAlias.returnType, isNotNull); |
| 14235 expect(typeAlias.semicolon, isNotNull); | 14297 expect(typeAlias.semicolon, isNotNull); |
| 14236 expect(typeAlias.typeParameters, isNotNull); | 14298 expect(typeAlias.typeParameters, isNotNull); |
| 14237 } | 14299 } |
| 14238 | 14300 |
| 14239 void test_parseTypeAlias_function_voidReturnType() { | 14301 void test_parseTypeAlias_function_voidReturnType() { |
| 14240 createParser('typedef void F();'); | 14302 createParser('typedef void F();'); |
| 14241 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14303 FunctionTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14242 expectNotNullIfNoErrors(typeAlias); | 14304 expect(typeAlias, isNotNull); |
| 14243 listener.assertNoErrors(); | 14305 assertNoErrors(); |
| 14244 expect(typeAlias.typedefKeyword, isNotNull); | 14306 expect(typeAlias.typedefKeyword, isNotNull); |
| 14245 expect(typeAlias.name, isNotNull); | 14307 expect(typeAlias.name, isNotNull); |
| 14246 expect(typeAlias.parameters, isNotNull); | 14308 expect(typeAlias.parameters, isNotNull); |
| 14247 expect(typeAlias.returnType, isNotNull); | 14309 expect(typeAlias.returnType, isNotNull); |
| 14248 expect(typeAlias.semicolon, isNotNull); | 14310 expect(typeAlias.semicolon, isNotNull); |
| 14249 expect(typeAlias.typeParameters, isNull); | 14311 expect(typeAlias.typeParameters, isNull); |
| 14250 } | 14312 } |
| 14251 | 14313 |
| 14252 @failingTest | 14314 @failingTest |
| 14253 void test_parseTypeAlias_genericFunction_noParameters() { | 14315 void test_parseTypeAlias_genericFunction_noParameters() { |
| 14254 createParser('typedef F = bool Function();'); | 14316 createParser('typedef F = bool Function();'); |
| 14255 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14317 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14256 expectNotNullIfNoErrors(typeAlias); | 14318 expect(typeAlias, isNotNull); |
| 14257 listener.assertNoErrors(); | 14319 assertNoErrors(); |
| 14258 expect(typeAlias.typedefKeyword, isNotNull); | 14320 expect(typeAlias.typedefKeyword, isNotNull); |
| 14259 expect(typeAlias.name, isNotNull); | 14321 expect(typeAlias.name, isNotNull); |
| 14260 expect(typeAlias.typeParameters, isNull); | 14322 expect(typeAlias.typeParameters, isNull); |
| 14261 expect(typeAlias.semicolon, isNotNull); | 14323 expect(typeAlias.semicolon, isNotNull); |
| 14262 GenericFunctionType functionType = typeAlias.functionType; | 14324 GenericFunctionType functionType = typeAlias.functionType; |
| 14263 expect(functionType, isNotNull); | 14325 expect(functionType, isNotNull); |
| 14264 expect(functionType.parameters, isNotNull); | 14326 expect(functionType.parameters, isNotNull); |
| 14265 expect(functionType.returnType, isNotNull); | 14327 expect(functionType.returnType, isNotNull); |
| 14266 expect(functionType.typeParameters, isNull); | 14328 expect(functionType.typeParameters, isNull); |
| 14267 } | 14329 } |
| 14268 | 14330 |
| 14269 @failingTest | 14331 @failingTest |
| 14270 void test_parseTypeAlias_genericFunction_noReturnType() { | 14332 void test_parseTypeAlias_genericFunction_noReturnType() { |
| 14271 createParser('typedef F = Function();'); | 14333 createParser('typedef F = Function();'); |
| 14272 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14334 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14273 expectNotNullIfNoErrors(typeAlias); | 14335 expect(typeAlias, isNotNull); |
| 14274 listener.assertNoErrors(); | 14336 assertNoErrors(); |
| 14275 expect(typeAlias.typedefKeyword, isNotNull); | 14337 expect(typeAlias.typedefKeyword, isNotNull); |
| 14276 expect(typeAlias.name, isNotNull); | 14338 expect(typeAlias.name, isNotNull); |
| 14277 expect(typeAlias.typeParameters, isNull); | 14339 expect(typeAlias.typeParameters, isNull); |
| 14278 expect(typeAlias.semicolon, isNotNull); | 14340 expect(typeAlias.semicolon, isNotNull); |
| 14279 GenericFunctionType functionType = typeAlias.functionType; | 14341 GenericFunctionType functionType = typeAlias.functionType; |
| 14280 expect(functionType, isNotNull); | 14342 expect(functionType, isNotNull); |
| 14281 expect(functionType.parameters, isNotNull); | 14343 expect(functionType.parameters, isNotNull); |
| 14282 expect(functionType.returnType, isNull); | 14344 expect(functionType.returnType, isNull); |
| 14283 expect(functionType.typeParameters, isNull); | 14345 expect(functionType.typeParameters, isNull); |
| 14284 } | 14346 } |
| 14285 | 14347 |
| 14286 @failingTest | 14348 @failingTest |
| 14287 void test_parseTypeAlias_genericFunction_parameterizedReturnType() { | 14349 void test_parseTypeAlias_genericFunction_parameterizedReturnType() { |
| 14288 createParser('typedef F = A<B> Function();'); | 14350 createParser('typedef F = A<B> Function();'); |
| 14289 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14351 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14290 expectNotNullIfNoErrors(typeAlias); | 14352 expect(typeAlias, isNotNull); |
| 14291 listener.assertNoErrors(); | 14353 assertNoErrors(); |
| 14292 expect(typeAlias.typedefKeyword, isNotNull); | 14354 expect(typeAlias.typedefKeyword, isNotNull); |
| 14293 expect(typeAlias.name, isNotNull); | 14355 expect(typeAlias.name, isNotNull); |
| 14294 expect(typeAlias.typeParameters, isNull); | 14356 expect(typeAlias.typeParameters, isNull); |
| 14295 expect(typeAlias.semicolon, isNotNull); | 14357 expect(typeAlias.semicolon, isNotNull); |
| 14296 GenericFunctionType functionType = typeAlias.functionType; | 14358 GenericFunctionType functionType = typeAlias.functionType; |
| 14297 expect(functionType, isNotNull); | 14359 expect(functionType, isNotNull); |
| 14298 expect(functionType.parameters, isNotNull); | 14360 expect(functionType.parameters, isNotNull); |
| 14299 expect(functionType.returnType, isNotNull); | 14361 expect(functionType.returnType, isNotNull); |
| 14300 expect(functionType.typeParameters, isNull); | 14362 expect(functionType.typeParameters, isNull); |
| 14301 } | 14363 } |
| 14302 | 14364 |
| 14303 @failingTest | 14365 @failingTest |
| 14304 void test_parseTypeAlias_genericFunction_parameters() { | 14366 void test_parseTypeAlias_genericFunction_parameters() { |
| 14305 createParser('typedef F = bool Function(Object value);'); | 14367 createParser('typedef F = bool Function(Object value);'); |
| 14306 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14368 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14307 expectNotNullIfNoErrors(typeAlias); | 14369 expect(typeAlias, isNotNull); |
| 14308 listener.assertNoErrors(); | 14370 assertNoErrors(); |
| 14309 expect(typeAlias.typedefKeyword, isNotNull); | 14371 expect(typeAlias.typedefKeyword, isNotNull); |
| 14310 expect(typeAlias.name, isNotNull); | 14372 expect(typeAlias.name, isNotNull); |
| 14311 expect(typeAlias.typeParameters, isNull); | 14373 expect(typeAlias.typeParameters, isNull); |
| 14312 expect(typeAlias.semicolon, isNotNull); | 14374 expect(typeAlias.semicolon, isNotNull); |
| 14313 GenericFunctionType functionType = typeAlias.functionType; | 14375 GenericFunctionType functionType = typeAlias.functionType; |
| 14314 expect(functionType, isNotNull); | 14376 expect(functionType, isNotNull); |
| 14315 expect(functionType.parameters, isNotNull); | 14377 expect(functionType.parameters, isNotNull); |
| 14316 expect(functionType.returnType, isNotNull); | 14378 expect(functionType.returnType, isNotNull); |
| 14317 expect(functionType.typeParameters, isNull); | 14379 expect(functionType.typeParameters, isNull); |
| 14318 } | 14380 } |
| 14319 | 14381 |
| 14320 @failingTest | 14382 @failingTest |
| 14321 void test_parseTypeAlias_genericFunction_typeParameters() { | 14383 void test_parseTypeAlias_genericFunction_typeParameters() { |
| 14322 createParser('typedef F = bool Function<E>();'); | 14384 createParser('typedef F = bool Function<E>();'); |
| 14323 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14385 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14324 expectNotNullIfNoErrors(typeAlias); | 14386 expect(typeAlias, isNotNull); |
| 14325 listener.assertNoErrors(); | 14387 assertNoErrors(); |
| 14326 expect(typeAlias.typedefKeyword, isNotNull); | 14388 expect(typeAlias.typedefKeyword, isNotNull); |
| 14327 expect(typeAlias.name, isNotNull); | 14389 expect(typeAlias.name, isNotNull); |
| 14328 expect(typeAlias.typeParameters, isNull); | 14390 expect(typeAlias.typeParameters, isNull); |
| 14329 expect(typeAlias.semicolon, isNotNull); | 14391 expect(typeAlias.semicolon, isNotNull); |
| 14330 GenericFunctionType functionType = typeAlias.functionType; | 14392 GenericFunctionType functionType = typeAlias.functionType; |
| 14331 expect(functionType, isNotNull); | 14393 expect(functionType, isNotNull); |
| 14332 expect(functionType.parameters, isNotNull); | 14394 expect(functionType.parameters, isNotNull); |
| 14333 expect(functionType.returnType, isNotNull); | 14395 expect(functionType.returnType, isNotNull); |
| 14334 expect(functionType.typeParameters, isNotNull); | 14396 expect(functionType.typeParameters, isNotNull); |
| 14335 } | 14397 } |
| 14336 | 14398 |
| 14337 @failingTest | 14399 @failingTest |
| 14338 void test_parseTypeAlias_genericFunction_typeParameters_noParameters() { | 14400 void test_parseTypeAlias_genericFunction_typeParameters_noParameters() { |
| 14339 createParser('typedef F<T> = bool Function();'); | 14401 createParser('typedef F<T> = bool Function();'); |
| 14340 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14402 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14341 expectNotNullIfNoErrors(typeAlias); | 14403 expect(typeAlias, isNotNull); |
| 14342 listener.assertNoErrors(); | 14404 assertNoErrors(); |
| 14343 expect(typeAlias.typedefKeyword, isNotNull); | 14405 expect(typeAlias.typedefKeyword, isNotNull); |
| 14344 expect(typeAlias.name, isNotNull); | 14406 expect(typeAlias.name, isNotNull); |
| 14345 expect(typeAlias.typeParameters, isNotNull); | 14407 expect(typeAlias.typeParameters, isNotNull); |
| 14346 expect(typeAlias.semicolon, isNotNull); | 14408 expect(typeAlias.semicolon, isNotNull); |
| 14347 GenericFunctionType functionType = typeAlias.functionType; | 14409 GenericFunctionType functionType = typeAlias.functionType; |
| 14348 expect(functionType, isNotNull); | 14410 expect(functionType, isNotNull); |
| 14349 expect(functionType.parameters, isNotNull); | 14411 expect(functionType.parameters, isNotNull); |
| 14350 expect(functionType.returnType, isNotNull); | 14412 expect(functionType.returnType, isNotNull); |
| 14351 expect(functionType.typeParameters, isNull); | 14413 expect(functionType.typeParameters, isNull); |
| 14352 } | 14414 } |
| 14353 | 14415 |
| 14354 @failingTest | 14416 @failingTest |
| 14355 void test_parseTypeAlias_genericFunction_typeParameters_noReturnType() { | 14417 void test_parseTypeAlias_genericFunction_typeParameters_noReturnType() { |
| 14356 createParser('typedef F<T> = Function();'); | 14418 createParser('typedef F<T> = Function();'); |
| 14357 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14419 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14358 expectNotNullIfNoErrors(typeAlias); | 14420 expect(typeAlias, isNotNull); |
| 14359 listener.assertNoErrors(); | 14421 assertNoErrors(); |
| 14360 expect(typeAlias.typedefKeyword, isNotNull); | 14422 expect(typeAlias.typedefKeyword, isNotNull); |
| 14361 expect(typeAlias.name, isNotNull); | 14423 expect(typeAlias.name, isNotNull); |
| 14362 expect(typeAlias.typeParameters, isNotNull); | 14424 expect(typeAlias.typeParameters, isNotNull); |
| 14363 expect(typeAlias.semicolon, isNotNull); | 14425 expect(typeAlias.semicolon, isNotNull); |
| 14364 GenericFunctionType functionType = typeAlias.functionType; | 14426 GenericFunctionType functionType = typeAlias.functionType; |
| 14365 expect(functionType, isNotNull); | 14427 expect(functionType, isNotNull); |
| 14366 expect(functionType.parameters, isNotNull); | 14428 expect(functionType.parameters, isNotNull); |
| 14367 expect(functionType.returnType, isNull); | 14429 expect(functionType.returnType, isNull); |
| 14368 expect(functionType.typeParameters, isNull); | 14430 expect(functionType.typeParameters, isNull); |
| 14369 } | 14431 } |
| 14370 | 14432 |
| 14371 @failingTest | 14433 @failingTest |
| 14372 void | 14434 void |
| 14373 test_parseTypeAlias_genericFunction_typeParameters_parameterizedReturnType
() { | 14435 test_parseTypeAlias_genericFunction_typeParameters_parameterizedReturnType
() { |
| 14374 createParser('typedef F<T> = A<B> Function();'); | 14436 createParser('typedef F<T> = A<B> Function();'); |
| 14375 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14437 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14376 expectNotNullIfNoErrors(typeAlias); | 14438 expect(typeAlias, isNotNull); |
| 14377 listener.assertNoErrors(); | 14439 assertNoErrors(); |
| 14378 expect(typeAlias.typedefKeyword, isNotNull); | 14440 expect(typeAlias.typedefKeyword, isNotNull); |
| 14379 expect(typeAlias.name, isNotNull); | 14441 expect(typeAlias.name, isNotNull); |
| 14380 expect(typeAlias.typeParameters, isNotNull); | 14442 expect(typeAlias.typeParameters, isNotNull); |
| 14381 expect(typeAlias.semicolon, isNotNull); | 14443 expect(typeAlias.semicolon, isNotNull); |
| 14382 GenericFunctionType functionType = typeAlias.functionType; | 14444 GenericFunctionType functionType = typeAlias.functionType; |
| 14383 expect(functionType, isNotNull); | 14445 expect(functionType, isNotNull); |
| 14384 expect(functionType.parameters, isNotNull); | 14446 expect(functionType.parameters, isNotNull); |
| 14385 expect(functionType.returnType, isNotNull); | 14447 expect(functionType.returnType, isNotNull); |
| 14386 expect(functionType.typeParameters, isNull); | 14448 expect(functionType.typeParameters, isNull); |
| 14387 } | 14449 } |
| 14388 | 14450 |
| 14389 @failingTest | 14451 @failingTest |
| 14390 void test_parseTypeAlias_genericFunction_typeParameters_parameters() { | 14452 void test_parseTypeAlias_genericFunction_typeParameters_parameters() { |
| 14391 createParser('typedef F<T> = bool Function(Object value);'); | 14453 createParser('typedef F<T> = bool Function(Object value);'); |
| 14392 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14454 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14393 expectNotNullIfNoErrors(typeAlias); | 14455 expect(typeAlias, isNotNull); |
| 14394 listener.assertNoErrors(); | 14456 assertNoErrors(); |
| 14395 expect(typeAlias.typedefKeyword, isNotNull); | 14457 expect(typeAlias.typedefKeyword, isNotNull); |
| 14396 expect(typeAlias.name, isNotNull); | 14458 expect(typeAlias.name, isNotNull); |
| 14397 expect(typeAlias.typeParameters, isNotNull); | 14459 expect(typeAlias.typeParameters, isNotNull); |
| 14398 expect(typeAlias.semicolon, isNotNull); | 14460 expect(typeAlias.semicolon, isNotNull); |
| 14399 GenericFunctionType functionType = typeAlias.functionType; | 14461 GenericFunctionType functionType = typeAlias.functionType; |
| 14400 expect(functionType, isNotNull); | 14462 expect(functionType, isNotNull); |
| 14401 expect(functionType.parameters, isNotNull); | 14463 expect(functionType.parameters, isNotNull); |
| 14402 expect(functionType.returnType, isNotNull); | 14464 expect(functionType.returnType, isNotNull); |
| 14403 expect(functionType.typeParameters, isNull); | 14465 expect(functionType.typeParameters, isNull); |
| 14404 } | 14466 } |
| 14405 | 14467 |
| 14406 @failingTest | 14468 @failingTest |
| 14407 void test_parseTypeAlias_genericFunction_typeParameters_typeParameters() { | 14469 void test_parseTypeAlias_genericFunction_typeParameters_typeParameters() { |
| 14408 createParser('typedef F<T> = bool Function<E>();'); | 14470 createParser('typedef F<T> = bool Function<E>();'); |
| 14409 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14471 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14410 expectNotNullIfNoErrors(typeAlias); | 14472 expect(typeAlias, isNotNull); |
| 14411 listener.assertNoErrors(); | 14473 assertNoErrors(); |
| 14412 expect(typeAlias.typedefKeyword, isNotNull); | 14474 expect(typeAlias.typedefKeyword, isNotNull); |
| 14413 expect(typeAlias.name, isNotNull); | 14475 expect(typeAlias.name, isNotNull); |
| 14414 expect(typeAlias.typeParameters, isNotNull); | 14476 expect(typeAlias.typeParameters, isNotNull); |
| 14415 expect(typeAlias.semicolon, isNotNull); | 14477 expect(typeAlias.semicolon, isNotNull); |
| 14416 GenericFunctionType functionType = typeAlias.functionType; | 14478 GenericFunctionType functionType = typeAlias.functionType; |
| 14417 expect(functionType, isNotNull); | 14479 expect(functionType, isNotNull); |
| 14418 expect(functionType.parameters, isNotNull); | 14480 expect(functionType.parameters, isNotNull); |
| 14419 expect(functionType.returnType, isNotNull); | 14481 expect(functionType.returnType, isNotNull); |
| 14420 expect(functionType.typeParameters, isNotNull); | 14482 expect(functionType.typeParameters, isNotNull); |
| 14421 } | 14483 } |
| 14422 | 14484 |
| 14423 @failingTest | 14485 @failingTest |
| 14424 void test_parseTypeAlias_genericFunction_typeParameters_voidReturnType() { | 14486 void test_parseTypeAlias_genericFunction_typeParameters_voidReturnType() { |
| 14425 createParser('typedef F<T> = void Function();'); | 14487 createParser('typedef F<T> = void Function();'); |
| 14426 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14488 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14427 expectNotNullIfNoErrors(typeAlias); | 14489 expect(typeAlias, isNotNull); |
| 14428 listener.assertNoErrors(); | 14490 assertNoErrors(); |
| 14429 expect(typeAlias.typedefKeyword, isNotNull); | 14491 expect(typeAlias.typedefKeyword, isNotNull); |
| 14430 expect(typeAlias.name, isNotNull); | 14492 expect(typeAlias.name, isNotNull); |
| 14431 expect(typeAlias.typeParameters, isNotNull); | 14493 expect(typeAlias.typeParameters, isNotNull); |
| 14432 expect(typeAlias.semicolon, isNotNull); | 14494 expect(typeAlias.semicolon, isNotNull); |
| 14433 GenericFunctionType functionType = typeAlias.functionType; | 14495 GenericFunctionType functionType = typeAlias.functionType; |
| 14434 expect(functionType, isNotNull); | 14496 expect(functionType, isNotNull); |
| 14435 expect(functionType.parameters, isNotNull); | 14497 expect(functionType.parameters, isNotNull); |
| 14436 expect(functionType.returnType, isNotNull); | 14498 expect(functionType.returnType, isNotNull); |
| 14437 expect(functionType.typeParameters, isNull); | 14499 expect(functionType.typeParameters, isNull); |
| 14438 } | 14500 } |
| 14439 | 14501 |
| 14440 @failingTest | 14502 @failingTest |
| 14441 void test_parseTypeAlias_genericFunction_voidReturnType() { | 14503 void test_parseTypeAlias_genericFunction_voidReturnType() { |
| 14442 createParser('typedef F = void Function();'); | 14504 createParser('typedef F = void Function();'); |
| 14443 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); | 14505 GenericTypeAlias typeAlias = parseFullCompilationUnitMember(); |
| 14444 expectNotNullIfNoErrors(typeAlias); | 14506 expect(typeAlias, isNotNull); |
| 14445 listener.assertNoErrors(); | 14507 assertNoErrors(); |
| 14446 expect(typeAlias.typedefKeyword, isNotNull); | 14508 expect(typeAlias.typedefKeyword, isNotNull); |
| 14447 expect(typeAlias.name, isNotNull); | 14509 expect(typeAlias.name, isNotNull); |
| 14448 expect(typeAlias.typeParameters, isNull); | 14510 expect(typeAlias.typeParameters, isNull); |
| 14449 expect(typeAlias.semicolon, isNotNull); | 14511 expect(typeAlias.semicolon, isNotNull); |
| 14450 GenericFunctionType functionType = typeAlias.functionType; | 14512 GenericFunctionType functionType = typeAlias.functionType; |
| 14451 expect(functionType, isNotNull); | 14513 expect(functionType, isNotNull); |
| 14452 expect(functionType.parameters, isNotNull); | 14514 expect(functionType.parameters, isNotNull); |
| 14453 expect(functionType.returnType, isNotNull); | 14515 expect(functionType.returnType, isNotNull); |
| 14454 expect(functionType.typeParameters, isNull); | 14516 expect(functionType.typeParameters, isNull); |
| 14455 } | 14517 } |
| 14456 | |
| 14457 /** | |
| 14458 * Parse the given source as a compilation unit. | |
| 14459 * | |
| 14460 * @param source the source to be parsed | |
| 14461 * @param errorCodes the error codes of the errors that are expected to be fou
nd | |
| 14462 * @return the compilation unit that was parsed | |
| 14463 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | |
| 14464 * not match those that are expected, or if the result would have be
en `null` | |
| 14465 */ | |
| 14466 CompilationUnit _parseDirectives(String source, | |
| 14467 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | |
| 14468 createParser(source); | |
| 14469 CompilationUnit unit = parser.parseDirectives2(); | |
| 14470 expect(unit, isNotNull); | |
| 14471 expect(unit.declarations, hasLength(0)); | |
| 14472 listener.assertErrorsWithCodes(errorCodes); | |
| 14473 return unit; | |
| 14474 } | |
| 14475 } | 14518 } |
| OLD | NEW |