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

Side by Side Diff: tests/corelib/maps_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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 library maps_test; 5 library maps_test;
6
6 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
7 import 'dart:collection'; 8 import 'dart:collection';
8 9
9 main() { 10 main() {
10 final key1 = "key1"; 11 final key1 = "key1";
11 final key2 = "key2"; 12 final key2 = "key2";
12 final key3 = "key3"; 13 final key3 = "key3";
13 final key4 = "key4"; 14 final key4 = "key4";
14 final key5 = "key5"; 15 final key5 = "key5";
15 final key6 = "key6"; 16 final key6 = "key6";
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Expect.equals(2, Maps.length(map)); 94 Expect.equals(2, Maps.length(map));
94 95
95 Expect.equals(true, Maps.containsKey(map, key1)); 96 Expect.equals(true, Maps.containsKey(map, key1));
96 Expect.equals(true, Maps.containsValue(map, value1)); 97 Expect.equals(true, Maps.containsValue(map, value1));
97 98
98 // Test Map.forEach. 99 // Test Map.forEach.
99 Map other_map = new Map(); 100 Map other_map = new Map();
100 void testForEachMap(key, value) { 101 void testForEachMap(key, value) {
101 other_map[key] = value; 102 other_map[key] = value;
102 } 103 }
104
103 Maps.forEach(map, testForEachMap); 105 Maps.forEach(map, testForEachMap);
104 Expect.equals(true, other_map.containsKey(key1)); 106 Expect.equals(true, other_map.containsKey(key1));
105 Expect.equals(true, other_map.containsKey(key2)); 107 Expect.equals(true, other_map.containsKey(key2));
106 Expect.equals(true, other_map.containsValue(value1)); 108 Expect.equals(true, other_map.containsValue(value1));
107 Expect.equals(true, other_map.containsValue(value2)); 109 Expect.equals(true, other_map.containsValue(value2));
108 Expect.equals(2, Maps.length(other_map)); 110 Expect.equals(2, Maps.length(other_map));
109 111
110 // Test Collection.values. 112 // Test Collection.values.
111 void testForEachCollection(value) { 113 void testForEachCollection(value) {
112 other_map[value] = value; 114 other_map[value] = value;
113 } 115 }
116
114 Iterable values = Maps.getValues(map); 117 Iterable values = Maps.getValues(map);
115 other_map = new Map(); 118 other_map = new Map();
116 values.forEach(testForEachCollection); 119 values.forEach(testForEachCollection);
117 Expect.equals(true, !other_map.containsKey(key1)); 120 Expect.equals(true, !other_map.containsKey(key1));
118 Expect.equals(true, !other_map.containsKey(key2)); 121 Expect.equals(true, !other_map.containsKey(key2));
119 Expect.equals(true, !other_map.containsValue(key1)); 122 Expect.equals(true, !other_map.containsValue(key1));
120 Expect.equals(true, !other_map.containsValue(key2)); 123 Expect.equals(true, !other_map.containsValue(key2));
121 Expect.equals(true, other_map.containsKey(value1)); 124 Expect.equals(true, other_map.containsKey(value1));
122 Expect.equals(true, other_map.containsKey(value2)); 125 Expect.equals(true, other_map.containsKey(value2));
123 Expect.equals(true, other_map.containsValue(value1)); 126 Expect.equals(true, other_map.containsValue(value1));
124 Expect.equals(true, other_map.containsValue(value2)); 127 Expect.equals(true, other_map.containsValue(value2));
125 Expect.equals(2, other_map.length); 128 Expect.equals(2, other_map.length);
126 other_map.clear(); 129 other_map.clear();
127 130
128 // Test Map.putIfAbsent. 131 // Test Map.putIfAbsent.
129 map.clear(); 132 map.clear();
130 Expect.equals(false, Maps.containsKey(map, key1)); 133 Expect.equals(false, Maps.containsKey(map, key1));
131 Maps.putIfAbsent(map, key1, () => 10); 134 Maps.putIfAbsent(map, key1, () => 10);
132 Expect.equals(true, map.containsKey(key1)); 135 Expect.equals(true, map.containsKey(key1));
133 Expect.equals(10, map[key1]); 136 Expect.equals(10, map[key1]);
134 Expect.equals(10, Maps.putIfAbsent(map, key1, () => 11)); 137 Expect.equals(10, Maps.putIfAbsent(map, key1, () => 11));
135 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698