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 // Dart test program for testing comparison operators. | 4 // Dart test program for testing comparison operators. |
5 | 5 |
6 class Helper { | 6 class Helper { |
7 static bool STRICT_EQ(a, b) { | 7 static bool STRICT_EQ(a, b) { |
8 return a === b; | 8 return identical(a, b); |
9 } | 9 } |
10 | 10 |
11 static bool STRICT_NE(a, b) { | 11 static bool STRICT_NE(a, b) { |
12 return a !== b; | 12 return !identical(a, b); |
13 } | 13 } |
14 | 14 |
15 static bool EQ(a, b) { | 15 static bool EQ(a, b) { |
16 return a == b; | 16 return a == b; |
17 } | 17 } |
18 | 18 |
19 static bool NE(a, b) { | 19 static bool NE(a, b) { |
20 return a != b; | 20 return a != b; |
21 } | 21 } |
22 | 22 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 Expect.equals(false, Helper.LT(1.2, 1.1)); | 291 Expect.equals(false, Helper.LT(1.2, 1.1)); |
292 Expect.equals(false, Helper.LT(1.2, 1.1)); | 292 Expect.equals(false, Helper.LT(1.2, 1.1)); |
293 Expect.equals(false, Helper.LT(1.2, 1.1)); | 293 Expect.equals(false, Helper.LT(1.2, 1.1)); |
294 | 294 |
295 Expect.equals(false, Helper.GE(1.1, 1.2)); | 295 Expect.equals(false, Helper.GE(1.1, 1.2)); |
296 Expect.equals(false, Helper.GE(1.1, 1.2)); | 296 Expect.equals(false, Helper.GE(1.1, 1.2)); |
297 Expect.equals(true, Helper.GE(1.2, 1.2)); | 297 Expect.equals(true, Helper.GE(1.2, 1.2)); |
298 Expect.equals(true, Helper.GE(1.2, 1.2)); | 298 Expect.equals(true, Helper.GE(1.2, 1.2)); |
299 | 299 |
300 // With non-number classes. | 300 // With non-number classes. |
301 Expect.equals(false, Helper.EQ(1, "eeny")); | 301 Expect.equals(false, Helper.EQ(1, "eeny")); |
Lasse Reichstein Nielsen
2012/11/12 13:10:41
Expect.isFalse
floitsch
2012/11/12 22:18:43
Done.
| |
302 Expect.equals(false, Helper.EQ("meeny", 1)); | 302 Expect.equals(false, Helper.EQ("meeny", 1)); |
303 Expect.equals(false, Helper.EQ(1.1, "miny")); | 303 Expect.equals(false, Helper.EQ(1.1, "miny")); |
304 Expect.equals(false, Helper.EQ("moe", 1.1)); | 304 Expect.equals(false, Helper.EQ("moe", 1.1)); |
305 Expect.equals(false, Helper.EQ(1.1, "catch")); | 305 Expect.equals(false, Helper.EQ(1.1, "catch")); |
306 Expect.equals(false, Helper.EQ("the", 1.1)); | 306 Expect.equals(false, Helper.EQ("the", 1.1)); |
307 | 307 |
308 // With null. | 308 // With null. |
309 Expect.equals(false, Helper.EQ(1, null)); | 309 Expect.equals(false, Helper.EQ(1, null)); |
310 Expect.equals(false, Helper.EQ(null, 1)); | 310 Expect.equals(false, Helper.EQ(null, 1)); |
311 Expect.equals(false, Helper.EQ(1.1, null)); | 311 Expect.equals(false, Helper.EQ(1.1, null)); |
312 Expect.equals(false, Helper.EQ(null, 1.1)); | 312 Expect.equals(false, Helper.EQ(null, 1.1)); |
313 Expect.equals(false, Helper.EQ(1.1, null)); | 313 Expect.equals(false, Helper.EQ(1.1, null)); |
314 Expect.equals(false, Helper.EQ(null, 1.1)); | 314 Expect.equals(false, Helper.EQ(null, 1.1)); |
315 | 315 |
316 // TODO(srdjan): Clarify behaviour of greater/less comparisons | 316 // TODO(srdjan): Clarify behaviour of greater/less comparisons |
317 // between numbers and non-numbers. | 317 // between numbers and non-numbers. |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 main() { | 321 main() { |
322 ComparisonTest.testMain(); | 322 ComparisonTest.testMain(); |
323 } | 323 } |
OLD | NEW |