| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 // Test efficient and correct implementation of !identical(a, b). |
| 5 |
| 6 notIdenticalTest1(a) { |
| 7 if (!identical("ho", a)) { |
| 8 return 2; |
| 9 } else { |
| 10 return 1; |
| 11 } |
| 12 } |
| 13 |
| 14 notIdenticalTest2(a) { |
| 15 var x = identical("ho", a); |
| 16 if (!x) { |
| 17 Expect.equals(false, x); |
| 18 return x; |
| 19 } else { |
| 20 Expect.equals(true, x); |
| 21 return 1; |
| 22 } |
| 23 } |
| 24 |
| 25 notIdenticalTest3(a) { |
| 26 var x = identical("ho", a); |
| 27 return !x; |
| 28 } |
| 29 |
| 30 main() { |
| 31 for (int i = 0; i < 10000; i++) { |
| 32 Expect.equals(1, notIdenticalTest1("ho")); |
| 33 Expect.equals(1, notIdenticalTest2("ho")); |
| 34 Expect.equals(false, notIdenticalTest3("ho")); |
| 35 } |
| 36 } |
| OLD | NEW |