| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Provide a trivial test for identity based hashed collections, which we |
| 7 * provide here until an implementation is available in the regular libraries. |
| 8 */ |
| 9 // TODO(alanknight): Remove once identity-hashed collections are available. |
| 10 // Issue 4161. |
| 11 library identity_set_test; |
| 12 |
| 13 import 'package:unittest/unittest.dart'; |
| 14 import 'package:serialization/src/polyfill_identity_set.old.dart'; |
| 15 |
| 16 class Foo { |
| 17 var x; |
| 18 Foo(this.x); |
| 19 int get hashCode => x.hashCode; |
| 20 bool operator ==(a) => a.x == x; |
| 21 } |
| 22 |
| 23 main() { |
| 24 test('basic', () { |
| 25 var one = new Foo(3); |
| 26 var two = new Foo(3); |
| 27 var set = new Set(); |
| 28 var identitySet = new IdentitySet(); |
| 29 set..add(one)..add(two); |
| 30 identitySet..add(one)..add(two); |
| 31 expect(set.length, 1); |
| 32 expect(identitySet.length, 2); |
| 33 for (var each in identitySet) { |
| 34 expect(each, one); |
| 35 } |
| 36 }); |
| 37 } |
| OLD | NEW |