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

Unified Diff: tests/language/async_and_or_test.dart

Issue 996103002: Fix handling of lazy and and or in async functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update unittest Created 5 years, 9 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 | « tests/compiler/dart2js/async_await_js_transform_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/async_and_or_test.dart
diff --git a/tests/language/async_and_or_test.dart b/tests/language/async_and_or_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f46061befc6e8e5a4c7596a843930b5daa73d9ac
--- /dev/null
+++ b/tests/language/async_and_or_test.dart
@@ -0,0 +1,86 @@
+// 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:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+test1() async {
+ Expect.isFalse(await confuse(false) && await confuse(false));
+ Expect.isFalse(await confuse(false) && await confuse(true));
+ Expect.isFalse(await confuse(true) && await confuse(false));
+ Expect.isTrue(await confuse(true) && await confuse(true));
+
+ Expect.isFalse(await confuse(false) || await confuse(false));
+ Expect.isTrue(await confuse(false) || await confuse(true));
+ Expect.isTrue(await confuse(true) || await confuse(false));
+ Expect.isTrue(await confuse(true) || await confuse(true));
+}
+
+String trace;
+
+traceA(x) {
+ trace += "a";
+ return x;
+}
+traceB(x) {
+ trace += "b";
+ return x;
+}
+
+testEvaluation(void fn()) async {
+ trace = "";
+ await fn();
+}
+
+test2() async {
+ await testEvaluation(() async {
+ Expect.isFalse(await confuse(traceA(false)) && await confuse(traceB(false)));
floitsch 2015/03/13 08:55:40 long line.
sigurdm 2015/05/08 07:44:52 Done.
+ Expect.equals("a", trace);
+ });
+ await testEvaluation(() async {
+ Expect.isFalse(await confuse(traceA(false)) && await confuse(traceB(true)));
+ Expect.equals("a", trace);
+ });
+ await testEvaluation(() async {
+ Expect.isFalse(await confuse(traceA(true)) && await confuse(traceB(false)));
+ Expect.equals("ab", trace);
+ });
+ await testEvaluation(() async {
+ Expect.isTrue(await confuse(traceA(true)) && await confuse(traceB(true)));
+ Expect.equals("ab", trace);
+ });
+
+ await testEvaluation(() async {
+ Expect.isFalse(await confuse(traceA(false)) || await confuse(traceB(false)));
floitsch 2015/03/13 08:55:40 long line.
sigurdm 2015/05/08 07:44:52 Done.
+ Expect.equals("ab", trace);
+ });
+ await testEvaluation(() async {
+ Expect.isTrue(await confuse(traceA(false)) || await confuse(traceB(true)));
+ Expect.equals("ab", trace);
+ });
+ await testEvaluation(() async {
+ Expect.isTrue(await confuse(traceA(true)) || await confuse(traceB(false)));
+ Expect.equals("a", trace);
+ });
+ await testEvaluation(() async {
+ Expect.isTrue(await confuse(traceA(true)) || await confuse(traceB(true)));
+ Expect.equals("a", trace);
+ });
+
+}
+
+test() async {
+ await test1();
+ await test2();
+}
+
+main() {
+ asyncStart();
+ test().then((_) => asyncEnd());
+}
+
+@NoInline
+@AssumeDynamic
+confuse(x) {
floitsch 2015/03/13 08:55:40 move this up.
sigurdm 2015/05/08 07:44:52 Done.
+ return x;
+}
« no previous file with comments | « tests/compiler/dart2js/async_await_js_transform_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698