OLD | NEW |
(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 } |
OLD | NEW |