Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: tests/language/src/MapLiteral2Test.dart

Issue 8318031: Interpolated strings are never considered compile time const (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 }
OLDNEW
« no previous file with comments | « tests/language/language.status ('k') | tests/language/src/StringInterpolation7NegativeTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698