OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 import 'package:collection/collection.dart'; |
| 6 import 'package:test/test.dart'; |
| 7 |
| 8 void main() { |
| 9 test("uses the given equality", () { |
| 10 var map = new EqualityMap(const IterableEquality()); |
| 11 expect(map, isEmpty); |
| 12 |
| 13 map[[1, 2, 3]] = 1; |
| 14 expect(map, containsPair([1, 2, 3], 1)); |
| 15 |
| 16 map[[1, 2, 3]] = 2; |
| 17 expect(map, containsPair([1, 2, 3], 2)); |
| 18 |
| 19 map[[2, 3, 4]] = 3; |
| 20 expect(map, containsPair([1, 2, 3], 2)); |
| 21 expect(map, containsPair([2, 3, 4], 3)); |
| 22 }); |
| 23 |
| 24 test("EqualityMap.from() prefers the lattermost equivalent key", () { |
| 25 var map = new EqualityMap.from(const IterableEquality(), { |
| 26 [1, 2, 3]: 1, |
| 27 [2, 3, 4]: 2, |
| 28 [1, 2, 3]: 3, |
| 29 [2, 3, 4]: 4, |
| 30 [1, 2, 3]: 5, |
| 31 [1, 2, 3]: 6, |
| 32 }); |
| 33 |
| 34 expect(map, containsPair([1, 2, 3], 6)); |
| 35 expect(map, containsPair([2, 3, 4], 4)); |
| 36 }); |
| 37 } |
OLD | NEW |