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

Side by Side Diff: pkg/serialization/test/polyfill_identity_map_test.dart

Issue 11567018: Get rid of the polyfill identity set implementation in favour of a (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: A bit more polyfill that can be removed with this change. Created 8 years 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) 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 4
5 /** 5 /**
6 * Provide a trivial test for identity based hashed collections, which we 6 * Provide a trivial test for identity based hashed collections, which we
7 * provide here until an implementation is available in the regular libraries. 7 * provide here until an implementation is available in the regular libraries.
8 */ 8 */
9 // TODO(alanknight): Remove once identity-hashed collections are available. 9 // TODO(alanknight): Remove once identity-hashed collections are available.
10 // Issue 4161. 10 // Issue 4161.
11 library identity_set_test; 11 library identity_set_test;
12 12
13 import '../../unittest/lib/unittest.dart'; 13 import '../../unittest/lib/unittest.dart';
14 import '../lib/src/polyfill_identity_set.dart'; 14 import '../lib/src/serialization_helpers.dart';
15 15
16 class Foo { 16 class Foo {
17 var x; 17 var x;
18 Foo(this.x); 18 Foo(this.x);
19 int get hashCode => x.hashCode; 19 int get hashCode => x.hashCode;
20 bool operator ==(a) => a.x == x; 20 bool operator ==(a) => a.x == x;
21 } 21 }
22 22
23 main() { 23 main() {
24 test('basic', () { 24 test('basic', () {
25 var one = new Foo(3); 25 var one = new Foo(3);
26 var two = new Foo(3); 26 var two = new Foo(3);
27 var map = new Map(); 27 var map = new Map();
28 var identityMap = new IdentityMap(); 28 var identityMap = new IdentityMap();
29 map[one] = one; 29 map[one] = one;
30 map[two] = two; 30 map[two] = two;
31 identityMap[one] = one; 31 identityMap[one] = one;
32 identityMap[two] = two; 32 identityMap[two] = two;
33 expect(map.length, 1); 33 expect(map.length, 1);
34 expect(identityMap.length, 2); 34 expect(identityMap.length, 2);
35 for (var each in identityMap.values) { 35 for (var each in identityMap.values) {
36 expect(each, one); 36 expect(each, one);
37 } 37 }
38 }); 38 });
39
40 test('uniquing primitives', () {
41 var map = new IdentityMap();
42 var one = 'one';
43 var two = new String.fromCharCodes(one.charCodes);
44 map[one] = 1;
45 expect(map[two], 1);
46 expect(map[one], 1);
47 });
39 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698