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 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
7 import 'package:analyzer/dart/ast/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
9 import 'package:analyzer/error/error.dart'; | 9 import 'package:analyzer/error/error.dart'; |
10 import 'package:analyzer/error/listener.dart'; | 10 import 'package:analyzer/error/listener.dart'; |
(...skipping 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 void test_expectedToken_parseStatement_afterVoid() { | 2640 void test_expectedToken_parseStatement_afterVoid() { |
2641 parseStatement("void}"); | 2641 parseStatement("void}"); |
2642 assertErrorsWithCodes( | 2642 assertErrorsWithCodes( |
2643 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); | 2643 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); |
2644 } | 2644 } |
2645 | 2645 |
2646 void test_expectedToken_semicolonMissingAfterExport() { | 2646 void test_expectedToken_semicolonMissingAfterExport() { |
2647 CompilationUnit unit = parseCompilationUnit( | 2647 CompilationUnit unit = parseCompilationUnit( |
2648 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); | 2648 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); |
2649 ExportDirective directive = unit.directives[0] as ExportDirective; | 2649 ExportDirective directive = unit.directives[0] as ExportDirective; |
| 2650 expect(directive.uri, isNotNull); |
| 2651 expect(directive.uri.stringValue, ''); |
| 2652 expect(directive.uri.beginToken.isSynthetic, false); |
| 2653 expect(directive.uri.isSynthetic, false); |
2650 Token semicolon = directive.semicolon; | 2654 Token semicolon = directive.semicolon; |
2651 expect(semicolon, isNotNull); | 2655 expect(semicolon, isNotNull); |
2652 expect(semicolon.isSynthetic, isTrue); | 2656 expect(semicolon.isSynthetic, isTrue); |
| 2657 ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration; |
| 2658 expect(clazz.name.name, 'A'); |
| 2659 } |
| 2660 |
| 2661 void test_expectedToken_uriAndSemicolonMissingAfterExport() { |
| 2662 CompilationUnit unit = parseCompilationUnit("export class A {}", [ |
| 2663 ParserErrorCode.EXPECTED_STRING_LITERAL, |
| 2664 ParserErrorCode.EXPECTED_TOKEN, |
| 2665 ]); |
| 2666 ExportDirective directive = unit.directives[0] as ExportDirective; |
| 2667 expect(directive.uri, isNotNull); |
| 2668 expect(directive.uri.stringValue, ''); |
| 2669 expect(directive.uri.beginToken.isSynthetic, true); |
| 2670 expect(directive.uri.isSynthetic, true); |
| 2671 Token semicolon = directive.semicolon; |
| 2672 expect(semicolon, isNotNull); |
| 2673 expect(semicolon.isSynthetic, isTrue); |
| 2674 ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration; |
| 2675 expect(clazz.name.name, 'A'); |
2653 } | 2676 } |
2654 | 2677 |
2655 void test_expectedToken_semicolonMissingAfterExpression() { | 2678 void test_expectedToken_semicolonMissingAfterExpression() { |
2656 parseStatement("x"); | 2679 parseStatement("x"); |
2657 assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]); | 2680 assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]); |
2658 } | 2681 } |
2659 | 2682 |
2660 void test_expectedToken_semicolonMissingAfterImport() { | 2683 void test_expectedToken_semicolonMissingAfterImport() { |
2661 CompilationUnit unit = parseCompilationUnit( | 2684 CompilationUnit unit = parseCompilationUnit( |
2662 "import '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); | 2685 "import '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); |
(...skipping 12781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15444 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 15467 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
15445 } | 15468 } |
15446 | 15469 |
15447 /** | 15470 /** |
15448 * Assert that the given [name] is in declaration context. | 15471 * Assert that the given [name] is in declaration context. |
15449 */ | 15472 */ |
15450 void _assertIsDeclarationName(SimpleIdentifier name) { | 15473 void _assertIsDeclarationName(SimpleIdentifier name) { |
15451 expect(name.inDeclarationContext(), isTrue); | 15474 expect(name.inDeclarationContext(), isTrue); |
15452 } | 15475 } |
15453 } | 15476 } |
OLD | NEW |