Skip to content

Commit

Permalink
Convert one more set of tests
Browse files Browse the repository at this point in the history
Change-Id: I4854985bd475d95c17be83e648bf5716d6156fbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98020
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
bwilkerson authored and commit-bot@chromium.org committed Mar 27, 2019
1 parent a9ee080 commit 4555cf7
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 328 deletions.
328 changes: 0 additions & 328 deletions pkg/analyzer/test/generated/compile_time_error_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,301 +96,6 @@ main() {
verify([source]);
}

test_async_used_as_identifier_in_annotation() async {
Source source = addSource('''
const int async = 0;
f() async {
g(@async x) {}
g(0);
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_argument_label() async {
Source source = addSource('''
f(c) async {
c.g(async: 0);
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_async_method() async {
Source source = addSource('''
f() async {
var async = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_async_star_method() async {
Source source = addSource('''
f() async* {
var async = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_break_statement() async {
Source source = addSource('''
f() async {
while (true) {
break async;
}
}
''');
await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
CompileTimeErrorCode.LABEL_UNDEFINED
]);
// Note: we don't call verify([source]) because the reference to the
// "async" label is unresolved.
}

test_async_used_as_identifier_in_cascaded_invocation() async {
Source source = addSource('''
class C {
int async() => 1;
}
f() async {
return new C()..async();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_cascaded_setter_invocation() async {
Source source = addSource('''
class C {
void set async(int i) {}
}
f() async {
return new C()..async = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_catch_exception_argument() async {
Source source = addSource('''
g() {}
f() async {
try {
g();
} catch (async) { }
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_catch_stacktrace_argument() async {
Source source = addSource('''
g() {}
f() async {
try {
g();
} catch (e, async) { }
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_continue_statement() async {
Source source = addSource('''
f() async {
while (true) {
continue async;
}
}
''');
await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
CompileTimeErrorCode.LABEL_UNDEFINED
]);
// Note: we don't call verify([source]) because the reference to the
// "async" label is unresolved.
}

test_async_used_as_identifier_in_for_statement() async {
Source source = addSource('''
var async;
f() async {
for (async in []) {}
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_formal_parameter_name() async {
Source source = addSource('''
f() async {
g(int async) {}
g(0);
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_getter_name() async {
Source source = addSource('''
class C {
int get async => 1;
}
f() async {
return new C().async;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_invocation() async {
Source source = addSource('''
class C {
int async() => 1;
}
f() async {
return new C().async();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_local_function_name() async {
Source source = addSource('''
f() async {
int async() => null;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_prefix() async {
Source source = addSource('''
import 'dart:async' as async;
f() async {
return new async.Future.value(0);
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_setter_name() async {
Source source = addSource('''
class C {
void set async(int i) {}
}
f() async {
new C().async = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_statement_label() async {
Source source = addSource('''
f() async {
async: g();
}
g() {}
''');
await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
HintCode.UNUSED_LABEL
]);
verify([source]);
}

test_async_used_as_identifier_in_string_interpolation() async {
Source source = addSource(r'''
int async = 1;
f() async {
return "$async";
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_suffix() async {
addNamedSource("/lib1.dart", r'''
library lib1;
int async;
''');
Source source = addSource('''
import 'lib1.dart' as l;
f() async {
return l.async;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_async_used_as_identifier_in_switch_label() async {
Source source = addSource('''
f() async {
switch (0) {
async: case 0: break;
}
}
''');
await computeAnalysisResult(source);
assertErrors(source, [
ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
HintCode.UNUSED_LABEL
]);
verify([source]);
}

test_async_used_as_identifier_in_sync_star_method() async {
Source source = addSource('''
f() sync* {
var async = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_asyncForInWrongContext() async {
Source source = addSource(r'''
f(list) {
Expand All @@ -402,39 +107,6 @@ f(list) {
verify([source]);
}

test_await_used_as_identifier_in_async_method() async {
Source source = addSource('''
f() async {
var await = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_await_used_as_identifier_in_async_star_method() async {
Source source = addSource('''
f() async* {
var await = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_await_used_as_identifier_in_sync_star_method() async {
Source source = addSource('''
f() sync* {
var await = 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER]);
verify([source]);
}

test_awaitInWrongContext_sync() async {
// This test requires better error recovery than we currently have. In
// particular, we need to be able to distinguish between an await expression
Expand Down
Loading

0 comments on commit 4555cf7

Please sign in to comment.