OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, 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 | |
5 import "package:expect/expect.dart"; | |
6 | |
7 var myIdentical = identical; | |
8 | |
9 class Point { | |
10 num x, y; | |
11 Point(this.x, this.y); | |
12 } | |
13 | |
14 main() { | |
15 // int. | |
16 Expect.isTrue(myIdentical(42, 42)); | |
17 Expect.isFalse(myIdentical(42, 41)); | |
18 | |
19 // double. | |
20 Expect.isTrue(myIdentical(42.0, 42.0)); | |
21 Expect.isFalse(myIdentical(42.0, 41.0)); | |
22 | |
23 // Mint (2^45). | |
24 Expect.isTrue(myIdentical(35184372088832, 35184372088832)); | |
25 Expect.isFalse(myIdentical(35184372088832, 35184372088831)); | |
26 | |
27 // Different types. | |
28 Expect.isFalse(myIdentical("hello", 41)); | |
29 | |
30 // Points. | |
31 var p = new Point(1, 1); | |
32 var q = new Point(1, 1); | |
33 Expect.isFalse(myIdentical(p, q)); | |
34 | |
35 // Strings. | |
36 var a = "hello"; | |
37 var b = "hello"; | |
38 // Identical strings are coalesced into single instances. | |
39 Expect.isTrue(myIdentical(a, b)); | |
40 | |
41 // Null handling. | |
42 Expect.isFalse(myIdentical(42, null)); | |
43 Expect.isTrue(myIdentical(null, null)); | |
44 } | |
OLD | NEW |