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 general expression as keys in map literals. | 5 // Test the use of general expression as keys in map literals. |
6 | 6 |
7 library map_literal5_test; | 7 library map_literal5_test; |
8 | 8 |
9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 Expect.equals(0, m[true]); | 25 Expect.equals(0, m[true]); |
26 Expect.equals(3, m[2]); | 26 Expect.equals(3, m[2]); |
27 Expect.equals(2, m[1]); | 27 Expect.equals(2, m[1]); |
28 } else { | 28 } else { |
29 Expect.equals(0, m[false]); | 29 Expect.equals(0, m[false]); |
30 Expect.equals("baz", m["bar"]); | 30 Expect.equals("baz", m["bar"]); |
31 Expect.equals(2, m["foo"]); | 31 Expect.equals(2, m["foo"]); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 create(bool b) { | 35 Map create(bool b) { |
36 return { | 36 return { |
37 b: 0, | 37 b: 0, |
38 m(b): n(b), | 38 m(b): n(b), |
39 b ? 1 : "foo": 2, | 39 b ? 1 : "foo": 2, |
40 }; | 40 }; |
41 } | 41 } |
42 | 42 |
43 m(bool b) => b ? 2 : "bar"; | 43 Object m(bool b) => b ? 2 : "bar"; |
44 n(bool b) => b ? 3 : "baz"; | 44 Object n(bool b) => b ? 3 : "baz"; |
OLD | NEW |