OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Test efficient and correct implementation of !identical(a, b). | 4 // Test efficient and correct implementation of !identical(a, b). |
5 | 5 |
| 6 import 'package:expect/expect.dart'; |
| 7 |
6 notIdenticalTest1(a) { | 8 notIdenticalTest1(a) { |
7 if (!identical("ho", a)) { | 9 if (!identical("ho", a)) { |
8 return 2; | 10 return 2; |
9 } else { | 11 } else { |
10 return 1; | 12 return 1; |
11 } | 13 } |
12 } | 14 } |
13 | 15 |
14 notIdenticalTest2(a) { | 16 notIdenticalTest2(a) { |
15 var x = identical("ho", a); | 17 var x = identical("ho", a); |
(...skipping 11 matching lines...) Expand all Loading... |
27 return !x; | 29 return !x; |
28 } | 30 } |
29 | 31 |
30 main() { | 32 main() { |
31 for (int i = 0; i < 10000; i++) { | 33 for (int i = 0; i < 10000; i++) { |
32 Expect.equals(1, notIdenticalTest1("ho")); | 34 Expect.equals(1, notIdenticalTest1("ho")); |
33 Expect.equals(1, notIdenticalTest2("ho")); | 35 Expect.equals(1, notIdenticalTest2("ho")); |
34 Expect.equals(false, notIdenticalTest3("ho")); | 36 Expect.equals(false, notIdenticalTest3("ho")); |
35 } | 37 } |
36 } | 38 } |
OLD | NEW |