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

Side by Side Diff: tests/corelib/list_as_map_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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 void testListMapCorrespondence(List list, Map map) { 7 void testListMapCorrespondence(List list, Map map) {
8 Expect.equals(list.length, map.length); 8 Expect.equals(list.length, map.length);
9 for (int i = 0; i < list.length; i++) { 9 for (int i = 0; i < list.length; i++) {
10 Expect.equals(list[i], map[i]); 10 Expect.equals(list[i], map[i]);
(...skipping 29 matching lines...) Expand all
40 Expect.equals(list.length, forEachCount); 40 Expect.equals(list.length, forEachCount);
41 41
42 Expect.equals(list.isEmpty, map.isEmpty); 42 Expect.equals(list.isEmpty, map.isEmpty);
43 } 43 }
44 44
45 void testConstAsMap(List list) { 45 void testConstAsMap(List list) {
46 Map<int, dynamic> map = list.asMap(); 46 Map<int, dynamic> map = list.asMap();
47 47
48 testListMapCorrespondence(list, map); 48 testListMapCorrespondence(list, map);
49 49
50 Expect.throws(() => map[0] = 499, 50 Expect.throws(() => map[0] = 499, (e) => e is UnsupportedError);
51 (e) => e is UnsupportedError); 51 Expect.throws(
52 Expect.throws(() => map.putIfAbsent(0, () => 499), 52 () => map.putIfAbsent(0, () => 499), (e) => e is UnsupportedError);
53 (e) => e is UnsupportedError); 53 Expect.throws(() => map.clear(), (e) => e is UnsupportedError);
54 Expect.throws(() => map.clear(),
55 (e) => e is UnsupportedError);
56 } 54 }
57 55
58 void testFixedAsMap(List list) { 56 void testFixedAsMap(List list) {
59 testConstAsMap(list); 57 testConstAsMap(list);
60 58
61 Map<int, dynamic> map = list.asMap(); 59 Map<int, dynamic> map = list.asMap();
62 60
63 if (!list.isEmpty) { 61 if (!list.isEmpty) {
64 list[0] = 499; 62 list[0] = 499;
65 // Check again to make sure the map is backed by the list. 63 // Check again to make sure the map is backed by the list.
(...skipping 23 matching lines...) Expand all
89 testConstAsMap(const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 87 testConstAsMap(const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
90 testAsMap([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 88 testAsMap([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
91 List list = new List(10); 89 List list = new List(10);
92 for (int i = 0; i < 10; i++) list[i] = i + 1; 90 for (int i = 0; i < 10; i++) list[i] = i + 1;
93 testFixedAsMap(list); 91 testFixedAsMap(list);
94 92
95 testConstAsMap(const []); 93 testConstAsMap(const []);
96 testAsMap([]); 94 testAsMap([]);
97 testFixedAsMap(new List(0)); 95 testFixedAsMap(new List(0));
98 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698