| 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 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 class Helper { | 8 class Helper { |
| 9 static bool STRICT_EQ(a, b) { | 9 static bool STRICT_EQ(a, b) { |
| 10 return identical(a, b); | 10 return identical(a, b); |
| 11 } | 11 } |
| 12 | 12 |
| 13 static bool STRICT_NE(a, b) { | 13 static bool STRICT_NE(a, b) { |
| 14 return !identical(a, b); | 14 return !identical(a, b); |
| 15 } | 15 } |
| 16 | 16 |
| 17 static bool EQ(a, b) { | 17 static bool EQ(a, b) { |
| 18 return a == b; | 18 return a == b; |
| 19 } | 19 } |
| 20 | 20 |
| 21 static bool NE(a, b) { | 21 static bool NE(a, b) { |
| 22 return a != b; | 22 return a != b; |
| 23 } | 23 } |
| 24 | 24 |
| 25 static bool LT(a, b) { | 25 static bool LT(a, b) { |
| 26 return a < b; | 26 return a < b; |
| 27 } | 27 } |
| 28 | 28 |
| 29 static bool LE(a,b) { | 29 static bool LE(a, b) { |
| 30 return a <= b; | 30 return a <= b; |
| 31 } | 31 } |
| 32 | 32 |
| 33 static bool GT(a, b) { | 33 static bool GT(a, b) { |
| 34 return a > b; | 34 return a > b; |
| 35 } | 35 } |
| 36 | 36 |
| 37 static bool GE(a, b) { | 37 static bool GE(a, b) { |
| 38 return a >= b; | 38 return a >= b; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 class A { | 42 class A { |
| 43 var b; | 43 var b; |
| 44 | 44 |
| 45 A(x) : b = x { } | 45 A(x) : b = x {} |
| 46 } | 46 } |
| 47 | 47 |
| 48 class ComparisonTest { | 48 class ComparisonTest { |
| 49 static testMain() { | 49 static testMain() { |
| 50 var a = new A(0); | 50 var a = new A(0); |
| 51 var b = new A(1); | 51 var b = new A(1); |
| 52 Expect.isTrue(Helper.STRICT_EQ(a, a)); | 52 Expect.isTrue(Helper.STRICT_EQ(a, a)); |
| 53 Expect.isFalse(Helper.STRICT_EQ(a, b)); | 53 Expect.isFalse(Helper.STRICT_EQ(a, b)); |
| 54 Expect.isFalse(Helper.STRICT_EQ(b, a)); | 54 Expect.isFalse(Helper.STRICT_EQ(b, a)); |
| 55 Expect.isTrue(Helper.STRICT_EQ(b, b)); | 55 Expect.isTrue(Helper.STRICT_EQ(b, b)); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 Expect.isFalse(Helper.EQ(null, 1.1)); | 316 Expect.isFalse(Helper.EQ(null, 1.1)); |
| 317 | 317 |
| 318 // TODO(srdjan): Clarify behaviour of greater/less comparisons | 318 // TODO(srdjan): Clarify behaviour of greater/less comparisons |
| 319 // between numbers and non-numbers. | 319 // between numbers and non-numbers. |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 main() { | 323 main() { |
| 324 ComparisonTest.testMain(); | 324 ComparisonTest.testMain(); |
| 325 } | 325 } |
| OLD | NEW |