| Index: tests/language_strong/async_await_test.dart
|
| diff --git a/tests/language_strong/async_await_test.dart b/tests/language_strong/async_await_test.dart
|
| index e8884b37112bab38270570c49bf9041960213d99..e9dff731a6ced091a86bf2c82a5ae856f28d8743 100644
|
| --- a/tests/language_strong/async_await_test.dart
|
| +++ b/tests/language_strong/async_await_test.dart
|
| @@ -13,7 +13,10 @@ main() {
|
|
|
| group("basic", () {
|
| test("async w/o await", () {
|
| - f() async { return id(42); }
|
| + f() async {
|
| + return id(42);
|
| + }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -23,7 +26,9 @@ main() {
|
| f() async {
|
| result.add(1);
|
| return id(42);
|
| - };
|
| + }
|
| +
|
| + ;
|
| var future = f();
|
| result.add(0);
|
| return future.whenComplete(() {
|
| @@ -36,6 +41,7 @@ main() {
|
| throw "err";
|
| return id(42);
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -43,7 +49,9 @@ main() {
|
| f() async {
|
| var v = await new Future.value(42);
|
| return v;
|
| - };
|
| + }
|
| +
|
| + ;
|
| return expect42(f());
|
| });
|
|
|
| @@ -51,7 +59,9 @@ main() {
|
| f() async {
|
| var v = await id(42);
|
| return v;
|
| - };
|
| + }
|
| +
|
| + ;
|
| return expect42(f());
|
| });
|
|
|
| @@ -59,7 +69,9 @@ main() {
|
| f() async {
|
| var v = await null;
|
| expect(v, equals(null));
|
| - };
|
| + }
|
| +
|
| + ;
|
| return f();
|
| });
|
|
|
| @@ -67,6 +79,7 @@ main() {
|
| f() async {
|
| return await await new Future.value(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -74,6 +87,7 @@ main() {
|
| f() async {
|
| return await new FakeValueFuture(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -81,33 +95,39 @@ main() {
|
| f() async {
|
| return await new FakeErrorFuture("err");
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| test("await value is delayed", () {
|
| f() async {
|
| bool x = false;
|
| - scheduleMicrotask(() { x = true; });
|
| + scheduleMicrotask(() {
|
| + x = true;
|
| + });
|
| var y = await true;
|
| expect(x, equals(y));
|
| }
|
| +
|
| return f();
|
| });
|
|
|
| test("await throw", () {
|
| f() async {
|
| - await (throw "err"); // Check grammar: Are parentheses necessary?
|
| + await (throw "err"); // Check grammar: Are parentheses necessary?
|
| return id(42);
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| test("throw before await", () {
|
| f() async {
|
| var x = throw "err";
|
| - await x; // Check grammar: Are parentheses necessary?
|
| + await x; // Check grammar: Are parentheses necessary?
|
| return id(42);
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -117,6 +137,7 @@ main() {
|
| assert(v == 87);
|
| return await new Future.microtask(() => 42);
|
| }
|
| +
|
| return f(42).then((_) {
|
| fail("assert didn't throw");
|
| }, onError: (e, s) {
|
| @@ -130,6 +151,7 @@ main() {
|
| assert(v == 87);
|
| return x;
|
| }
|
| +
|
| return f(42).then((_) {
|
| fail("assert didn't throw");
|
| }, onError: (e, s) {
|
| @@ -143,22 +165,27 @@ main() {
|
| await new Future.error("err");
|
| return id(42);
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| test("async flattens futures", () {
|
| f() async {
|
| - return new Future.value(42); // Not awaited.
|
| - };
|
| + return new Future.value(42); // Not awaited.
|
| + }
|
| +
|
| + ;
|
| return f().then((v) {
|
| - expect(v, equals(42)); // And not a Future with value 42.
|
| + expect(v, equals(42)); // And not a Future with value 42.
|
| });
|
| });
|
|
|
| test("async flattens futures, error", () {
|
| f() async {
|
| - return new Future.error("err"); // Not awaited.
|
| - };
|
| + return new Future.error("err"); // Not awaited.
|
| + }
|
| +
|
| + ;
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -170,8 +197,9 @@ main() {
|
| }
|
| return i;
|
| }
|
| +
|
| return f(mkStream()).then((v) {
|
| - expect(v, equals(45)); // 0 + 1 + ... + 9
|
| + expect(v, equals(45)); // 0 + 1 + ... + 9
|
| });
|
| });
|
|
|
| @@ -183,8 +211,9 @@ main() {
|
| }
|
| return i;
|
| }
|
| +
|
| return f(mkStream()).then((v) {
|
| - expect(v, equals(45)); // 0 + 1 + ... + 9
|
| + expect(v, equals(45)); // 0 + 1 + ... + 9
|
| });
|
| });
|
|
|
| @@ -196,6 +225,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| var s = (new StreamController<int>()..close()).stream;
|
| return f(s).then((v) {
|
| expect(v, equals(0));
|
| @@ -212,6 +242,7 @@ main() {
|
| }
|
| return i;
|
| }
|
| +
|
| return f(mkStream()).then((v) {
|
| fail("assert didn't throw");
|
| }, onError: (e, s) {
|
| @@ -230,6 +261,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * id(42)));
|
| });
|
| @@ -243,6 +275,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * 5));
|
| });
|
| @@ -256,6 +289,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * 5));
|
| });
|
| @@ -269,6 +303,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * 3));
|
| });
|
| @@ -282,6 +317,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -293,6 +329,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -304,6 +341,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -315,6 +353,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -326,6 +365,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(0));
|
| });
|
| @@ -339,6 +379,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(0));
|
| });
|
| @@ -353,6 +394,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 2));
|
| });
|
| @@ -367,6 +409,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 2));
|
| });
|
| @@ -381,6 +424,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 9));
|
| });
|
| @@ -396,6 +440,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 9));
|
| });
|
| @@ -413,6 +458,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * id(42)));
|
| });
|
| @@ -428,6 +474,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * 5));
|
| });
|
| @@ -443,6 +490,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -456,6 +504,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return throwsErr(f());
|
| });
|
|
|
| @@ -470,6 +519,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 2));
|
| });
|
| @@ -486,6 +536,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 3));
|
| });
|
| @@ -502,6 +553,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 9));
|
| });
|
| @@ -519,6 +571,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 9));
|
| });
|
| @@ -536,6 +589,7 @@ main() {
|
| } while (i < 10);
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * id(42)));
|
| });
|
| @@ -551,6 +605,7 @@ main() {
|
| } while (i < await new Future.value(42));
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10 * 5));
|
| });
|
| @@ -566,8 +621,12 @@ main() {
|
| } while (i < 10);
|
| return v;
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("await err in test", () {
|
| @@ -580,8 +639,12 @@ main() {
|
| } while (i < await new Future.error("err"));
|
| return v;
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("break before await", () {
|
| @@ -595,6 +658,7 @@ main() {
|
| } while (i < 10);
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 2));
|
| });
|
| @@ -611,6 +675,7 @@ main() {
|
| } while (i < 10);
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 3));
|
| });
|
| @@ -627,6 +692,7 @@ main() {
|
| } while (i < 10);
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 9));
|
| });
|
| @@ -644,6 +710,7 @@ main() {
|
| } while (i < 10);
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42 * 9));
|
| });
|
| @@ -659,6 +726,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(6));
|
| });
|
| @@ -672,6 +740,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(6));
|
| });
|
| @@ -680,15 +749,18 @@ main() {
|
| test("await err in for-in", () {
|
| f() async {
|
| var v = 0;
|
| - for (var fut in [1, 2, 3].map((v) => (v != 1)
|
| - ? new Future.value(v)
|
| - : new Future.error("err"))) {
|
| + for (var fut in [1, 2, 3].map(
|
| + (v) => (v != 1) ? new Future.value(v) : new Future.error("err"))) {
|
| v += await fut;
|
| }
|
| return v;
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("await err in for-in iterable", () {
|
| @@ -699,8 +771,12 @@ main() {
|
| }
|
| return v;
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("break before await in for-in", () {
|
| @@ -712,6 +788,7 @@ main() {
|
| }
|
| return v;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(3));
|
| });
|
| @@ -723,10 +800,11 @@ main() {
|
| f() async {
|
| try {
|
| return await id(42);
|
| - } catch(e) {
|
| + } catch (e) {
|
| return 37;
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -734,10 +812,11 @@ main() {
|
| f() async {
|
| try {
|
| await new Future.error(42);
|
| - } catch(e) {
|
| + } catch (e) {
|
| return e;
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -747,10 +826,11 @@ main() {
|
| try {
|
| if (i >= 0) throw id(42);
|
| return await new Future.value(10);
|
| - } catch(e) {
|
| + } catch (e) {
|
| return e;
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -758,10 +838,11 @@ main() {
|
| f() async {
|
| try {
|
| throw id(42);
|
| - } catch(e) {
|
| + } catch (e) {
|
| return await new Future.value(e);
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -769,25 +850,33 @@ main() {
|
| f() async {
|
| try {
|
| throw id(42);
|
| - } catch(e) {
|
| + } catch (e) {
|
| await new Future.error("err");
|
| }
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("try-catch-rethrow", () {
|
| f() async {
|
| try {
|
| await new Future.error("err");
|
| - } catch(e) {
|
| + } catch (e) {
|
| if (e == id(42)) return;
|
| rethrow;
|
| }
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
| });
|
|
|
| @@ -800,6 +889,7 @@ main() {
|
| // Don't do anything.
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -812,6 +902,7 @@ main() {
|
| x = await new Future.value(37);
|
| }
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42));
|
| expect(x, equals(37));
|
| @@ -826,8 +917,12 @@ main() {
|
| // Don't do anything.
|
| }
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("await err in finally", () {
|
| @@ -838,8 +933,12 @@ main() {
|
| await new Future.error("err");
|
| }
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("await err in both", () {
|
| @@ -850,8 +949,12 @@ main() {
|
| await new Future.error("err");
|
| }
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| });
|
|
|
| test("await err in body, override in finally", () {
|
| @@ -862,25 +965,29 @@ main() {
|
| return id(42);
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| test("await in body, override in finally", () {
|
| f() async {
|
| - label: try {
|
| + label:
|
| + try {
|
| return await new Future.value(37);
|
| } finally {
|
| break label;
|
| }
|
| return id(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| test("await, override in finally", () {
|
| var x = 0;
|
| f() async {
|
| - label: try {
|
| + label:
|
| + try {
|
| return 87;
|
| } finally {
|
| x = await new Future.value(37);
|
| @@ -888,6 +995,7 @@ main() {
|
| }
|
| return id(42);
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42));
|
| expect(x, equals(37));
|
| @@ -897,7 +1005,8 @@ main() {
|
| test("throw in body, await, override in finally 3", () {
|
| var x = 0;
|
| f() async {
|
| - label: try {
|
| + label:
|
| + try {
|
| throw "err";
|
| } finally {
|
| x = await new Future.value(37);
|
| @@ -905,6 +1014,7 @@ main() {
|
| }
|
| return id(42);
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42));
|
| expect(x, equals(37));
|
| @@ -913,13 +1023,15 @@ main() {
|
|
|
| test("await err in body, override in finally 2", () {
|
| f() async {
|
| - label: try {
|
| + label:
|
| + try {
|
| return await new Future.error("err");
|
| } finally {
|
| break label;
|
| }
|
| return id(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -934,6 +1046,7 @@ main() {
|
| }
|
| return id(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -950,6 +1063,7 @@ main() {
|
| }
|
| return id(i);
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(10));
|
| });
|
| @@ -968,6 +1082,7 @@ main() {
|
| }
|
| return id(i);
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(0));
|
| });
|
| @@ -985,6 +1100,7 @@ main() {
|
| }
|
| return id(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1000,6 +1116,7 @@ main() {
|
| }
|
| return id(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1016,6 +1133,7 @@ main() {
|
| x += await new Future.value(37);
|
| }
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42));
|
| expect(x, equals(74));
|
| @@ -1025,7 +1143,8 @@ main() {
|
| test("nested finallies 2", () {
|
| var x = 0;
|
| f() async {
|
| - label: try {
|
| + label:
|
| + try {
|
| try {
|
| break label;
|
| } finally {
|
| @@ -1036,6 +1155,7 @@ main() {
|
| }
|
| return 42;
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42));
|
| expect(x, equals(74));
|
| @@ -1045,7 +1165,8 @@ main() {
|
| test("nested finallies 3", () {
|
| var x = 0;
|
| f() async {
|
| - label: try {
|
| + label:
|
| + try {
|
| try {
|
| break label;
|
| } finally {
|
| @@ -1056,6 +1177,7 @@ main() {
|
| }
|
| return 42;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1072,11 +1194,13 @@ main() {
|
| x += await new Future.value(37);
|
| }
|
| }
|
| - return f().then((v) { fail("didn't throw"); },
|
| - onError: (e) {
|
| - expect(e, equals("err"));
|
| - expect(x, equals(2 * 37));
|
| - });
|
| +
|
| + return f().then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + expect(x, equals(2 * 37));
|
| + });
|
| });
|
| });
|
|
|
| @@ -1091,6 +1215,7 @@ main() {
|
| if (id(42) == id(10)) return 10;
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1104,6 +1229,7 @@ main() {
|
| if (id(42) == id(10)) return 10;
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1117,6 +1243,7 @@ main() {
|
| if (id(42) == id(10)) return 10;
|
| }
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1132,6 +1259,7 @@ main() {
|
| if (id(42) == id(10)) return 10;
|
| }
|
| }
|
| +
|
| return f().then((v) {
|
| expect(v, equals(42));
|
| expect(x, equals(37));
|
| @@ -1143,48 +1271,64 @@ main() {
|
| test("await in expression", () {
|
| f(v) async {
|
| switch (await new Future.value(v)) {
|
| - case 1: return 1;
|
| - case 2: return 42;
|
| - default: return 3;
|
| + case 1:
|
| + return 1;
|
| + case 2:
|
| + return 42;
|
| + default:
|
| + return 3;
|
| }
|
| return null;
|
| }
|
| +
|
| return expect42(f(2));
|
| });
|
|
|
| test("await err in expression", () {
|
| f(v) async {
|
| switch (await new Future.error("err")) {
|
| - case 1: return 1;
|
| - case 2: return 42;
|
| - default: return 3;
|
| + case 1:
|
| + return 1;
|
| + case 2:
|
| + return 42;
|
| + default:
|
| + return 3;
|
| }
|
| return null;
|
| }
|
| +
|
| return throwsErr(f(2));
|
| });
|
|
|
| test("await in case", () {
|
| f(v) async {
|
| switch (v) {
|
| - case 1: return 1;
|
| - case 2: return await new Future.value(42);
|
| - default: return 3;
|
| + case 1:
|
| + return 1;
|
| + case 2:
|
| + return await new Future.value(42);
|
| + default:
|
| + return 3;
|
| }
|
| return null;
|
| }
|
| +
|
| return expect42(f(2));
|
| });
|
|
|
| test("await err in case", () {
|
| f(v) async {
|
| switch (v) {
|
| - case 1: return 1;
|
| - case 2: return await new Future.error("err");
|
| - default: return 3;
|
| + case 1:
|
| + return 1;
|
| + case 2:
|
| + return await new Future.error("err");
|
| + default:
|
| + return 3;
|
| }
|
| return null;
|
| }
|
| +
|
| return throwsErr(f(2));
|
| });
|
| // TODO(jmesserly): restore this when we fix
|
| @@ -1229,6 +1373,7 @@ main() {
|
| return 37;
|
| }
|
| }
|
| +
|
| return expect42(f(true));
|
| });
|
|
|
| @@ -1240,6 +1385,7 @@ main() {
|
| return 37;
|
| }
|
| }
|
| +
|
| return throwsErr(f(true));
|
| });
|
|
|
| @@ -1250,6 +1396,7 @@ main() {
|
| }
|
| return 37;
|
| }
|
| +
|
| return expect42(f(true));
|
| });
|
|
|
| @@ -1260,6 +1407,7 @@ main() {
|
| }
|
| return 37;
|
| }
|
| +
|
| return throwsErr(f(true));
|
| });
|
|
|
| @@ -1272,6 +1420,7 @@ main() {
|
| }
|
| return 37;
|
| }
|
| +
|
| return expect42(f(true));
|
| });
|
|
|
| @@ -1284,6 +1433,7 @@ main() {
|
| }
|
| return 37;
|
| }
|
| +
|
| return throwsErr(f(true));
|
| });
|
|
|
| @@ -1296,6 +1446,7 @@ main() {
|
| }
|
| return 87;
|
| }
|
| +
|
| return expect42(f(false));
|
| });
|
|
|
| @@ -1308,6 +1459,7 @@ main() {
|
| }
|
| return 87;
|
| }
|
| +
|
| return throwsErr(f(false));
|
| });
|
|
|
| @@ -1322,6 +1474,7 @@ main() {
|
| }
|
| return 87;
|
| }
|
| +
|
| return expect42(f(false));
|
| });
|
|
|
| @@ -1336,6 +1489,7 @@ main() {
|
| }
|
| return 87;
|
| }
|
| +
|
| return expect42(f(false));
|
| });
|
| });
|
| @@ -1345,6 +1499,7 @@ main() {
|
| f(v) async {
|
| return (await new Future.value(v)) ? 42 : 37;
|
| }
|
| +
|
| return expect42(f(true));
|
| });
|
|
|
| @@ -1352,6 +1507,7 @@ main() {
|
| f(v) async {
|
| return (await new Future.error("err")) ? 42 : 37;
|
| }
|
| +
|
| return throwsErr(f(true));
|
| });
|
|
|
| @@ -1359,6 +1515,7 @@ main() {
|
| f(v) async {
|
| return v ? (await new Future.value(42)) : 37;
|
| }
|
| +
|
| return expect42(f(true));
|
| });
|
|
|
| @@ -1366,6 +1523,7 @@ main() {
|
| f(v) async {
|
| return v ? (await new Future.error("err")) : 37;
|
| }
|
| +
|
| return throwsErr(f(true));
|
| });
|
|
|
| @@ -1373,6 +1531,7 @@ main() {
|
| f(v) async {
|
| return v ? 37 : (await new Future.value(42));
|
| }
|
| +
|
| return expect42(f(false));
|
| });
|
|
|
| @@ -1380,6 +1539,7 @@ main() {
|
| f(v) async {
|
| return v ? 37 : (await new Future.error("err"));
|
| }
|
| +
|
| return throwsErr(f(false));
|
| });
|
| });
|
| @@ -1553,6 +1713,7 @@ main() {
|
| f() async {
|
| return await l42;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1560,6 +1721,7 @@ main() {
|
| f(p) async {
|
| return await p;
|
| }
|
| +
|
| return expect42(f(42));
|
| });
|
|
|
| @@ -1567,6 +1729,7 @@ main() {
|
| f() async {
|
| return await v42;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1574,6 +1737,7 @@ main() {
|
| f() async {
|
| return await c42;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1581,6 +1745,7 @@ main() {
|
| f() async {
|
| return -await -42;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1589,6 +1754,7 @@ main() {
|
| var v = [42];
|
| return await v[0];
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1597,6 +1763,7 @@ main() {
|
| var x = 42;
|
| return await x++;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1605,6 +1772,7 @@ main() {
|
| var v = [42];
|
| return await v[0]++;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1613,6 +1781,7 @@ main() {
|
| var v = [42];
|
| return await v[await 0]++;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1621,6 +1790,7 @@ main() {
|
| var x = 41;
|
| return await ++x;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1630,6 +1800,7 @@ main() {
|
| var v = [41];
|
| return await ++v[0];
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1638,6 +1809,7 @@ main() {
|
| var x = 37;
|
| return await (x = 42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1646,6 +1818,7 @@ main() {
|
| var x = 37;
|
| return await (x += 5);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1653,6 +1826,7 @@ main() {
|
| f() async {
|
| return await (10 + 11) + await (10 + 11);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1660,6 +1834,7 @@ main() {
|
| f(v) async {
|
| return await ((v == 10) ? new Future.value(42) : 37);
|
| }
|
| +
|
| return expect42(f(10));
|
| });
|
|
|
| @@ -1667,6 +1842,7 @@ main() {
|
| f() async {
|
| return await topMethod(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1674,6 +1850,7 @@ main() {
|
| f() async {
|
| return await Async.staticMethod(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1682,6 +1859,7 @@ main() {
|
| var a = new Async();
|
| return await a.instanceMethod(42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1689,6 +1867,7 @@ main() {
|
| f() async {
|
| return await topMethod(await 42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1696,6 +1875,7 @@ main() {
|
| f() async {
|
| return await Async.staticMethod(await 42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1704,6 +1884,7 @@ main() {
|
| var a = new Async();
|
| return await a.instanceMethod(await 42);
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1711,6 +1892,7 @@ main() {
|
| f() async {
|
| return await topGetter;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1718,6 +1900,7 @@ main() {
|
| f() async {
|
| return await Async.staticGetter;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1726,6 +1909,7 @@ main() {
|
| var a = new Async();
|
| return await a.instanceGetter;
|
| }
|
| +
|
| return expect42(f());
|
| });
|
|
|
| @@ -1762,7 +1946,6 @@ main() {
|
| expect(e is AssertionError, isTrue); // //# 03: continued
|
| }); // //# 03: continued
|
| }); // //# 03: continued
|
| -
|
| });
|
|
|
| group("syntax", () {
|
| @@ -1786,7 +1969,6 @@ main() {
|
| });
|
| }
|
|
|
| -
|
| // Attempt to obfuscates value to avoid too much constant folding.
|
| id(v) {
|
| try {
|
| @@ -1809,6 +1991,7 @@ Stream<int> mkStream() {
|
| scheduleMicrotask(next);
|
| }
|
| }
|
| +
|
| c = new StreamController(onListen: () {
|
| scheduleMicrotask(next);
|
| });
|
| @@ -1817,8 +2000,11 @@ Stream<int> mkStream() {
|
|
|
| // Check that future contains the error "err".
|
| Future throwsErr(Future future) {
|
| - return future.then((v) { fail("didn't throw"); },
|
| - onError: (e) { expect(e, equals("err")); });
|
| + return future.then((v) {
|
| + fail("didn't throw");
|
| + }, onError: (e) {
|
| + expect(e, equals("err"));
|
| + });
|
| }
|
|
|
| // Check that future contains the value 42.
|
| @@ -1828,10 +2014,11 @@ Future expect42(Future future) {
|
| });
|
| }
|
|
|
| -
|
| // Various async declarations.
|
|
|
| -Future topMethod(f) async { return await f; }
|
| +Future topMethod(f) async {
|
| + return await f;
|
| +}
|
|
|
| Future topArrowMethod(f) async => await f;
|
|
|
| @@ -1842,7 +2029,10 @@ Future get topGetter async {
|
| Future get topArrowGetter async => await new Future.value(42);
|
|
|
| Future topLocal(f) {
|
| - local() async { return await f; }
|
| + local() async {
|
| + return await f;
|
| + }
|
| +
|
| return local();
|
| }
|
|
|
| @@ -1852,14 +2042,18 @@ Future topArrowLocal(f) {
|
| }
|
|
|
| Future topExpression(f) {
|
| - return () async { return await f; } ();
|
| + return () async {
|
| + return await f;
|
| + }();
|
| }
|
|
|
| Future topArrowExpression(f) {
|
| - return (() async => await f) ();
|
| + return (() async => await f)();
|
| }
|
|
|
| -var topVarExpression = (f) async { return await f; };
|
| +var topVarExpression = (f) async {
|
| + return await f;
|
| +};
|
|
|
| var topVarArrowExpression = (f) async => await f;
|
|
|
| @@ -1867,12 +2061,17 @@ class Async {
|
| var initValue;
|
| Async();
|
|
|
| - Async.initializer(f) : initValue = (() async { return await f; } ());
|
| + Async.initializer(f)
|
| + : initValue = (() async {
|
| + return await f;
|
| + }());
|
|
|
| - Async.initializerArrow(f) : initValue = ((() async => await f) ());
|
| + Async.initializerArrow(f) : initValue = ((() async => await f)());
|
|
|
| /* static */
|
| - static Future staticMethod(f) async { return await f; }
|
| + static Future staticMethod(f) async {
|
| + return await f;
|
| + }
|
|
|
| static Future staticArrowMethod(f) async => await f;
|
|
|
| @@ -1883,7 +2082,10 @@ class Async {
|
| static Future get staticArrowGetter async => await new Future.value(42);
|
|
|
| static Future staticLocal(f) {
|
| - local() async { return await f; }
|
| + local() async {
|
| + return await f;
|
| + }
|
| +
|
| return local();
|
| }
|
|
|
| @@ -1893,19 +2095,25 @@ class Async {
|
| }
|
|
|
| static Future staticExpression(f) {
|
| - return () async { return await f; } ();
|
| + return () async {
|
| + return await f;
|
| + }();
|
| }
|
|
|
| static Future staticArrowExpression(f) {
|
| - return (() async => await f) ();
|
| + return (() async => await f)();
|
| }
|
|
|
| - static var staticVarExpression = (f) async { return await f; };
|
| + static var staticVarExpression = (f) async {
|
| + return await f;
|
| + };
|
|
|
| static var staticVarArrowExpression = (f) async => await f;
|
|
|
| /* instance */
|
| - Future instanceMethod(f) async { return await f; }
|
| + Future instanceMethod(f) async {
|
| + return await f;
|
| + }
|
|
|
| Future instanceArrowMethod(f) async => await f;
|
|
|
| @@ -1916,7 +2124,10 @@ class Async {
|
| Future get instanceArrowGetter async => await new Future.value(42);
|
|
|
| Future instanceLocal(f) {
|
| - local() async { return await f; }
|
| + local() async {
|
| + return await f;
|
| + }
|
| +
|
| return local();
|
| }
|
|
|
| @@ -1926,14 +2137,18 @@ class Async {
|
| }
|
|
|
| Future instanceExpression(f) {
|
| - return () async { return await f; } ();
|
| + return () async {
|
| + return await f;
|
| + }();
|
| }
|
|
|
| Future instanceArrowExpression(f) {
|
| - return (() async => await f) ();
|
| + return (() async => await f)();
|
| }
|
|
|
| - var instanceVarExpression = (f) async { return await f; };
|
| + var instanceVarExpression = (f) async {
|
| + return await f;
|
| + };
|
|
|
| var instanceVarArrowExpression = (f) async => await f;
|
| }
|
| @@ -1942,6 +2157,7 @@ Future asyncInAsync(f) async {
|
| inner(f) async {
|
| return await f;
|
| }
|
| +
|
| return await inner(f);
|
| }
|
|
|
| @@ -1949,6 +2165,7 @@ Future asyncInSync(f) {
|
| inner(f) async {
|
| return await f;
|
| }
|
| +
|
| return inner(f);
|
| }
|
|
|
| @@ -1956,6 +2173,7 @@ Future syncInAsync(f) async {
|
| inner(f) {
|
| return f;
|
| }
|
| +
|
| return await inner(f);
|
| }
|
|
|
| @@ -1966,13 +2184,20 @@ class FakeValueFuture implements Future {
|
| final _value;
|
| FakeValueFuture(this._value);
|
| Future/*<S>*/ then/*<S>*/(callback(value), {Function onError}) {
|
| - return new Future/*<S>*/.microtask(() => callback(_value));
|
| + return new Future/*<S>*/ .microtask(() => callback(_value));
|
| }
|
| +
|
| Future whenComplete(callback()) {
|
| - return new Future.microtask(() { callback(); });
|
| + return new Future.microtask(() {
|
| + callback();
|
| + });
|
| }
|
| +
|
| Future catchError(Function onError, {bool test(error)}) => this;
|
| - Stream asStream() => (new StreamController()..add(_value)..close()).stream;
|
| + Stream asStream() => (new StreamController()
|
| + ..add(_value)
|
| + ..close())
|
| + .stream;
|
| Future timeout(Duration duration, {onTimeout()}) => this;
|
| }
|
|
|
| @@ -1987,15 +2212,19 @@ class FakeErrorFuture implements Future {
|
| Future/*<S>*/ then/*<S>*/(callback(value), {Function onError}) {
|
| if (onError != null) {
|
| if (onError is BinaryFunction) {
|
| - return new Future/*<S>*/.microtask(() => onError(_error, null));
|
| + return new Future/*<S>*/ .microtask(() => onError(_error, null));
|
| }
|
| - return new Future/*<S>*/.microtask(() => onError(_error));
|
| + return new Future/*<S>*/ .microtask(() => onError(_error));
|
| }
|
| - return new Future/*<S>*/.error(_error);
|
| + return new Future/*<S>*/ .error(_error);
|
| }
|
| +
|
| Future whenComplete(callback()) {
|
| - return new Future.microtask(() { callback(); }).then((_) => this);
|
| + return new Future.microtask(() {
|
| + callback();
|
| + }).then((_) => this);
|
| }
|
| +
|
| Future catchError(Function onError, {bool test(error)}) {
|
| return new Future.microtask(() {
|
| if (test != null && !test(_error)) return this;
|
| @@ -2005,7 +2234,10 @@ class FakeErrorFuture implements Future {
|
| return onError(_error);
|
| });
|
| }
|
| - Stream asStream() =>
|
| - (new StreamController()..addError(_error)..close()).stream;
|
| +
|
| + Stream asStream() => (new StreamController()
|
| + ..addError(_error)
|
| + ..close())
|
| + .stream;
|
| Future timeout(Duration duration, {onTimeout()}) => this;
|
| }
|
|
|