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); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 Expect.equals(true, !false); | 109 Expect.equals(true, !false); |
110 Expect.equals(false, !true); | 110 Expect.equals(false, !true); |
111 Expect.equals(true, !isFalse); | 111 Expect.equals(true, !isFalse); |
112 Expect.equals(false, !isTrue); | 112 Expect.equals(false, !isTrue); |
113 } | 113 } |
114 | 114 |
115 static void testLogicalOp() { | 115 static void testLogicalOp() { |
116 testOr(a, b, onTypeError) { | 116 testOr(a, b, onTypeError) { |
117 try { | 117 try { |
118 return a || b; | 118 return a || b; |
119 } catch (TypeError t) { | 119 } on TypeError catch (t) { |
120 return onTypeError; | 120 return onTypeError; |
121 } | 121 } |
122 } | 122 } |
123 testAnd(a, b, onTypeError) { | 123 testAnd(a, b, onTypeError) { |
124 try { | 124 try { |
125 return a && b; | 125 return a && b; |
126 } catch (TypeError t) { | 126 } on TypeError catch (t) { |
127 return onTypeError; | 127 return onTypeError; |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 var isTrue = true; | 131 var isTrue = true; |
132 var isFalse = false; | 132 var isFalse = false; |
133 Expect.equals(true, testAnd(isTrue, isTrue, false)); | 133 Expect.equals(true, testAnd(isTrue, isTrue, false)); |
134 Expect.equals(false, testAnd(isTrue, 0, false)); | 134 Expect.equals(false, testAnd(isTrue, 0, false)); |
135 Expect.equals(false, testAnd(isTrue, 1, false)); | 135 Expect.equals(false, testAnd(isTrue, 1, false)); |
136 Expect.equals(false, testAnd(isTrue, "true", false)); | 136 Expect.equals(false, testAnd(isTrue, "true", false)); |
(...skipping 73 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 |