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

Unified Diff: tests/language/await_backwards_compatibility_test.dart

Issue 507233002: Fix conditionally parsing await as keyword. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix typo Created 6 years, 4 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 | « runtime/vm/symbols.h ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/await_backwards_compatibility_test.dart
diff --git a/tests/language/await_backwards_compatibility_test.dart b/tests/language/await_backwards_compatibility_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5b25b17a892deeda6bd33d49d32474ba3a9c0a91
--- /dev/null
+++ b/tests/language/await_backwards_compatibility_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// VMOptions=--enable_async
+
+import 'dart:async';
+
+import 'package:expect/expect.dart';
+
+get await => 4;
+
+// For functions that are declared with the async modifier we treat await as
+// keyword.
+
+test0() async {
+ var x = await 7;
+ Expect.equals(7, x);
+ var await = 1; /// await1: compile-time error
+}
+
+test1() async {
+ var x = await 9;
+ Expect.equals(9, x);
+ var y = await; /// await2: compile-time error
+}
+
+// For functions that are not declared with the async modifier we allow await to
+// be used as an identifier.
+
+test2() {
+ var y = await;
+ Expect.equals(4, y);
+ var x = await 1; /// await3: compile-time error
+}
+
+test3() {
+ var await = 3;
+ Expect.equals(3, await);
+ var x = await 1; /// await4: compile-time error
+}
+
+main() {
+ test0();
+ test1();
+ test2();
+ test3();
+}
« no previous file with comments | « runtime/vm/symbols.h ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698