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

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

Issue 881403002: Fix for issue 22052 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
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 engine.compile_time_error_code_test; 5 library engine.compile_time_error_code_test;
6 6
7 import 'package:analyzer/src/generated/error.dart'; 7 import 'package:analyzer/src/generated/error.dart';
8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:unittest/unittest.dart' as _ut; 10 import 'package:unittest/unittest.dart' as _ut;
11 11
12 import '../reflective_tests.dart'; 12 import '../reflective_tests.dart';
13 import 'resolver_test.dart'; 13 import 'resolver_test.dart';
14 14
15 15
16 main() { 16 main() {
17 _ut.groupSep = ' | '; 17 _ut.groupSep = ' | ';
18 runReflectiveTests(CompileTimeErrorCodeTest); 18 runReflectiveTests(CompileTimeErrorCodeTest);
19 } 19 }
20 20
21 @reflectiveTest 21 @reflectiveTest
22 class CompileTimeErrorCodeTest extends ResolverTestCase { 22 class CompileTimeErrorCodeTest extends ResolverTestCase {
23 void fail_awaitInWrongContext_sync() {
24 // This test requires better error recovery than we currently have. In
25 // particular, we need to be able to distinguish between an await expression
26 // in the wrong context, and the use of 'await' as an identifier.
27 Source source = addSource(r'''
28 f(x) {
29 return await x;
30 }''');
31 resolve(source);
32 assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
33 verify([source]);
34 }
35
36 void fail_awaitInWrongContext_syncStar() {
37 // This test requires better error recovery than we currently have. In
38 // particular, we need to be able to distinguish between an await expression
39 // in the wrong context, and the use of 'await' as an identifier.
40 Source source = addSource(r'''
41 f(x) sync* {
42 yield await x;
43 }''');
44 resolve(source);
45 assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
46 verify([source]);
47 }
48
23 void fail_compileTimeConstantRaisesException() { 49 void fail_compileTimeConstantRaisesException() {
24 Source source = addSource(r''' 50 Source source = addSource(r'''
25 '''); 51 ''');
26 resolve(source); 52 resolve(source);
27 assertErrors( 53 assertErrors(
28 source, 54 source,
29 [CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]); 55 [CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]);
30 verify([source]); 56 verify([source]);
31 } 57 }
32 58
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 Source source = addSource(r''' 250 Source source = addSource(r'''
225 f(list) { 251 f(list) {
226 await for (var e in list) { 252 await for (var e in list) {
227 } 253 }
228 }'''); 254 }''');
229 resolve(source); 255 resolve(source);
230 assertErrors(source, [CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT]); 256 assertErrors(source, [CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT]);
231 verify([source]); 257 verify([source]);
232 } 258 }
233 259
234 void test_awaitInWrongContext_sync() {
235 Source source = addSource(r'''
236 f(x) {
237 return await x;
238 }''');
239 resolve(source);
240 assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
241 verify([source]);
242 }
243
244 void test_awaitInWrongContext_syncStar() {
245 Source source = addSource(r'''
246 f(x) sync* {
247 yield await x;
248 }''');
249 resolve(source);
250 assertErrors(source, [CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT]);
251 verify([source]);
252 }
253
254 void test_builtInIdentifierAsMixinName_classTypeAlias() { 260 void test_builtInIdentifierAsMixinName_classTypeAlias() {
255 Source source = addSource(r''' 261 Source source = addSource(r'''
256 class A {} 262 class A {}
257 class B {} 263 class B {}
258 class as = A with B;'''); 264 class as = A with B;''');
259 resolve(source); 265 resolve(source);
260 assertErrors( 266 assertErrors(
261 source, 267 source,
262 [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]); 268 [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
263 verify([source]); 269 verify([source]);
(...skipping 5150 matching lines...) Expand 10 before | Expand all | Expand 10 after
5414 [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 5420 [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
5415 verify([source]); 5421 verify([source]);
5416 reset(); 5422 reset();
5417 } 5423 }
5418 5424
5419 void _check_wrongNumberOfParametersForOperator1(String name) { 5425 void _check_wrongNumberOfParametersForOperator1(String name) {
5420 _check_wrongNumberOfParametersForOperator(name, ""); 5426 _check_wrongNumberOfParametersForOperator(name, "");
5421 _check_wrongNumberOfParametersForOperator(name, "a, b"); 5427 _check_wrongNumberOfParametersForOperator(name, "a, b");
5422 } 5428 }
5423 } 5429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698