Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tests/language/canonical_const_test.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/language/canonical_const2_test.dart ('k') | tests/language/class_literal_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Check that initializers of static const fields are compile time constants. 4 // Check that initializers of static const fields are compile time constants.
5 5
6 class CanonicalConstTest { 6 class CanonicalConstTest {
7 static const A = const C1(); 7 static const A = const C1();
8 static const B = const C2(); 8 static const B = const C2();
9 9
10 static testMain() { 10 static testMain() {
11 Expect.isTrue(null===null); 11 Expect.identical(null, null);
12 Expect.isTrue(null!==0); 12 Expect.isFalse(identical(null, 0));
13 Expect.isTrue(1===1); 13 Expect.identical(1, 1);
14 Expect.isTrue(1!==2); 14 Expect.isFalse(identical(1, 2));
15 Expect.isTrue(true===true); 15 Expect.identical(true, true);
16 Expect.isTrue("so"==="so"); 16 Expect.identical("so", "so");
17 Expect.isTrue(const Object()===const Object()); 17 Expect.identical(const Object(), const Object());
18 Expect.isTrue(const Object()!==const C1()); 18 Expect.isFalse(identical(const Object(), const C1()));
19 Expect.isTrue(const C1()===const C1()); 19 Expect.identical(const C1(), const C1());
20 Expect.isTrue(A===const C1()); 20 Expect.identical(A, const C1());
21 Expect.isTrue(const C1()!==const C2()); 21 Expect.isFalse(identical(const C1(), const C2()));
22 Expect.isTrue(B===const C2()); 22 Expect.identical(B, const C2());
23 // TODO(johnlenz): these two values don't currently have the same type 23 // TODO(johnlenz): these two values don't currently have the same type
24 // Expect.isTrue(const [1,2] === const List[1,2]); 24 // Expect.isTrue(const [1,2] === const List[1,2]);
25 Expect.isTrue(const [2,1] !== const[1,2]); 25 Expect.isFalse(identical(const [2,1], const[1,2]));
26 Expect.isTrue(const <int>[1,2] === const <int>[1,2]); 26 Expect.identical(const <int>[1,2], const <int>[1,2]);
27 Expect.isTrue(const <Object>[1,2] === const <Object>[1,2]); 27 Expect.identical(const <Object>[1,2], const <Object>[1,2]);
28 Expect.isTrue(const <int>[1,2] !== const <double>[1.0,2.0]); 28 Expect.isFalse(identical(const <int>[1,2], const <double>[1.0,2.0]));
29 Expect.isTrue(const {"a":1, "b":2} === const {"a":1, "b":2}); 29 Expect.identical(const {"a":1, "b":2}, const {"a":1, "b":2});
30 Expect.isTrue(const {"a":1, "b":2} !== const {"a":2, "b":2}); 30 Expect.isFalse(identical(const {"a":1, "b":2}, const {"a":2, "b":2}));
31 } 31 }
32 } 32 }
33 33
34 class C1 { 34 class C1 {
35 const C1(); 35 const C1();
36 } 36 }
37 37
38 class C2 extends C1 { 38 class C2 extends C1 {
39 const C2() : super(); 39 const C2() : super();
40 } 40 }
41 41
42 main() { 42 main() {
43 CanonicalConstTest.testMain(); 43 CanonicalConstTest.testMain();
44 } 44 }
OLDNEW
« no previous file with comments | « tests/language/canonical_const2_test.dart ('k') | tests/language/class_literal_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698