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

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

Issue 2996553002: Removed tests that have already been migrated as part of block 13. (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « tests/corelib/list_get_range_test.dart ('k') | no next file » | 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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6 import "dart:collection";
7
8 test(List list, int index, Iterable iterable) {
9 List copy = list.toList();
10 list.insertAll(index, iterable);
11 List iterableList = iterable.toList();
12 Expect.equals(copy.length + iterableList.length, list.length);
13 for (int i = 0; i < index; i++) {
14 Expect.equals(copy[i], list[i]);
15 }
16 for (int i = 0; i < iterableList.length; i++) {
17 Expect.equals(iterableList[i], list[i + index]);
18 }
19 for (int i = index + iterableList.length; i < copy.length; i++) {
20 Expect.equals(copy[i], list[i + iterableList.length]);
21 }
22 }
23
24 class MyList extends ListBase {
25 List list;
26 MyList(this.list);
27 get length => list.length;
28 set length(value) {
29 list.length = value;
30 }
31
32 operator [](index) => list[index];
33 operator []=(index, val) {
34 list[index] = val;
35 }
36
37 toString() => list.toString();
38 }
39
40 main() {
41 test([1, 2, 3], 0, [4, 5]);
42 test([1, 2, 3], 1, [4, 5]);
43 test([1, 2, 3], 2, [4, 5]);
44 test([1, 2, 3], 3, [4, 5]);
45 test([1, 2, 3], 2, [4]);
46 test([1, 2, 3], 3, []);
47 test([1, 2, 3], 0, [4, 5].map((x) => x));
48 test([1, 2, 3], 1, [4, 5].map((x) => x));
49 test([1, 2, 3], 2, [4, 5].map((x) => x));
50 test([1, 2, 3], 3, [4, 5].map((x) => x));
51 test([1, 2, 3], 2, [4].map((x) => x));
52 test([1, 2, 3], 3, [].map((x) => x));
53 test([1, 2, 3], 0, const [4, 5]);
54 test([1, 2, 3], 1, const [4, 5]);
55 test([1, 2, 3], 2, const [4, 5]);
56 test([1, 2, 3], 3, const [4, 5]);
57 test([1, 2, 3], 2, const [4]);
58 test([1, 2, 3], 3, const []);
59 test([1, 2, 3], 0, new Iterable.generate(2, (x) => x + 4));
60 test([1, 2, 3], 1, new Iterable.generate(2, (x) => x + 4));
61 test([1, 2, 3], 2, new Iterable.generate(2, (x) => x + 4));
62 test([1, 2, 3], 3, new Iterable.generate(2, (x) => x + 4));
63 test([1, 2, 3], 2, new Iterable.generate(1, (x) => x + 4));
64 test([1, 2, 3], 3, new Iterable.generate(0, (x) => x + 4));
65 test(new MyList([1, 2, 3]), 0, [4, 5]);
66 test(new MyList([1, 2, 3]), 1, [4, 5]);
67 test(new MyList([1, 2, 3]), 2, [4]);
68 test(new MyList([1, 2, 3]), 3, []);
69 test(new MyList([1, 2, 3]), 2, [4, 5]);
70 test(new MyList([1, 2, 3]), 3, [4, 5]);
71 test(new MyList([1, 2, 3]), 0, [4, 5].map((x) => x));
72 test(new MyList([1, 2, 3]), 1, [4, 5].map((x) => x));
73 test(new MyList([1, 2, 3]), 2, [4, 5].map((x) => x));
74 test(new MyList([1, 2, 3]), 3, [4, 5].map((x) => x));
75 test(new MyList([1, 2, 3]), 2, [4].map((x) => x));
76 test(new MyList([1, 2, 3]), 3, [].map((x) => x));
77
78 expectRE(() => test([1, 2, 3], -1, [4, 5]));
79 expectUE(() => test([1, 2, 3].toList(growable: false), -1, [4, 5]));
80 expectRE(() => test(new MyList([1, 2, 3]), -1, [4, 5]));
81 expectUE(() => test([1, 2, 3].toList(growable: false), 0, [4, 5]));
82 }
83
84 void expectRE(Function f) {
85 Expect.throws(f, (e) => e is RangeError);
86 }
87
88 void expectUE(Function f) {
89 Expect.throws(f, (e) => e is UnsupportedError);
90 }
OLDNEW
« no previous file with comments | « tests/corelib/list_get_range_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698