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

Unified Diff: tests/compiler/dart2js/resolver_test.dart

Issue 1094903002: Better hints for await in non-async functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/warnings.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/resolver_test.dart
diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart
index d64cacfc1b6b0b02380fb8c8cce6f740bb3b7b13..ceca9de76425ede4ba3740dd5026cf6119570194 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -90,6 +90,7 @@ main() {
testConstConstructorAndNonFinalFields,
testCantAssignMethods,
testCantAssignFinalAndConsts,
+ testAwaitHint,
], (f) => f()));
}
@@ -1288,7 +1289,6 @@ testCantAssignFinalAndConsts() {
''', []);
}
-
/// Helper to test that [script] produces all the given [warnings].
checkWarningOn(String script, List<MessageKind> warnings) {
Expect.isTrue(warnings.length >= 0 && warnings.length <= 2);
@@ -1300,3 +1300,41 @@ checkWarningOn(String script, List<MessageKind> warnings) {
}
}));
}
+
+testAwaitHint() {
+ check(String script, {String className, String functionName}) {
+ var prefix = className == null
+ ? "Cannot resolve 'await'"
+ : "No member named 'await' in class '$className'";
+ var where = functionName == null
+ ? 'the enclosing function' : "'$functionName'";
+ asyncTest(() => compileScript(script).then((compiler) {
+ Expect.equals(0, compiler.errors.length);
+ Expect.equals(1, compiler.warnings.length);
+ Expect.equals("$prefix.\n"
+ "Did you mean to add the 'async' marker to $where?",
+ '${compiler.warnings[0].message}');
+ }));
+ }
+ check('main() { await -3; }', functionName: 'main');
+ check('main() { () => await -3; }');
+ check('foo() => await -3; main() => foo();', functionName: 'foo');
+ check('''
+ class A {
+ m() => await - 3;
+ }
+ main() => new A().m();
+ ''', className: 'A', functionName: 'm');
+ check('''
+ class A {
+ static m() => await - 3;
+ }
+ main() => A.m();
+ ''', functionName: 'm');
+ check('''
+ class A {
+ m() => () => await - 3;
+ }
+ main() => new A().m();
+ ''', className: 'A');
+}
« no previous file with comments | « pkg/compiler/lib/src/warnings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698