| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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 program for map literals. | 4 // Test program for map literals. |
| 5 | 5 |
| 6 final AA = 1; | |
| 7 final BB = 2; | |
| 8 | |
| 9 int nextValCtr; | 6 int nextValCtr; |
| 10 | 7 |
| 11 get nextVal() { | 8 get nextVal() { |
| 12 return nextValCtr++; | 9 return nextValCtr++; |
| 13 } | 10 } |
| 14 | 11 |
| 15 class MapLiteral2Test { | 12 main() { |
| 16 static testMain() { | 13 // Map literals with string interpolation in keys. |
| 17 // Map literals with string interpolation in keys. | 14 nextValCtr = 0; |
| 18 var map = const { "a$AA": 88, "b$BB": 99 }; | 15 var map = {"a$nextVal": "Grey", "a$nextVal": "Poupon" }; |
| 19 Expect.equals(2, map.length); | 16 Expect.equals(true, map.containsKey("a0")); |
| 20 Expect.equals("a1", "a$AA"); | 17 Expect.equals(true, map.containsKey("a1")); |
| 21 Expect.equals(88, map["a1"]); | 18 Expect.equals("Grey", map["a0"]); |
| 22 Expect.equals("b2", "b$BB"); | 19 Expect.equals("Poupon", map["a1"]); |
| 23 Expect.equals(99, map["b2"]); | |
| 24 | |
| 25 nextValCtr = 0; | |
| 26 map = {"a$nextVal": "Grey", "a$nextVal": "Poupon" }; | |
| 27 Expect.equals(true, map.containsKey("a0")); | |
| 28 Expect.equals(true, map.containsKey("a1")); | |
| 29 Expect.equals("Grey", map["a0"]); | |
| 30 Expect.equals("Poupon", map["a1"]); | |
| 31 } | |
| 32 } | 20 } |
| 33 | |
| 34 | |
| 35 | |
| 36 main() { | |
| 37 MapLiteral2Test.testMain(); | |
| 38 } | |
| OLD | NEW |