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

Side by Side Diff: tests/lib_strong/collection/hash_set_test.dart

Issue 2667343005: Infer Null for return type of functions with empty returns. (Closed)
Patch Set: Address comments, fix 28630, ddc expectations Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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 import "dart:collection"; 5 import "dart:collection";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 void main() { 8 void main() {
9 // Test customized sets. 9 // Test customized sets.
10 // Regression test for issue http://dartbug.com/18109 10 // Regression test for issue http://dartbug.com/18109
11 11
12 hash(s) => s.toLowerCase().hashCode; 12 int hash(s) => s.toLowerCase().hashCode;
13 equals(a, b) => a.toLowerCase() == b.toLowerCase(); 13 bool equals(a, b) => a.toLowerCase() == b.toLowerCase();
14 14
15 for (var m in [ 15 for (var m in [
16 new HashSet<String>(equals: equals, hashCode: hash), 16 new HashSet<String>(equals: equals, hashCode: hash),
17 new LinkedHashSet<String>(equals: equals, hashCode: hash), 17 new LinkedHashSet<String>(equals: equals, hashCode: hash),
18 ]) { 18 ]) {
19 m.add("Abel"); 19 m.add("Abel");
20 var prev = "Abel"; 20 var prev = "Abel";
21 for (var key in ["Abel", "abel", "ABEL", "Abel"]) { 21 for (var key in ["Abel", "abel", "ABEL", "Abel"]) {
22 Expect.isTrue(m.contains(key), "contains $key in ${m.runtimeType} $m"); 22 Expect.isTrue(m.contains(key), "contains $key in ${m.runtimeType} $m");
23 Expect.equals(prev, m.lookup(key), "lookup $key in ${m.runtimeType} $m"); 23 Expect.equals(prev, m.lookup(key), "lookup $key in ${m.runtimeType} $m");
24 Expect.isTrue(m.remove(key), "remove $key in ${m.runtimeType} $m"); 24 Expect.isTrue(m.remove(key), "remove $key in ${m.runtimeType} $m");
25 m.add(key); 25 m.add(key);
26 prev = key; 26 prev = key;
27 } 27 }
28 } 28 }
29 29
30 abshash(n) => n.abs(); 30 int abshash(n) => n.abs();
31 abseq(a, b) => a.abs() == b.abs(); 31 bool abseq(a, b) => a.abs() == b.abs();
32 for (var m in [ 32 for (var m in [
33 new HashSet<int>(equals: abseq, hashCode: abshash), 33 new HashSet<int>(equals: abseq, hashCode: abshash),
34 new LinkedHashSet<int>(equals: abseq, hashCode: abshash), 34 new LinkedHashSet<int>(equals: abseq, hashCode: abshash),
35 ]) { 35 ]) {
36 m.add(1); 36 m.add(1);
37 var prev = 1; 37 var prev = 1;
38 for (var key in [1, -1, 1]) { 38 for (var key in [1, -1, 1]) {
39 Expect.isTrue(m.contains(key), "contains $key in ${m.runtimeType} $m"); 39 Expect.isTrue(m.contains(key), "contains $key in ${m.runtimeType} $m");
40 Expect.equals(prev, m.lookup(key), "lookup $key in ${m.runtimeType} $m"); 40 Expect.equals(prev, m.lookup(key), "lookup $key in ${m.runtimeType} $m");
41 Expect.isTrue(m.remove(key), "remove $key in ${m.runtimeType} $m"); 41 Expect.isTrue(m.remove(key), "remove $key in ${m.runtimeType} $m");
42 m.add(key); 42 m.add(key);
43 prev = key; 43 prev = key;
44 } 44 }
45 } 45 }
46 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698