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 engine.parser_test; | 5 library engine.parser_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
(...skipping 3320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3331 NodeList<VariableDeclaration> vars = | 3331 NodeList<VariableDeclaration> vars = |
3332 (fieldDecl as FieldDeclaration).fields.variables; | 3332 (fieldDecl as FieldDeclaration).fields.variables; |
3333 expect(vars, hasLength(1)); | 3333 expect(vars, hasLength(1)); |
3334 expect(vars[0].name.name, "v"); | 3334 expect(vars[0].name.name, "v"); |
3335 } | 3335 } |
3336 | 3336 |
3337 void test_functionExpression_named() { | 3337 void test_functionExpression_named() { |
3338 parseExpression("m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]); | 3338 parseExpression("m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]); |
3339 } | 3339 } |
3340 | 3340 |
| 3341 void test_declarationBeforeDirective() { |
| 3342 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 3343 "class foo { } import 'bar.dart';", |
| 3344 [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION]); |
| 3345 expect(unit.directives, hasLength(1)); |
| 3346 expect(unit.declarations, hasLength(1)); |
| 3347 ClassDeclaration classDecl = unit.childEntities.first; |
| 3348 expect(classDecl, isNotNull); |
| 3349 expect(classDecl.name.name, 'foo'); |
| 3350 } |
| 3351 |
3341 void test_importDirectivePartial_as() { | 3352 void test_importDirectivePartial_as() { |
3342 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3353 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
3343 "import 'b.dart' d as b;", [ParserErrorCode.UNEXPECTED_TOKEN]); | 3354 "import 'b.dart' d as b;", [ParserErrorCode.UNEXPECTED_TOKEN]); |
3344 ImportDirective importDirective = unit.childEntities.first; | 3355 ImportDirective importDirective = unit.childEntities.first; |
3345 expect(importDirective.asKeyword, isNotNull); | 3356 expect(importDirective.asKeyword, isNotNull); |
3346 expect(unit.directives, hasLength(1)); | 3357 expect(unit.directives, hasLength(1)); |
3347 expect(unit.declarations, hasLength(0)); | 3358 expect(unit.declarations, hasLength(0)); |
3348 } | 3359 } |
3349 | 3360 |
3350 void test_importDirectivePartial_hide() { | 3361 void test_importDirectivePartial_hide() { |
(...skipping 7323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10674 new Scanner(null, new CharSequenceReader(source), listener); | 10685 new Scanner(null, new CharSequenceReader(source), listener); |
10675 Token tokenStream = scanner.tokenize(); | 10686 Token tokenStream = scanner.tokenize(); |
10676 // | 10687 // |
10677 // Parse the source. | 10688 // Parse the source. |
10678 // | 10689 // |
10679 Parser parser = new Parser(null, listener); | 10690 Parser parser = new Parser(null, listener); |
10680 return invokeParserMethodImpl( | 10691 return invokeParserMethodImpl( |
10681 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 10692 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
10682 } | 10693 } |
10683 } | 10694 } |
OLD | NEW |