dart-sdk/tests/language/regress_22777_test.dart
hausner@google.com ada21bfda6 Fix do-while with await in condition
The await “preamble” code must be part of the expression,
not part of the body.

Fixes issue 22777

R=srdjan@google.com

Review URL: https://codereview.chromium.org//1012933002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44520 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-16 19:57:28 +00:00

43 lines
764 B
Dart

// Copyright (c) 2015, 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.
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
var a = 0;
testSync () {
do {
continue;
} while (throw "Error");
a = 100;
}
testAsync() async {
do {
continue;
} while (await (throw "Error"));
a = 100;
}
test() async {
try {
testSync();
} catch (e) {
Expect.equals(e, "Error");
}
Expect.equals(a, 0);
try {
await testAsync();
} catch (e) {
Expect.equals(e, "Error");
}
Expect.equals(a, 0);
}
main() {
asyncStart();
test().then((_) => asyncEnd());
}