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

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

Issue 2765693002: Update all tests (Closed)
Patch Set: Created 3 years, 9 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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" show Queue; 5 import "dart:collection" show Queue;
6 import "dart:typed_data" show Uint8List, Float32List; 6 import "dart:typed_data" show Uint8List, Float32List;
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 main() { 9 main() {
10 // testIterable takes an iterable and a list expected to be equal to 10 // testIterable takes an iterable and a list expected to be equal to
(...skipping 10 matching lines...) Expand all
21 testIterable({"x": 2, "y": 3}.values, [2, 3]); 21 testIterable({"x": 2, "y": 3}.values, [2, 3]);
22 testIterable(<String, int>{"x": 2, "y": 3}.values, <int>[2, 3]); 22 testIterable(<String, int>{"x": 2, "y": 3}.values, <int>[2, 3]);
23 testIterable(new Iterable.generate(3), [0, 1, 2]); 23 testIterable(new Iterable.generate(3), [0, 1, 2]);
24 testIterable(new Iterable<int>.generate(3), <int>[0, 1, 2]); 24 testIterable(new Iterable<int>.generate(3), <int>[0, 1, 2]);
25 testIterable(new Iterable<String>.generate(3, (x)=>"$x"), 25 testIterable(new Iterable<String>.generate(3, (x)=>"$x"),
26 <String>["0", "1", "2"]); 26 <String>["0", "1", "2"]);
27 testIterable(new Set.from([1, 2, 3]), [1, 2, 3]); 27 testIterable(new Set.from([1, 2, 3]), [1, 2, 3]);
28 testIterable(new Set<int>.from([1, 2, 3]), <int>[1, 2, 3]); 28 testIterable(new Set<int>.from([1, 2, 3]), <int>[1, 2, 3]);
29 testIterable(new Queue.from([1, 2, 3]), [1, 2, 3]); 29 testIterable(new Queue.from([1, 2, 3]), [1, 2, 3]);
30 testIterable(new Queue<int>.from(<int>[1, 2, 3]), <int>[1, 2, 3]); 30 testIterable(new Queue<int>.from(<int>[1, 2, 3]), <int>[1, 2, 3]);
31 testIterable(new Uint8List.fromList(<int>[1, 2, 3]), /// 01: ok 31 testIterable(new Uint8List.fromList(<int>[1, 2, 3]), //# 01: ok
32 <int>[1, 2, 3]); /// 01: continued 32 <int>[1, 2, 3]); //# 01: continued
33 testIterable(new Float32List.fromList([1.0, 2.0, 3.0]), /// 01: continued 33 testIterable(new Float32List.fromList([1.0, 2.0, 3.0]), //# 01: continued
34 <double>[1.0, 2.0, 3.0]); /// 01: continued 34 <double>[1.0, 2.0, 3.0]); //# 01: continued
35 testIterable("abc".codeUnits, <int>[97, 98, 99]); /// 01: continued 35 testIterable("abc".codeUnits, <int>[97, 98, 99]); //# 01: continued
36 testIterable("abc".runes, <int>[97, 98, 99]); 36 testIterable("abc".runes, <int>[97, 98, 99]);
37 } 37 }
38 38
39 testIterable(Iterable iterable, List expected, [int depth = 0]) { 39 testIterable(Iterable iterable, List expected, [int depth = 0]) {
40 print(" " * depth + "${iterable.runtimeType} vs ${expected.runtimeType}"); 40 print(" " * depth + "${iterable.runtimeType} vs ${expected.runtimeType}");
41 test(iterable, expected); 41 test(iterable, expected);
42 test(iterable, expected, growable: true); 42 test(iterable, expected, growable: true);
43 test(iterable, expected, growable: false); 43 test(iterable, expected, growable: false);
44 if (depth < 2) { 44 if (depth < 2) {
45 depth++; 45 depth++;
(...skipping 16 matching lines...) Expand all
62 Expect.equals(expected is List<double>, list is List<double>, "double"); 62 Expect.equals(expected is List<double>, list is List<double>, "double");
63 Expect.equals(expected is List<String>, list is List<String>, "str"); 63 Expect.equals(expected is List<String>, list is List<String>, "str");
64 if (growable) { 64 if (growable) {
65 int length = list.length; 65 int length = list.length;
66 list.add(null); 66 list.add(null);
67 Expect.equals(length + 1, list.length); 67 Expect.equals(length + 1, list.length);
68 } else { 68 } else {
69 Expect.throws(() { list.add(null); }); 69 Expect.throws(() { list.add(null); });
70 } 70 }
71 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698