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

Side by Side 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: Address Review 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js/async_await_js_transform_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 import "package:expect/expect.dart";
5 import "package:async_helper/async_helper.dart";
6
7 @NoInline
8 @AssumeDynamic
9 confuse(x) {
10 return x;
11 }
12
13 test1() async {
14 Expect.isFalse(await confuse(false) && await confuse(false));
15 Expect.isFalse(await confuse(false) && await confuse(true));
16 Expect.isFalse(await confuse(true) && await confuse(false));
17 Expect.isTrue(await confuse(true) && await confuse(true));
18
19 Expect.isFalse(await confuse(false) || await confuse(false));
20 Expect.isTrue(await confuse(false) || await confuse(true));
21 Expect.isTrue(await confuse(true) || await confuse(false));
22 Expect.isTrue(await confuse(true) || await confuse(true));
23 }
24
25 String trace;
26
27 traceA(x) {
28 trace += "a";
29 return x;
30 }
31 traceB(x) {
32 trace += "b";
33 return x;
34 }
35
36 testEvaluation(void fn()) async {
37 trace = "";
38 await fn();
39 }
40
41 test2() async {
42 await testEvaluation(() async {
43 Expect.isFalse(
44 await confuse(traceA(false)) && await confuse(traceB(false)));
45 Expect.equals("a", trace);
46 });
47 await testEvaluation(() async {
48 Expect.isFalse(await confuse(traceA(false)) && await confuse(traceB(true)));
49 Expect.equals("a", trace);
50 });
51 await testEvaluation(() async {
52 Expect.isFalse(await confuse(traceA(true)) && await confuse(traceB(false)));
53 Expect.equals("ab", trace);
54 });
55 await testEvaluation(() async {
56 Expect.isTrue(await confuse(traceA(true)) && await confuse(traceB(true)));
57 Expect.equals("ab", trace);
58 });
59
60 await testEvaluation(() async {
61 Expect.isFalse(
62 await confuse(traceA(false)) || await confuse(traceB(false)));
63 Expect.equals("ab", trace);
64 });
65 await testEvaluation(() async {
66 Expect.isTrue(await confuse(traceA(false)) || await confuse(traceB(true)));
67 Expect.equals("ab", trace);
68 });
69 await testEvaluation(() async {
70 Expect.isTrue(await confuse(traceA(true)) || await confuse(traceB(false)));
71 Expect.equals("a", trace);
72 });
73 await testEvaluation(() async {
74 Expect.isTrue(await confuse(traceA(true)) || await confuse(traceB(true)));
75 Expect.equals("a", trace);
76 });
77
78 }
79
80 test() async {
81 await test1();
82 await test2();
83 }
84
85 main() {
86 asyncStart();
87 test().then((_) => asyncEnd());
88 }
OLDNEW
« 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