Chromium Code Reviews

Side by Side Diff: test/codegen/lib/collection/hash_map_test.dart

Issue 1977003002: Update dart:collection. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « test/codegen/corelib/set_test.dart ('k') | test/codegen/lib/collection/hash_set_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, 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 "dart:collection";
6 import "package:expect/expect.dart";
7
8 void main() {
9 // Test customized maps.
10 // Regression test for issue http://dartbug.com/18109
11
12 hash(s) => s.toLowerCase().hashCode;
13 equals(a, b) => a.toLowerCase() == b.toLowerCase();
14
15 for (var m in [
16 new HashMap<String,int>(equals: equals, hashCode: hash),
17 new LinkedHashMap<String,int>(equals: equals, hashCode: hash),
18 ]) {
19 m["Abel"] = 42;
20 for (var key in ["Abel", "abel", "ABEL", "Abel"]) {
21 Expect.isTrue(m.containsKey(key), "contains $key in ${m.runtimeType} $m");
22 Expect.equals(42, m[key], "get $key in ${m.runtimeType} $m");
23 Expect.equals(42, m.remove(key), "remove $key in ${m.runtimeType} $m");
24 m[key] = 42;
25 }
26 }
27
28 abshash(n) => n.abs();
29 abseq(a, b) => a.abs() == b.abs();
30 for (var m in [
31 new HashMap<int,int>(equals: abseq, hashCode: abshash),
32 new LinkedHashMap<int,int>(equals: abseq, hashCode: abshash),
33 ]) {
34 m[1] = 42;
35 for (var key in [1, -1, 1]) {
36 Expect.isTrue(m.containsKey(key), "contains $key in ${m.runtimeType} $m");
37 Expect.equals(42, m[key], "get $key in ${m.runtimeType} $m");
38 Expect.equals(42, m.remove(key), "remove $key in ${m.runtimeType} $m");
39 m[key] = 42;
40 }
41 }
42 }
OLDNEW
« no previous file with comments | « test/codegen/corelib/set_test.dart ('k') | test/codegen/lib/collection/hash_set_test.dart » ('j') | no next file with comments »

Powered by Google App Engine