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/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
9 import 'package:analyzer/src/dart/element/element.dart'; | 9 import 'package:analyzer/src/dart/element/element.dart'; |
10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 [ParserErrorCode.DUPLICATED_MODIFIER]); | 930 [ParserErrorCode.DUPLICATED_MODIFIER]); |
931 } | 931 } |
932 | 932 |
933 void test_duplicateLabelInSwitchStatement() { | 933 void test_duplicateLabelInSwitchStatement() { |
934 parse4( | 934 parse4( |
935 "parseSwitchStatement", | 935 "parseSwitchStatement", |
936 "switch (e) {l1: case 0: break; l1: case 1: break;}", | 936 "switch (e) {l1: case 0: break; l1: case 1: break;}", |
937 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]); | 937 [ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT]); |
938 } | 938 } |
939 | 939 |
| 940 void test_enableAsync_false_1() { |
| 941 parseAsync = false; |
| 942 parse4("parseFunctionDeclarationStatement", |
| 943 "foo() async {}", [ParserErrorCode.ASYNC_NOT_SUPPORTED]); |
| 944 } |
| 945 |
| 946 void test_enableAsync_false_2() { |
| 947 parseAsync = false; |
| 948 parse4("parseFunctionDeclarationStatement", |
| 949 "foo() sync* {}", [ParserErrorCode.ASYNC_NOT_SUPPORTED]); |
| 950 } |
| 951 |
940 void test_emptyEnumBody() { | 952 void test_emptyEnumBody() { |
941 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], | 953 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], |
942 "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]); | 954 "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]); |
943 } | 955 } |
944 | 956 |
945 void test_enumInClass() { | 957 void test_enumInClass() { |
946 ParserTestCase.parseCompilationUnit( | 958 ParserTestCase.parseCompilationUnit( |
947 r''' | 959 r''' |
948 class Foo { | 960 class Foo { |
949 enum Bar { | 961 enum Bar { |
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2640 * An empty list of objects used as arguments to zero-argument methods. | 2652 * An empty list of objects used as arguments to zero-argument methods. |
2641 */ | 2653 */ |
2642 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; | 2654 static const List<Object> _EMPTY_ARGUMENTS = const <Object>[]; |
2643 | 2655 |
2644 /** | 2656 /** |
2645 * A flag indicating whether parser is to parse function bodies. | 2657 * A flag indicating whether parser is to parse function bodies. |
2646 */ | 2658 */ |
2647 static bool parseFunctionBodies = true; | 2659 static bool parseFunctionBodies = true; |
2648 | 2660 |
2649 /** | 2661 /** |
| 2662 * A flag indicating whether parser is to parse async. |
| 2663 */ |
| 2664 bool parseAsync = true; |
| 2665 |
| 2666 /** |
2650 * A flag indicating whether conditional directives support should be enabled | 2667 * A flag indicating whether conditional directives support should be enabled |
2651 * for a specific test. | 2668 * for a specific test. |
2652 */ | 2669 */ |
2653 bool enableConditionalDirectives = false; | 2670 bool enableConditionalDirectives = false; |
2654 | 2671 |
2655 /** | 2672 /** |
2656 * A flag indicating whether generic method support should be enabled for a | 2673 * A flag indicating whether generic method support should be enabled for a |
2657 * specific test. | 2674 * specific test. |
2658 */ | 2675 */ |
2659 bool enableGenericMethods = false; | 2676 bool enableGenericMethods = false; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2706 // | 2723 // |
2707 Scanner scanner = | 2724 Scanner scanner = |
2708 new Scanner(null, new CharSequenceReader(source), listener); | 2725 new Scanner(null, new CharSequenceReader(source), listener); |
2709 scanner.scanGenericMethodComments = enableGenericMethodComments; | 2726 scanner.scanGenericMethodComments = enableGenericMethodComments; |
2710 Token tokenStream = scanner.tokenize(); | 2727 Token tokenStream = scanner.tokenize(); |
2711 listener.setLineInfo(new TestSource(), scanner.lineStarts); | 2728 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
2712 // | 2729 // |
2713 // Parse the source. | 2730 // Parse the source. |
2714 // | 2731 // |
2715 Parser parser = createParser(listener); | 2732 Parser parser = createParser(listener); |
| 2733 parser.parseAsync = parseAsync; |
2716 parser.parseConditionalDirectives = enableConditionalDirectives; | 2734 parser.parseConditionalDirectives = enableConditionalDirectives; |
2717 parser.parseGenericMethods = enableGenericMethods; | 2735 parser.parseGenericMethods = enableGenericMethods; |
2718 parser.parseGenericMethodComments = enableGenericMethodComments; | 2736 parser.parseGenericMethodComments = enableGenericMethodComments; |
2719 parser.parseFunctionBodies = parseFunctionBodies; | 2737 parser.parseFunctionBodies = parseFunctionBodies; |
2720 Object result = | 2738 Object result = |
2721 invokeParserMethodImpl(parser, methodName, objects, tokenStream); | 2739 invokeParserMethodImpl(parser, methodName, objects, tokenStream); |
2722 // | 2740 // |
2723 // Partially test the results. | 2741 // Partially test the results. |
2724 // | 2742 // |
2725 if (!listener.hasErrors) { | 2743 if (!listener.hasErrors) { |
(...skipping 8644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11370 new Scanner(null, new CharSequenceReader(source), listener); | 11388 new Scanner(null, new CharSequenceReader(source), listener); |
11371 Token tokenStream = scanner.tokenize(); | 11389 Token tokenStream = scanner.tokenize(); |
11372 // | 11390 // |
11373 // Parse the source. | 11391 // Parse the source. |
11374 // | 11392 // |
11375 Parser parser = new Parser(null, listener); | 11393 Parser parser = new Parser(null, listener); |
11376 return invokeParserMethodImpl( | 11394 return invokeParserMethodImpl( |
11377 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 11395 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
11378 } | 11396 } |
11379 } | 11397 } |
OLD | NEW |