OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart test program for testing basic boolean properties. | 5 // Dart test program for testing basic boolean properties. |
6 // @static-clean | 6 // @static-clean |
7 | 7 |
8 class BoolTest { | 8 class BoolTest { |
9 static void testEquality() { | 9 static void testEquality() { |
10 Expect.equals(true, true); | 10 Expect.equals(true, true); |
11 Expect.equals(false, false); | 11 Expect.equals(false, false); |
12 Expect.equals(true, true === true); | 12 Expect.equals(true, identical(true, true)); |
Lasse Reichstein Nielsen
2012/11/12 13:10:41
Expect.identical(true, true)
and
Expect.isFalse(
floitsch
2012/11/12 22:18:43
Changed to .isTrue / .isFalse.
Kept the identicals
| |
13 Expect.equals(false, true === false); | 13 Expect.equals(false, identical(true, false)); |
14 Expect.equals(true, false === false); | 14 Expect.equals(true, identical(false, false)); |
15 Expect.equals(false, false === true); | 15 Expect.equals(false, identical(false, true)); |
16 Expect.equals(false, true !== true); | 16 Expect.equals(false, !identical(true, true)); |
17 Expect.equals(true, true !== false); | 17 Expect.equals(true, !identical(true, false)); |
18 Expect.equals(false, false !== false); | 18 Expect.equals(false, !identical(false, false)); |
19 Expect.equals(true, false !== true); | 19 Expect.equals(true, !identical(false, true)); |
20 Expect.equals(true, true == true); | 20 Expect.equals(true, true == true); |
21 Expect.equals(false, true == false); | 21 Expect.equals(false, true == false); |
22 Expect.equals(true, false == false); | 22 Expect.equals(true, false == false); |
23 Expect.equals(false, false == true); | 23 Expect.equals(false, false == true); |
24 Expect.equals(false, true != true); | 24 Expect.equals(false, true != true); |
25 Expect.equals(true, true != false); | 25 Expect.equals(true, true != false); |
26 Expect.equals(false, false != false); | 26 Expect.equals(false, false != false); |
27 Expect.equals(true, false != true); | 27 Expect.equals(true, false != true); |
28 Expect.equals(true, true === (true == true)); | 28 Expect.equals(true, identical(true, (true == true))); |
29 Expect.equals(true, false === (true == false)); | 29 Expect.equals(true, identical(false, (true == false))); |
30 Expect.equals(true, true === (false == false)); | 30 Expect.equals(true, identical(true, (false == false))); |
31 Expect.equals(true, false === (false == true)); | 31 Expect.equals(true, identical(false, (false == true))); |
32 Expect.equals(false, true !== (true == true)); | 32 Expect.equals(false, !identical(true, (true == true))); |
33 Expect.equals(false, false !== (true == false)); | 33 Expect.equals(false, !identical(false, (true == false))); |
34 Expect.equals(false, true !== (false == false)); | 34 Expect.equals(false, !identical(true, (false == false))); |
35 Expect.equals(false, false !== (false == true)); | 35 Expect.equals(false, !identical(false, (false == true))); |
36 Expect.equals(false, false === (true == true)); | 36 Expect.equals(false, identical(false, (true == true))); |
37 Expect.equals(false, true === (true == false)); | 37 Expect.equals(false, identical(true, (true == false))); |
38 Expect.equals(false, false === (false == false)); | 38 Expect.equals(false, identical(false, (false == false))); |
39 Expect.equals(false, true === (false == true)); | 39 Expect.equals(false, identical(true, (false == true))); |
40 Expect.equals(true, false !== (true == true)); | 40 Expect.equals(true, !identical(false, (true == true))); |
41 Expect.equals(true, true !== (true == false)); | 41 Expect.equals(true, !identical(true, (true == false))); |
42 Expect.equals(true, false !== (false == false)); | 42 Expect.equals(true, !identical(false, (false == false))); |
43 Expect.equals(true, true !== (false == true)); | 43 Expect.equals(true, !identical(true, (false == true))); |
44 // Expect.equals could rely on a broken boolean equality. | 44 // Expect.equals could rely on a broken boolean equality. |
45 if (true == false) { | 45 if (true == false) { |
46 throw "Expect.equals broken"; | 46 throw "Expect.equals broken"; |
47 } | 47 } |
48 if (false == true) { | 48 if (false == true) { |
49 throw "Expect.equals broken"; | 49 throw "Expect.equals broken"; |
50 } | 50 } |
51 if (true === false) { | 51 if (identical(true, false)) { |
52 throw "Expect.equals broken"; | 52 throw "Expect.equals broken"; |
53 } | 53 } |
54 if (false === true) { | 54 if (identical(false, true)) { |
55 throw "Expect.equals broken"; | 55 throw "Expect.equals broken"; |
56 } | 56 } |
57 if (true == true) { | 57 if (true == true) { |
58 } else { | 58 } else { |
59 throw "Expect.equals broken"; | 59 throw "Expect.equals broken"; |
60 } | 60 } |
61 if (false == false) { | 61 if (false == false) { |
62 } else { | 62 } else { |
63 throw "Expect.equals broken"; | 63 throw "Expect.equals broken"; |
64 } | 64 } |
65 if (true === true) { | 65 if (identical(true, true)) { |
66 } else { | 66 } else { |
67 throw "Expect.equals broken"; | 67 throw "Expect.equals broken"; |
68 } | 68 } |
69 if (false === false) { | 69 if (identical(false, false)) { |
70 } else { | 70 } else { |
71 throw "Expect.equals broken"; | 71 throw "Expect.equals broken"; |
72 } | 72 } |
73 if (true != false) { | 73 if (true != false) { |
74 } else { | 74 } else { |
75 throw "Expect.equals broken"; | 75 throw "Expect.equals broken"; |
76 } | 76 } |
77 if (false != true) { | 77 if (false != true) { |
78 } else { | 78 } else { |
79 throw "Expect.equals broken"; | 79 throw "Expect.equals broken"; |
80 } | 80 } |
81 if (true !== false) { | 81 if (!identical(true, false)) { |
82 } else { | 82 } else { |
83 throw "Expect.equals broken"; | 83 throw "Expect.equals broken"; |
84 } | 84 } |
85 if (false !== true) { | 85 if (!identical(false, true)) { |
86 } else { | 86 } else { |
87 throw "Expect.equals broken"; | 87 throw "Expect.equals broken"; |
88 } | 88 } |
89 if (true != true) { | 89 if (true != true) { |
90 throw "Expect.equals broken"; | 90 throw "Expect.equals broken"; |
91 } | 91 } |
92 if (false != false) { | 92 if (false != false) { |
93 throw "Expect.equals broken"; | 93 throw "Expect.equals broken"; |
94 } | 94 } |
95 if (true !== true) { | 95 if (!identical(true, true)) { |
96 throw "Expect.equals broken"; | 96 throw "Expect.equals broken"; |
97 } | 97 } |
98 if (false !== false) { | 98 if (!identical(false, false)) { |
99 throw "Expect.equals broken"; | 99 throw "Expect.equals broken"; |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 static void testToString() { | 103 static void testToString() { |
104 Expect.equals("true", true.toString()); | 104 Expect.equals("true", true.toString()); |
105 Expect.equals("false", false.toString()); | 105 Expect.equals("false", false.toString()); |
106 } | 106 } |
107 | 107 |
108 static void testNegate(isTrue, isFalse) { | 108 static void testNegate(isTrue, isFalse) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 testEquality(); | 210 testEquality(); |
211 testNegate(true, false); | 211 testNegate(true, false); |
212 testToString(); | 212 testToString(); |
213 testLogicalOp(); | 213 testLogicalOp(); |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 main() { | 217 main() { |
218 BoolTest.testMain(); | 218 BoolTest.testMain(); |
219 } | 219 } |
OLD | NEW |