Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(864)

Side by Side Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 1584823003: assert isAsynchronous and isGenerator false if parseAsync is false (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() { 940 void test_enableAsync_false_1() {
941 parseAsync = false; 941 parseAsync = false;
942 parse4("parseFunctionDeclarationStatement", 942 FunctionDeclarationStatement stmt = parse4(
943 "foo() async {}", [ParserErrorCode.ASYNC_NOT_SUPPORTED]); 943 "parseFunctionDeclarationStatement",
944 "foo() async {}",
945 [ParserErrorCode.ASYNC_NOT_SUPPORTED]);
946 FunctionExpression expr = stmt.functionDeclaration.functionExpression;
947 expect(expr.body.isAsynchronous, isFalse);
948 expect(expr.body.isGenerator, isFalse);
944 } 949 }
945 950
946 void test_enableAsync_false_2() { 951 void test_enableAsync_false_2() {
947 parseAsync = false; 952 parseAsync = false;
948 parse4("parseFunctionDeclarationStatement", 953 FunctionDeclarationStatement stmt = parse4(
949 "foo() sync* {}", [ParserErrorCode.ASYNC_NOT_SUPPORTED]); 954 "parseFunctionDeclarationStatement",
955 "foo() async => 0;",
956 [ParserErrorCode.ASYNC_NOT_SUPPORTED]);
957 FunctionExpression expr = stmt.functionDeclaration.functionExpression;
958 expect(expr.body.isAsynchronous, isFalse);
959 expect(expr.body.isGenerator, isFalse);
960 }
961
962 void test_enableAsync_false_3() {
963 parseAsync = false;
964 FunctionDeclarationStatement stmt = parse4(
965 "parseFunctionDeclarationStatement",
966 "foo() sync* {}",
967 [ParserErrorCode.ASYNC_NOT_SUPPORTED]);
968 FunctionExpression expr = stmt.functionDeclaration.functionExpression;
969 expect(expr.body.isAsynchronous, isFalse);
970 expect(expr.body.isGenerator, isFalse);
950 } 971 }
951 972
952 void test_emptyEnumBody() { 973 void test_emptyEnumBody() {
953 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()], 974 parse3("parseEnumDeclaration", <Object>[emptyCommentAndMetadata()],
954 "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]); 975 "enum E {}", [ParserErrorCode.EMPTY_ENUM_BODY]);
955 } 976 }
956 977
957 void test_enumInClass() { 978 void test_enumInClass() {
958 ParserTestCase.parseCompilationUnit( 979 ParserTestCase.parseCompilationUnit(
959 r''' 980 r'''
(...skipping 10428 matching lines...) Expand 10 before | Expand all | Expand 10 after
11388 new Scanner(null, new CharSequenceReader(source), listener); 11409 new Scanner(null, new CharSequenceReader(source), listener);
11389 Token tokenStream = scanner.tokenize(); 11410 Token tokenStream = scanner.tokenize();
11390 // 11411 //
11391 // Parse the source. 11412 // Parse the source.
11392 // 11413 //
11393 Parser parser = new Parser(null, listener); 11414 Parser parser = new Parser(null, listener);
11394 return invokeParserMethodImpl( 11415 return invokeParserMethodImpl(
11395 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 11416 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
11396 } 11417 }
11397 } 11418 }
OLDNEW
« pkg/analyzer/lib/src/generated/parser.dart ('K') | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698