OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 test1(bool passed, [a = 42]) { | 5 test1(bool passed, [a = 42]) { |
6 if (passed) { | 6 if (passed) { |
7 Expect.equals(54, a); | 7 Expect.equals(54, a); |
8 Expect.isTrue(?a); | 8 Expect.isTrue(?a); |
9 } else { | 9 } else { |
10 Expect.equals(42, a); | 10 Expect.equals(42, a); |
(...skipping 23 matching lines...) Expand all Loading... |
34 Expect.equals(54, a); | 34 Expect.equals(54, a); |
35 Expect.isTrue(?a); | 35 Expect.isTrue(?a); |
36 } else { | 36 } else { |
37 Expect.equals(42, a); | 37 Expect.equals(42, a); |
38 Expect.isFalse(?a); | 38 Expect.isFalse(?a); |
39 } | 39 } |
40 Expect.isTrue(?passed); | 40 Expect.isTrue(?passed); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
| 44 |
| 45 test4(bool passed, [a]) { |
| 46 if (passed) { |
| 47 Expect.equals(54, a); |
| 48 Expect.isTrue(?a); |
| 49 } else { |
| 50 Expect.equals(null, a); |
| 51 Expect.isFalse(?a); |
| 52 } |
| 53 Expect.isTrue(?passed); |
| 54 } |
| 55 |
44 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1)); | 56 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1)); |
45 | 57 |
46 main() { | 58 main() { |
47 test1(true, 54); | 59 test1(true, 54); |
48 test1(false); | 60 test1(false); |
49 test2(); | 61 test2(); |
50 new A().test3(true, 54); | 62 new A().test3(true, 54); |
51 new A().test3(false); | 63 new A().test3(false); |
52 | 64 |
53 var things = [test1, test2, new A().test3]; | 65 var things = [test1, test2, new A().test3]; |
54 | 66 |
55 var closure = things[inscrutable(0)]; | 67 var closure = things[inscrutable(0)]; |
56 closure(true, 54); | 68 closure(true, 54); |
57 closure(false); | 69 closure(false); |
58 | 70 |
59 closure = things[inscrutable(1)]; | 71 closure = things[inscrutable(1)]; |
60 closure(); | 72 closure(); |
61 | 73 |
62 closure = things[inscrutable(2)]; | 74 closure = things[inscrutable(2)]; |
63 closure(true, 54); | 75 closure(true, 54); |
64 closure(false); | 76 closure(false); |
| 77 |
| 78 test4(true, 54); |
| 79 test4(false); |
65 } | 80 } |
OLD | NEW |