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

Unified Diff: tests/language/map_literal10_test.dart

Issue 22909056: Support general expressions as keys in literal maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/language/language_dart2js.status ('k') | tests/language/map_literal11_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/map_literal10_test.dart
diff --git a/tests/language/map_literal10_test.dart b/tests/language/map_literal10_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d1d388604d05b2760720fa6ae4f719bc6535ba05
--- /dev/null
+++ b/tests/language/map_literal10_test.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test the use of '__proto__' keys in maps.
+
+library map_literal10_test;
+
+import "package:expect/expect.dart";
+
+void main() {
+ var m1 = const {"__proto__": 0, 1: 1};
+ Expect.isTrue(m1.containsKey("__proto__"));
+ Expect.equals(0, m1["__proto__"]);
+ Expect.isTrue(m1.containsKey(1));
+ Expect.equals(1, m1[1]);
+ Expect.listEquals(["__proto__", 1], m1.keys.toList());
+
+ var m2 = const {1: 0, "__proto__": 1};
+ Expect.isTrue(m2.containsKey(1));
+ Expect.equals(0, m2[1]);
+ Expect.isTrue(m2.containsKey("__proto__"));
+ Expect.equals(1, m2["__proto__"]);
+ Expect.listEquals([1, "__proto__"], m2.keys.toList());
+
+ var m3 = const {"1": 0, "__proto__": 1};
+ Expect.isTrue(m3.containsKey("1"));
+ Expect.equals(0, m3["1"]);
+ Expect.isTrue(m3.containsKey("__proto__"));
+ Expect.equals(1, m3["__proto__"]);
+ Expect.listEquals(["1", "__proto__"], m3.keys.toList());
+
+ var m4 = const {"__proto__": 1, "1": 2};
+ Expect.isTrue(m4.containsKey("1"));
+ Expect.equals(2, m4["1"]);
+ Expect.isTrue(m4.containsKey("__proto__"));
+ Expect.equals(1, m4["__proto__"]);
+ Expect.listEquals(["__proto__", "1"], m4.keys.toList());
+}
« no previous file with comments | « tests/language/language_dart2js.status ('k') | tests/language/map_literal11_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698