Chromium Code Reviews| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 (obj) => obj is ReturnStatement, ReturnStatement, statement); | 347 (obj) => obj is ReturnStatement, ReturnStatement, statement); |
| 348 Expression expression = (statement as ReturnStatement).expression; | 348 Expression expression = (statement as ReturnStatement).expression; |
| 349 EngineTestCase.assertInstanceOf( | 349 EngineTestCase.assertInstanceOf( |
| 350 (obj) => obj is BinaryExpression, BinaryExpression, expression); | 350 (obj) => obj is BinaryExpression, BinaryExpression, expression); |
| 351 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, | 351 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, |
| 352 AwaitExpression, (expression as BinaryExpression).leftOperand); | 352 AwaitExpression, (expression as BinaryExpression).leftOperand); |
| 353 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, | 353 EngineTestCase.assertInstanceOf((obj) => obj is AwaitExpression, |
| 354 AwaitExpression, (expression as BinaryExpression).rightOperand); | 354 AwaitExpression, (expression as BinaryExpression).rightOperand); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void test_parseClassMember_constructor_withDocComment() { | |
| 358 createParser('/// Doc\nC();'); | |
| 359 var constructor = parser.parseClassMember('C') as ConstructorDeclaration; | |
|
ahe
2017/03/09 13:56:01
Why don't you just put the type on the variable?
Paul Berry
2017/03/09 16:42:04
Two reasons:
1. it makes the downcast obvious. A
| |
| 360 expectCommentText(constructor.documentationComment, '/// Doc'); | |
| 361 } | |
| 362 | |
| 357 void test_parseClassMember_constructor_withInitializers() { | 363 void test_parseClassMember_constructor_withInitializers() { |
| 358 // TODO(brianwilkerson) Test other kinds of class members: fields, getters | 364 // TODO(brianwilkerson) Test other kinds of class members: fields, getters |
| 359 // and setters. | 365 // and setters. |
| 360 createParser('C(_, _\$, this.__) : _a = _ + _\$ {}'); | 366 createParser('C(_, _\$, this.__) : _a = _ + _\$ {}'); |
| 361 ClassMember member = parser.parseClassMember('C'); | 367 ClassMember member = parser.parseClassMember('C'); |
| 362 expect(member, isNotNull); | 368 expect(member, isNotNull); |
| 363 assertNoErrors(); | 369 assertNoErrors(); |
| 364 expect(member, new isInstanceOf<ConstructorDeclaration>()); | 370 expect(member, new isInstanceOf<ConstructorDeclaration>()); |
| 365 ConstructorDeclaration constructor = member; | 371 ConstructorDeclaration constructor = member; |
| 366 expect(constructor.body, isNotNull); | 372 expect(constructor.body, isNotNull); |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1225 expectCommentText(method.documentationComment, '/// Doc'); | 1231 expectCommentText(method.documentationComment, '/// Doc'); |
| 1226 expect(method.externalKeyword, isNull); | 1232 expect(method.externalKeyword, isNull); |
| 1227 expect(method.modifierKeyword.lexeme, 'static'); | 1233 expect(method.modifierKeyword.lexeme, 'static'); |
| 1228 expect(method.name, isNotNull); | 1234 expect(method.name, isNotNull); |
| 1229 expect(method.operatorKeyword, isNull); | 1235 expect(method.operatorKeyword, isNull); |
| 1230 expect(method.typeParameters, isNull); | 1236 expect(method.typeParameters, isNull); |
| 1231 expect(method.parameters, isNotNull); | 1237 expect(method.parameters, isNotNull); |
| 1232 expect(method.propertyKeyword, isNotNull); | 1238 expect(method.propertyKeyword, isNotNull); |
| 1233 expect((method.returnType as TypeName).name.name, 'T'); | 1239 expect((method.returnType as TypeName).name.name, 'T'); |
| 1234 } | 1240 } |
| 1241 | |
| 1242 void test_simpleFormalParameter_withDocComment() { | |
| 1243 createParser(''' | |
| 1244 int f( | |
| 1245 /// Doc | |
| 1246 int x) {} | |
| 1247 '''); | |
| 1248 var function = parseFullCompilationUnitMember() as FunctionDeclaration; | |
| 1249 var parameter = function.functionExpression.parameters.parameters[0] | |
| 1250 as NormalFormalParameter; | |
| 1251 expectCommentText(parameter.documentationComment, '/// Doc'); | |
| 1252 } | |
| 1235 } | 1253 } |
| 1236 | 1254 |
| 1237 /** | 1255 /** |
| 1238 * Tests of the analyzer parser based on [ComplexParserTestMixin]. | 1256 * Tests of the analyzer parser based on [ComplexParserTestMixin]. |
| 1239 */ | 1257 */ |
| 1240 @reflectiveTest | 1258 @reflectiveTest |
| 1241 class ComplexParserTest extends ParserTestCase with ComplexParserTestMixin {} | 1259 class ComplexParserTest extends ParserTestCase with ComplexParserTestMixin {} |
| 1242 | 1260 |
| 1243 /** | 1261 /** |
| 1244 * The class `ComplexParserTest` defines parser tests that test the parsing of m ore complex | 1262 * The class `ComplexParserTest` defines parser tests that test the parsing of m ore complex |
| (...skipping 5998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7243 expect(parameter, new isInstanceOf<FieldFormalParameter>()); | 7261 expect(parameter, new isInstanceOf<FieldFormalParameter>()); |
| 7244 FieldFormalParameter fieldParameter = parameter; | 7262 FieldFormalParameter fieldParameter = parameter; |
| 7245 expect(fieldParameter.keyword, isNull); | 7263 expect(fieldParameter.keyword, isNull); |
| 7246 expect(fieldParameter.type, isNull); | 7264 expect(fieldParameter.type, isNull); |
| 7247 expect(fieldParameter.identifier, isNotNull); | 7265 expect(fieldParameter.identifier, isNotNull); |
| 7248 FormalParameterList parameterList = fieldParameter.parameters; | 7266 FormalParameterList parameterList = fieldParameter.parameters; |
| 7249 expect(parameterList, isNotNull); | 7267 expect(parameterList, isNotNull); |
| 7250 expect(parameterList.parameters, hasLength(0)); | 7268 expect(parameterList.parameters, hasLength(0)); |
| 7251 } | 7269 } |
| 7252 | 7270 |
| 7271 void test_parseNormalFormalParameter_field_function_withDocComment() { | |
| 7272 var parameter = parseNormalFormalParameter('/// Doc\nthis.f()'); | |
| 7273 expectCommentText(parameter.documentationComment, '/// Doc'); | |
| 7274 } | |
| 7275 | |
| 7253 void test_parseNormalFormalParameter_field_noType() { | 7276 void test_parseNormalFormalParameter_field_noType() { |
| 7254 NormalFormalParameter parameter = parseNormalFormalParameter('this.a'); | 7277 NormalFormalParameter parameter = parseNormalFormalParameter('this.a'); |
| 7255 expect(parameter, isNotNull); | 7278 expect(parameter, isNotNull); |
| 7256 assertNoErrors(); | 7279 assertNoErrors(); |
| 7257 expect(parameter, new isInstanceOf<FieldFormalParameter>()); | 7280 expect(parameter, new isInstanceOf<FieldFormalParameter>()); |
| 7258 FieldFormalParameter fieldParameter = parameter; | 7281 FieldFormalParameter fieldParameter = parameter; |
| 7259 expect(fieldParameter.keyword, isNull); | 7282 expect(fieldParameter.keyword, isNull); |
| 7260 expect(fieldParameter.type, isNull); | 7283 expect(fieldParameter.type, isNull); |
| 7261 expect(fieldParameter.identifier, isNotNull); | 7284 expect(fieldParameter.identifier, isNotNull); |
| 7262 expect(fieldParameter.parameters, isNull); | 7285 expect(fieldParameter.parameters, isNull); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 7279 expect(parameter, isNotNull); | 7302 expect(parameter, isNotNull); |
| 7280 assertNoErrors(); | 7303 assertNoErrors(); |
| 7281 expect(parameter, new isInstanceOf<FieldFormalParameter>()); | 7304 expect(parameter, new isInstanceOf<FieldFormalParameter>()); |
| 7282 FieldFormalParameter fieldParameter = parameter; | 7305 FieldFormalParameter fieldParameter = parameter; |
| 7283 expect(fieldParameter.keyword, isNotNull); | 7306 expect(fieldParameter.keyword, isNotNull); |
| 7284 expect(fieldParameter.type, isNull); | 7307 expect(fieldParameter.type, isNull); |
| 7285 expect(fieldParameter.identifier, isNotNull); | 7308 expect(fieldParameter.identifier, isNotNull); |
| 7286 expect(fieldParameter.parameters, isNull); | 7309 expect(fieldParameter.parameters, isNull); |
| 7287 } | 7310 } |
| 7288 | 7311 |
| 7312 void test_parseNormalFormalParameter_field_withDocComment() { | |
| 7313 var parameter = parseNormalFormalParameter('/// Doc\nthis.a'); | |
| 7314 expectCommentText(parameter.documentationComment, '/// Doc'); | |
| 7315 } | |
| 7316 | |
| 7289 void test_parseNormalFormalParameter_function_named() { | 7317 void test_parseNormalFormalParameter_function_named() { |
| 7290 ParameterKind kind = ParameterKind.NAMED; | 7318 ParameterKind kind = ParameterKind.NAMED; |
| 7291 var defaultParameter = | 7319 var defaultParameter = |
| 7292 parseFormalParameter('a() : null', kind) as DefaultFormalParameter; | 7320 parseFormalParameter('a() : null', kind) as DefaultFormalParameter; |
| 7293 var functionParameter = | 7321 var functionParameter = |
| 7294 defaultParameter.parameter as FunctionTypedFormalParameter; | 7322 defaultParameter.parameter as FunctionTypedFormalParameter; |
| 7295 assertNoErrors(); | 7323 assertNoErrors(); |
| 7296 expect(functionParameter.returnType, isNull); | 7324 expect(functionParameter.returnType, isNull); |
| 7297 expect(functionParameter.identifier, isNotNull); | 7325 expect(functionParameter.identifier, isNotNull); |
| 7298 expect(functionParameter.typeParameters, isNull); | 7326 expect(functionParameter.typeParameters, isNull); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7517 assertNoErrors(); | 7545 assertNoErrors(); |
| 7518 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 7546 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
| 7519 FunctionTypedFormalParameter functionParameter = parameter; | 7547 FunctionTypedFormalParameter functionParameter = parameter; |
| 7520 expect(functionParameter.returnType, isNotNull); | 7548 expect(functionParameter.returnType, isNotNull); |
| 7521 expect(functionParameter.identifier, isNotNull); | 7549 expect(functionParameter.identifier, isNotNull); |
| 7522 expect(functionParameter.typeParameters, isNotNull); | 7550 expect(functionParameter.typeParameters, isNotNull); |
| 7523 expect(functionParameter.parameters, isNotNull); | 7551 expect(functionParameter.parameters, isNotNull); |
| 7524 expect(functionParameter.question, isNotNull); | 7552 expect(functionParameter.question, isNotNull); |
| 7525 } | 7553 } |
| 7526 | 7554 |
| 7555 void test_parseNormalFormalParameter_function_withDocComment() { | |
| 7556 var parameter = parseFormalParameter('/// Doc\nf()', ParameterKind.REQUIRED) | |
| 7557 as FunctionTypedFormalParameter; | |
| 7558 expectCommentText(parameter.documentationComment, '/// Doc'); | |
| 7559 } | |
| 7560 | |
| 7527 void test_parseNormalFormalParameter_simple_const_noType() { | 7561 void test_parseNormalFormalParameter_simple_const_noType() { |
| 7528 NormalFormalParameter parameter = parseNormalFormalParameter('const a'); | 7562 NormalFormalParameter parameter = parseNormalFormalParameter('const a'); |
| 7529 expect(parameter, isNotNull); | 7563 expect(parameter, isNotNull); |
| 7530 assertNoErrors(); | 7564 assertNoErrors(); |
| 7531 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); | 7565 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); |
| 7532 SimpleFormalParameter simpleParameter = parameter; | 7566 SimpleFormalParameter simpleParameter = parameter; |
| 7533 expect(simpleParameter.keyword, isNotNull); | 7567 expect(simpleParameter.keyword, isNotNull); |
| 7534 expect(simpleParameter.type, isNull); | 7568 expect(simpleParameter.type, isNull); |
| 7535 expect(simpleParameter.identifier, isNotNull); | 7569 expect(simpleParameter.identifier, isNotNull); |
| 7536 } | 7570 } |
| (...skipping 5504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13041 | 13075 |
| 13042 void test_import_as_show() { | 13076 void test_import_as_show() { |
| 13043 parseCompilationUnit("import 'dart:math' as M show E;"); | 13077 parseCompilationUnit("import 'dart:math' as M show E;"); |
| 13044 } | 13078 } |
| 13045 | 13079 |
| 13046 void test_import_show_hide() { | 13080 void test_import_show_hide() { |
| 13047 parseCompilationUnit( | 13081 parseCompilationUnit( |
| 13048 "import 'import1_lib.dart' show hide, show hide ugly;"); | 13082 "import 'import1_lib.dart' show hide, show hide ugly;"); |
| 13049 } | 13083 } |
| 13050 | 13084 |
| 13085 void test_import_withDocComment() { | |
| 13086 var compilationUnit = parseCompilationUnit('/// Doc\nimport "foo.dart";'); | |
| 13087 var importDirective = compilationUnit.directives[0]; | |
| 13088 expectCommentText(importDirective.documentationComment, '/// Doc'); | |
| 13089 } | |
| 13090 | |
| 13051 void test_parseClassDeclaration_abstract() { | 13091 void test_parseClassDeclaration_abstract() { |
| 13052 createParser('abstract class A {}'); | 13092 createParser('abstract class A {}'); |
| 13053 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13093 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13054 expect(member, isNotNull); | 13094 expect(member, isNotNull); |
| 13055 assertNoErrors(); | 13095 assertNoErrors(); |
| 13056 expect(member, new isInstanceOf<ClassDeclaration>()); | 13096 expect(member, new isInstanceOf<ClassDeclaration>()); |
| 13057 ClassDeclaration declaration = member; | 13097 ClassDeclaration declaration = member; |
| 13058 expect(declaration.documentationComment, isNull); | 13098 expect(declaration.documentationComment, isNull); |
| 13059 expect(declaration.abstractKeyword, isNotNull); | 13099 expect(declaration.abstractKeyword, isNotNull); |
| 13060 expect(declaration.extendsClause, isNull); | 13100 expect(declaration.extendsClause, isNull); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13264 expect(declaration.implementsClause, isNull); | 13304 expect(declaration.implementsClause, isNull); |
| 13265 expect(declaration.classKeyword, isNotNull); | 13305 expect(declaration.classKeyword, isNotNull); |
| 13266 expect(declaration.leftBracket, isNotNull); | 13306 expect(declaration.leftBracket, isNotNull); |
| 13267 expect(declaration.name, isNotNull); | 13307 expect(declaration.name, isNotNull); |
| 13268 expect(declaration.members, hasLength(0)); | 13308 expect(declaration.members, hasLength(0)); |
| 13269 expect(declaration.rightBracket, isNotNull); | 13309 expect(declaration.rightBracket, isNotNull); |
| 13270 expect(declaration.typeParameters, isNotNull); | 13310 expect(declaration.typeParameters, isNotNull); |
| 13271 expect(declaration.typeParameters.typeParameters, hasLength(1)); | 13311 expect(declaration.typeParameters.typeParameters, hasLength(1)); |
| 13272 } | 13312 } |
| 13273 | 13313 |
| 13314 void test_parseClassDeclaration_withDocumentationComment() { | |
| 13315 createParser('/// Doc\nclass C {}'); | |
| 13316 var classDeclaration = parseFullCompilationUnitMember() as ClassDeclaration; | |
| 13317 expectCommentText(classDeclaration.documentationComment, '/// Doc'); | |
| 13318 } | |
| 13319 | |
| 13320 void test_parseClassTypeAlias_withDocumentationComment() { | |
| 13321 createParser('/// Doc\nclass C = D with E;'); | |
| 13322 var classTypeAlias = parseFullCompilationUnitMember() as ClassTypeAlias; | |
| 13323 expectCommentText(classTypeAlias.documentationComment, '/// Doc'); | |
| 13324 } | |
| 13325 | |
| 13274 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { | 13326 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { |
| 13275 createParser('abstract<dynamic> _abstract = new abstract.A();'); | 13327 createParser('abstract<dynamic> _abstract = new abstract.A();'); |
| 13276 CompilationUnit unit = parser.parseCompilationUnit2(); | 13328 CompilationUnit unit = parser.parseCompilationUnit2(); |
| 13277 expect(unit, isNotNull); | 13329 expect(unit, isNotNull); |
| 13278 assertNoErrors(); | 13330 assertNoErrors(); |
| 13279 expect(unit.scriptTag, isNull); | 13331 expect(unit.scriptTag, isNull); |
| 13280 expect(unit.directives, hasLength(0)); | 13332 expect(unit.directives, hasLength(0)); |
| 13281 expect(unit.declarations, hasLength(1)); | 13333 expect(unit.declarations, hasLength(1)); |
| 13282 } | 13334 } |
| 13283 | 13335 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13734 createParser('typedef F();'); | 13786 createParser('typedef F();'); |
| 13735 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13787 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13736 expect(member, isNotNull); | 13788 expect(member, isNotNull); |
| 13737 assertNoErrors(); | 13789 assertNoErrors(); |
| 13738 expect(member, new isInstanceOf<FunctionTypeAlias>()); | 13790 expect(member, new isInstanceOf<FunctionTypeAlias>()); |
| 13739 FunctionTypeAlias typeAlias = member; | 13791 FunctionTypeAlias typeAlias = member; |
| 13740 expect(typeAlias.name.name, "F"); | 13792 expect(typeAlias.name.name, "F"); |
| 13741 expect(typeAlias.parameters.parameters, hasLength(0)); | 13793 expect(typeAlias.parameters.parameters, hasLength(0)); |
| 13742 } | 13794 } |
| 13743 | 13795 |
| 13796 void test_parseCompilationUnitMember_typedef_withDocComment() { | |
| 13797 createParser('/// Doc\ntypedef F();'); | |
| 13798 var typeAlias = parseFullCompilationUnitMember() as FunctionTypeAlias; | |
| 13799 expectCommentText(typeAlias.documentationComment, '/// Doc'); | |
| 13800 } | |
| 13801 | |
| 13744 void test_parseCompilationUnitMember_typedVariable() { | 13802 void test_parseCompilationUnitMember_typedVariable() { |
| 13745 createParser('int x = 0;'); | 13803 createParser('int x = 0;'); |
| 13746 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13804 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13747 expect(member, isNotNull); | 13805 expect(member, isNotNull); |
| 13748 assertNoErrors(); | 13806 assertNoErrors(); |
| 13749 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13807 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13750 TopLevelVariableDeclaration declaration = member; | 13808 TopLevelVariableDeclaration declaration = member; |
| 13751 expect(declaration.semicolon, isNotNull); | 13809 expect(declaration.semicolon, isNotNull); |
| 13752 expect(declaration.variables, isNotNull); | 13810 expect(declaration.variables, isNotNull); |
| 13753 expect(declaration.variables.type, isNotNull); | 13811 expect(declaration.variables.type, isNotNull); |
| 13754 expect(declaration.variables.keyword, isNull); | 13812 expect(declaration.variables.keyword, isNull); |
| 13755 } | 13813 } |
| 13756 | 13814 |
| 13757 void test_parseCompilationUnitMember_variable() { | 13815 void test_parseCompilationUnitMember_variable() { |
| 13758 createParser('var x = 0;'); | 13816 createParser('var x = 0;'); |
| 13759 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13817 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13760 expect(member, isNotNull); | 13818 expect(member, isNotNull); |
| 13761 assertNoErrors(); | 13819 assertNoErrors(); |
| 13762 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13820 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13763 TopLevelVariableDeclaration declaration = member; | 13821 TopLevelVariableDeclaration declaration = member; |
| 13764 expect(declaration.semicolon, isNotNull); | 13822 expect(declaration.semicolon, isNotNull); |
| 13765 expect(declaration.variables, isNotNull); | 13823 expect(declaration.variables, isNotNull); |
| 13766 expect(declaration.variables.keyword.lexeme, 'var'); | 13824 expect(declaration.variables.keyword.lexeme, 'var'); |
| 13767 } | 13825 } |
| 13768 | 13826 |
| 13827 void test_parseCompilationUnitMember_variable_withDocumentationComment() { | |
| 13828 createParser('/// Doc\nvar x = 0;'); | |
| 13829 var declaration = | |
| 13830 parseFullCompilationUnitMember() as TopLevelVariableDeclaration; | |
| 13831 expectCommentText(declaration.documentationComment, '/// Doc'); | |
| 13832 } | |
| 13833 | |
| 13769 void test_parseCompilationUnitMember_variableGet() { | 13834 void test_parseCompilationUnitMember_variableGet() { |
| 13770 createParser('String get = null;'); | 13835 createParser('String get = null;'); |
| 13771 CompilationUnitMember member = parseFullCompilationUnitMember(); | 13836 CompilationUnitMember member = parseFullCompilationUnitMember(); |
| 13772 expect(member, isNotNull); | 13837 expect(member, isNotNull); |
| 13773 assertNoErrors(); | 13838 assertNoErrors(); |
| 13774 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); | 13839 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); |
| 13775 TopLevelVariableDeclaration declaration = member; | 13840 TopLevelVariableDeclaration declaration = member; |
| 13776 expect(declaration.semicolon, isNotNull); | 13841 expect(declaration.semicolon, isNotNull); |
| 13777 expect(declaration.variables, isNotNull); | 13842 expect(declaration.variables, isNotNull); |
| 13778 } | 13843 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 13794 expect(directive, isNotNull); | 13859 expect(directive, isNotNull); |
| 13795 assertNoErrors(); | 13860 assertNoErrors(); |
| 13796 expect(directive, new isInstanceOf<ExportDirective>()); | 13861 expect(directive, new isInstanceOf<ExportDirective>()); |
| 13797 ExportDirective exportDirective = directive; | 13862 ExportDirective exportDirective = directive; |
| 13798 expect(exportDirective.keyword, isNotNull); | 13863 expect(exportDirective.keyword, isNotNull); |
| 13799 expect(exportDirective.uri, isNotNull); | 13864 expect(exportDirective.uri, isNotNull); |
| 13800 expect(exportDirective.combinators, hasLength(0)); | 13865 expect(exportDirective.combinators, hasLength(0)); |
| 13801 expect(exportDirective.semicolon, isNotNull); | 13866 expect(exportDirective.semicolon, isNotNull); |
| 13802 } | 13867 } |
| 13803 | 13868 |
| 13869 void test_parseDirective_export_withDocComment() { | |
| 13870 createParser("/// Doc\nexport 'foo.dart';"); | |
| 13871 var directive = parseFullDirective() as ExportDirective; | |
| 13872 expectCommentText(directive.documentationComment, '/// Doc'); | |
| 13873 } | |
| 13874 | |
| 13804 void test_parseDirective_import() { | 13875 void test_parseDirective_import() { |
| 13805 createParser("import 'lib/lib.dart';"); | 13876 createParser("import 'lib/lib.dart';"); |
| 13806 Directive directive = parseFullDirective(); | 13877 Directive directive = parseFullDirective(); |
| 13807 expect(directive, isNotNull); | 13878 expect(directive, isNotNull); |
| 13808 assertNoErrors(); | 13879 assertNoErrors(); |
| 13809 expect(directive, new isInstanceOf<ImportDirective>()); | 13880 expect(directive, new isInstanceOf<ImportDirective>()); |
| 13810 ImportDirective importDirective = directive; | 13881 ImportDirective importDirective = directive; |
| 13811 expect(importDirective.keyword, isNotNull); | 13882 expect(importDirective.keyword, isNotNull); |
| 13812 expect(importDirective.uri, isNotNull); | 13883 expect(importDirective.uri, isNotNull); |
| 13813 expect(importDirective.asKeyword, isNull); | 13884 expect(importDirective.asKeyword, isNull); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13845 | 13916 |
| 13846 void test_parseDirective_library_3_components() { | 13917 void test_parseDirective_library_3_components() { |
| 13847 createParser("library a.b.c;"); | 13918 createParser("library a.b.c;"); |
| 13848 var lib = parseFullDirective() as LibraryDirective; | 13919 var lib = parseFullDirective() as LibraryDirective; |
| 13849 expect(lib.name.components, hasLength(3)); | 13920 expect(lib.name.components, hasLength(3)); |
| 13850 expect(lib.name.components[0].name, 'a'); | 13921 expect(lib.name.components[0].name, 'a'); |
| 13851 expect(lib.name.components[1].name, 'b'); | 13922 expect(lib.name.components[1].name, 'b'); |
| 13852 expect(lib.name.components[2].name, 'c'); | 13923 expect(lib.name.components[2].name, 'c'); |
| 13853 } | 13924 } |
| 13854 | 13925 |
| 13926 void test_parseDirective_library_withDocumentationComment() { | |
| 13927 createParser('/// Doc\nlibrary l;'); | |
| 13928 var directive = parseFullDirective() as LibraryDirective; | |
| 13929 expectCommentText(directive.documentationComment, '/// Doc'); | |
| 13930 } | |
| 13931 | |
| 13855 void test_parseDirective_part() { | 13932 void test_parseDirective_part() { |
| 13856 createParser("part 'lib/lib.dart';"); | 13933 createParser("part 'lib/lib.dart';"); |
| 13857 Directive directive = parseFullDirective(); | 13934 Directive directive = parseFullDirective(); |
| 13858 expect(directive, isNotNull); | 13935 expect(directive, isNotNull); |
| 13859 assertNoErrors(); | 13936 assertNoErrors(); |
| 13860 expect(directive, new isInstanceOf<PartDirective>()); | 13937 expect(directive, new isInstanceOf<PartDirective>()); |
| 13861 PartDirective partDirective = directive; | 13938 PartDirective partDirective = directive; |
| 13862 expect(partDirective.partKeyword, isNotNull); | 13939 expect(partDirective.partKeyword, isNotNull); |
| 13863 expect(partDirective.uri, isNotNull); | 13940 expect(partDirective.uri, isNotNull); |
| 13864 expect(partDirective.semicolon, isNotNull); | 13941 expect(partDirective.semicolon, isNotNull); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 13881 | 13958 |
| 13882 void test_parseDirective_part_of_3_components() { | 13959 void test_parseDirective_part_of_3_components() { |
| 13883 createParser("part of a.b.c;"); | 13960 createParser("part of a.b.c;"); |
| 13884 var partOf = parseFullDirective() as PartOfDirective; | 13961 var partOf = parseFullDirective() as PartOfDirective; |
| 13885 expect(partOf.libraryName.components, hasLength(3)); | 13962 expect(partOf.libraryName.components, hasLength(3)); |
| 13886 expect(partOf.libraryName.components[0].name, 'a'); | 13963 expect(partOf.libraryName.components[0].name, 'a'); |
| 13887 expect(partOf.libraryName.components[1].name, 'b'); | 13964 expect(partOf.libraryName.components[1].name, 'b'); |
| 13888 expect(partOf.libraryName.components[2].name, 'c'); | 13965 expect(partOf.libraryName.components[2].name, 'c'); |
| 13889 } | 13966 } |
| 13890 | 13967 |
| 13968 void test_parseDirective_part_of_withDocumentationComment() { | |
| 13969 createParser('/// Doc\npart of a;'); | |
| 13970 var partOf = parseFullDirective() as PartOfDirective; | |
| 13971 expectCommentText(partOf.documentationComment, '/// Doc'); | |
| 13972 } | |
| 13973 | |
| 13974 void test_parseDirective_part_withDocumentationComment() { | |
| 13975 createParser("/// Doc\npart 'lib.dart';"); | |
| 13976 var directive = parseFullDirective() as PartDirective; | |
| 13977 expectCommentText(directive.documentationComment, '/// Doc'); | |
| 13978 } | |
| 13979 | |
| 13891 void test_parseDirective_partOf() { | 13980 void test_parseDirective_partOf() { |
| 13892 createParser("part of l;"); | 13981 createParser("part of l;"); |
| 13893 Directive directive = parseFullDirective(); | 13982 Directive directive = parseFullDirective(); |
| 13894 expect(directive, isNotNull); | 13983 expect(directive, isNotNull); |
| 13895 assertNoErrors(); | 13984 assertNoErrors(); |
| 13896 expect(directive, new isInstanceOf<PartOfDirective>()); | 13985 expect(directive, new isInstanceOf<PartOfDirective>()); |
| 13897 PartOfDirective partOfDirective = directive; | 13986 PartOfDirective partOfDirective = directive; |
| 13898 expect(partOfDirective.partKeyword, isNotNull); | 13987 expect(partOfDirective.partKeyword, isNotNull); |
| 13899 expect(partOfDirective.ofKeyword, isNotNull); | 13988 expect(partOfDirective.ofKeyword, isNotNull); |
| 13900 expect(partOfDirective.libraryName, isNotNull); | 13989 expect(partOfDirective.libraryName, isNotNull); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13977 expect(declaration, isNotNull); | 14066 expect(declaration, isNotNull); |
| 13978 assertNoErrors(); | 14067 assertNoErrors(); |
| 13979 expect(declaration.documentationComment, isNull); | 14068 expect(declaration.documentationComment, isNull); |
| 13980 expect(declaration.enumKeyword, isNotNull); | 14069 expect(declaration.enumKeyword, isNotNull); |
| 13981 expect(declaration.leftBracket, isNotNull); | 14070 expect(declaration.leftBracket, isNotNull); |
| 13982 expect(declaration.name, isNotNull); | 14071 expect(declaration.name, isNotNull); |
| 13983 expect(declaration.constants, hasLength(2)); | 14072 expect(declaration.constants, hasLength(2)); |
| 13984 expect(declaration.rightBracket, isNotNull); | 14073 expect(declaration.rightBracket, isNotNull); |
| 13985 } | 14074 } |
| 13986 | 14075 |
| 14076 void test_parseEnumDeclaration_withDocComment_onEnum() { | |
| 14077 createParser('/// Doc\nenum E {ONE}'); | |
| 14078 var declaration = parseFullCompilationUnitMember() as EnumDeclaration; | |
| 14079 expectCommentText(declaration.documentationComment, '/// Doc'); | |
| 14080 } | |
| 14081 | |
| 14082 void test_parseEnumDeclaration_withDocComment_onValue() { | |
| 14083 createParser(''' | |
| 14084 enum E { | |
| 14085 /// Doc | |
| 14086 ONE | |
| 14087 }'''); | |
| 14088 var declaration = parseFullCompilationUnitMember() as EnumDeclaration; | |
| 14089 var value = declaration.constants[0]; | |
| 14090 expectCommentText(value.documentationComment, '/// Doc'); | |
| 14091 } | |
| 14092 | |
| 13987 void test_parseExportDirective_configuration_multiple() { | 14093 void test_parseExportDirective_configuration_multiple() { |
| 13988 createParser("export 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); | 14094 createParser("export 'lib/lib.dart' if (a) 'b.dart' if (c) 'd.dart';"); |
| 13989 ExportDirective directive = parseFullDirective(); | 14095 ExportDirective directive = parseFullDirective(); |
| 13990 expect(directive, isNotNull); | 14096 expect(directive, isNotNull); |
| 13991 assertNoErrors(); | 14097 assertNoErrors(); |
| 13992 expect(directive.keyword, isNotNull); | 14098 expect(directive.keyword, isNotNull); |
| 13993 expect(directive.uri, isNotNull); | 14099 expect(directive.uri, isNotNull); |
| 13994 expect(directive.configurations, hasLength(2)); | 14100 expect(directive.configurations, hasLength(2)); |
| 13995 expectDottedName(directive.configurations[0].name, ['a']); | 14101 expectDottedName(directive.configurations[0].name, ['a']); |
| 13996 expectDottedName(directive.configurations[1].name, ['c']); | 14102 expectDottedName(directive.configurations[1].name, ['c']); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14611 expect(typeAlias.typedefKeyword, isNotNull); | 14717 expect(typeAlias.typedefKeyword, isNotNull); |
| 14612 expect(typeAlias.name, isNotNull); | 14718 expect(typeAlias.name, isNotNull); |
| 14613 expect(typeAlias.typeParameters, isNull); | 14719 expect(typeAlias.typeParameters, isNull); |
| 14614 expect(typeAlias.semicolon, isNotNull); | 14720 expect(typeAlias.semicolon, isNotNull); |
| 14615 GenericFunctionType functionType = typeAlias.functionType; | 14721 GenericFunctionType functionType = typeAlias.functionType; |
| 14616 expect(functionType, isNotNull); | 14722 expect(functionType, isNotNull); |
| 14617 expect(functionType.parameters, isNotNull); | 14723 expect(functionType.parameters, isNotNull); |
| 14618 expect(functionType.returnType, isNotNull); | 14724 expect(functionType.returnType, isNotNull); |
| 14619 expect(functionType.typeParameters, isNull); | 14725 expect(functionType.typeParameters, isNull); |
| 14620 } | 14726 } |
| 14727 | |
| 14728 void test_parseTypeAlias_genericFunction_withDocComment() { | |
| 14729 createParser('/// Doc\ntypedef F = bool Function();'); | |
| 14730 var typeAlias = parseFullCompilationUnitMember() as GenericTypeAlias; | |
| 14731 expectCommentText(typeAlias.documentationComment, '/// Doc'); | |
| 14732 } | |
| 14621 } | 14733 } |
| OLD | NEW |