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

Unified Diff: pkg/serialization/test/polyfill_identity_map_test.dart

Issue 23890008: Revert "Make LinkedHashMap also have a factory constructor and be customizable" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « pkg/serialization/lib/src/serialization_helpers.dart ('k') | runtime/lib/collection_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/serialization/test/polyfill_identity_map_test.dart
diff --git a/pkg/serialization/test/polyfill_identity_map_test.dart b/pkg/serialization/test/polyfill_identity_map_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..bfc8fef647686ac2ac1ccdf6941bb410f6ee7eb5
--- /dev/null
+++ b/pkg/serialization/test/polyfill_identity_map_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2012, 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.
+
+/**
+ * Provide a trivial test for identity based hashed collections, which we
+ * provide here until an implementation is available in the regular libraries.
+ */
+// TODO(alanknight): Remove once identity-hashed collections are available.
+// Issue 4161.
+library identity_set_test;
+
+import 'package:unittest/unittest.dart';
+import 'package:serialization/src/serialization_helpers.dart';
+
+class Foo {
+ var x;
+ Foo(this.x);
+ int get hashCode => x.hashCode;
+ bool operator ==(a) => a.x == x;
+}
+
+main() {
+ test('basic', () {
+ var one = new Foo(3);
+ var two = new Foo(3);
+ var map = new Map();
+ var identityMap = new IdentityMap();
+ map[one] = one;
+ map[two] = two;
+ identityMap[one] = one;
+ identityMap[two] = two;
+ expect(map.length, 1);
+ expect(identityMap.length, 2);
+ for (var each in identityMap.values) {
+ expect(each, one);
+ }
+ });
+
+ test('uniquing primitives', () {
+ var map = new IdentityMap();
+ var one = 'one';
+ var two = new String.fromCharCodes(one.codeUnits);
+ map[one] = 1;
+ expect(map[two], 1);
+ expect(map[one], 1);
+ });
+}
« no previous file with comments | « pkg/serialization/lib/src/serialization_helpers.dart ('k') | runtime/lib/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698