Chromium Code Reviews| 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 | |
| 5 // Test the use of general expression as keys in const map literals. | |
| 6 | |
| 7 library map_literal6_test; | |
| 8 | |
| 9 import "package:expect/expect.dart"; | |
| 10 | |
| 11 class A { | |
| 12 const A(); | |
|
ngeoffray
2013/09/13 07:30:15
Please add tests with user-defined hashCode.
Johnni Winther
2013/09/18 12:37:21
Done.
ngeoffray
2013/09/18 14:32:08
Where?
| |
| 13 } | |
| 14 class B { | |
| 15 final a; | |
| 16 const B(this.a); | |
| 17 } | |
| 18 | |
| 19 void main() { | |
| 20 var m1 = const { | |
| 21 const A(): 0, | |
| 22 const B(0): 1, | |
| 23 const B(1): 2, | |
| 24 const B(const A()): 3, | |
| 25 const B(0): 4, | |
| 26 }; | |
| 27 Expect.isTrue(m1.containsKey(const A())); | |
| 28 Expect.isTrue(m1.containsKey(const B(0))); | |
| 29 Expect.isTrue(m1.containsKey(const B(1))); | |
| 30 Expect.isTrue(m1.containsKey(const B(const A()))); | |
| 31 Expect.equals(0, m1[const A()]); | |
| 32 Expect.equals(4, m1[const B(0)]); | |
| 33 Expect.equals(2, m1[const B(1)]); | |
| 34 Expect.equals(3, m1[const B(const A())]); | |
| 35 } | |
| OLD | NEW |