| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // Check that initializers of static const fields are compile time constants. | |
| 5 | |
| 6 class CanonicalConstTest { | |
| 7 static final A = const C1(); | |
| 8 static final B = const C2(); | |
| 9 | |
| 10 static testMain() { | |
| 11 Expect.isTrue(null===null); | |
| 12 Expect.isTrue(null!==0); | |
| 13 Expect.isTrue(1===1); | |
| 14 Expect.isTrue(1!==2); | |
| 15 Expect.isTrue(true===true); | |
| 16 Expect.isTrue("so"==="so"); | |
| 17 Expect.isTrue(const Object()===const Object()); | |
| 18 Expect.isTrue(const Object()!==const C1()); | |
| 19 Expect.isTrue(const C1()===const C1()); | |
| 20 Expect.isTrue(A===const C1()); | |
| 21 Expect.isTrue(const C1()!==const C2()); | |
| 22 Expect.isTrue(B===const C2()); | |
| 23 // TODO(johnlenz): these two values don't currently have the same type | |
| 24 // Expect.isTrue(const [1,2] === const List[1,2]); | |
| 25 Expect.isTrue(const [2,1] !== const[1,2]); | |
| 26 Expect.isTrue(const <int>[1,2] === const <int>[1,2]); | |
| 27 Expect.isTrue(const <Object>[1,2] === const <Object>[1,2]); | |
| 28 Expect.isTrue(const <int>[1,2] !== const <double>[1.0,2.0]); | |
| 29 Expect.isTrue(const {"a":1, "b":2} === const {"a":1, "b":2}); | |
| 30 Expect.isTrue(const {"a":1, "b":2} !== const {"a":2, "b":2}); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 class C1 { | |
| 35 const C1(); | |
| 36 } | |
| 37 | |
| 38 class C2 extends C1 { | |
| 39 const C2() : super(); | |
| 40 } | |
| 41 | |
| 42 main() { | |
| 43 CanonicalConstTest.testMain(); | |
| 44 } | |
| OLD | NEW |