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 | 4 |
5 // Test the use of type arguments on const map literals using general expression | 5 // Test the use of type arguments on const map literals using general expression |
6 // as keys. | 6 // as keys. |
7 | 7 |
8 library map_literal8_test; | 8 library map_literal8_test; |
9 | 9 |
10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
11 | 11 |
12 class A { | 12 class A { |
13 const A(); | 13 const A(); |
14 } | 14 } |
| 15 |
15 class B extends A { | 16 class B extends A { |
16 final a; | 17 final a; |
17 const B(this.a); | 18 const B(this.a); |
18 } | 19 } |
19 | 20 |
20 void main() { | 21 void main() { |
21 var m1 = const { | 22 var m1 = const { |
22 const A(): 0, | 23 const A(): 0, |
23 const B(0): 1, | 24 const B(0): 1, |
24 const B(1): 2, | 25 const B(1): 2, |
25 const B(const A()): 3, | 26 const B(const A()): 3, |
26 const B(0): 4, | 27 const B(0): 4, |
27 }; | 28 }; |
28 Expect.isTrue(m1 is Map); | 29 Expect.isTrue(m1 is Map); |
29 Expect.isTrue(m1 is Map<A,int>); | 30 Expect.isTrue(m1 is Map<A, int>); |
30 Expect.isTrue(m1 is Map<int, dynamic>); | 31 Expect.isTrue(m1 is Map<int, dynamic>); |
31 Expect.isTrue(m1 is Map<dynamic, A>); | 32 Expect.isTrue(m1 is Map<dynamic, A>); |
32 | 33 |
33 var m2 = const <A, int>{ | 34 var m2 = const <A, int>{ |
34 const A(): 0, | 35 const A(): 0, |
35 const B(0): 1, | 36 const B(0): 1, |
36 const B(1): 2, | 37 const B(1): 2, |
37 const B(const A()): 3, | 38 const B(const A()): 3, |
38 const B(0): 4, | 39 const B(0): 4, |
39 }; | 40 }; |
40 Expect.isTrue(m2 is Map); | 41 Expect.isTrue(m2 is Map); |
41 Expect.isTrue(m2 is Map<A, int>); | 42 Expect.isTrue(m2 is Map<A, int>); |
42 Expect.isFalse(m2 is Map<int, dynamic>); | 43 Expect.isFalse(m2 is Map<int, dynamic>); |
43 Expect.isFalse(m2 is Map<dynamic, A>); | 44 Expect.isFalse(m2 is Map<dynamic, A>); |
44 } | 45 } |
OLD | NEW |