OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test compile-time constants with string-interpolation. | 4 // Test compile-time constants with string-interpolation. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 const str = "foo"; | 8 const str = "foo"; |
9 const m1 = const { "foo": 499 }; | 9 const m1 = const {"foo": 499}; |
10 const m2 = const { "$str": 499 }; | 10 const m2 = const {"$str": 499}; |
11 const m3 = const { | 11 const m3 = const { |
12 "$str": 42, //# 01: static type warning | 12 "$str": 42, //# 01: static type warning |
13 "foo": 499 }; | 13 "foo": 499 |
| 14 }; |
14 const m4 = const { | 15 const m4 = const { |
15 "foo": 42, //# 02: static type warning | 16 "foo": 42, //# 02: static type warning |
16 "$str": 499 }; | 17 "$str": 499 |
17 const m5 = const { "f" "o" "o": 499 }; | 18 }; |
| 19 const m5 = const {"f" "o" "o": 499}; |
18 | 20 |
19 const mm1 = const { "afoo#foo": 499 }; | 21 const mm1 = const {"afoo#foo": 499}; |
20 const mm2 = const { "a$str#$str": 499 }; | 22 const mm2 = const {"a$str#$str": 499}; |
21 const mm3 = const { "a" "$str" "#" "foo": 499 }; | 23 const mm3 = const {"a" "$str" "#" "foo": 499}; |
22 const mm4 = const { "a$str" "#$str": 499 }; | 24 const mm4 = const {"a$str" "#$str": 499}; |
23 | 25 |
24 main() { | 26 main() { |
25 Expect.equals(1, m1.length); | 27 Expect.equals(1, m1.length); |
26 Expect.equals(499, m1["foo"]); | 28 Expect.equals(499, m1["foo"]); |
27 Expect.identical(m1, m2); | 29 Expect.identical(m1, m2); |
28 Expect.identical(m1, m3); | 30 Expect.identical(m1, m3); |
29 Expect.identical(m1, m4); | 31 Expect.identical(m1, m4); |
30 Expect.identical(m1, m5); | 32 Expect.identical(m1, m5); |
31 | 33 |
32 Expect.equals(1, mm1.length); | 34 Expect.equals(1, mm1.length); |
33 Expect.equals(499, mm1["afoo#foo"]); | 35 Expect.equals(499, mm1["afoo#foo"]); |
34 Expect.identical(mm1, mm2); | 36 Expect.identical(mm1, mm2); |
35 Expect.identical(mm1, mm3); | 37 Expect.identical(mm1, mm3); |
36 Expect.identical(mm1, mm4); | 38 Expect.identical(mm1, mm4); |
37 } | 39 } |
OLD | NEW |