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

Side by Side Diff: tests/corelib/src/ListFromListTest.dart

Issue 8422005: Remove List.fromList constructor, and List.copyFrom. They are duplicates of the new range methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« runtime/lib/array.dart ('K') | « tests/co19/co19-runtime.status ('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) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class ListFromListTest {
6
7 static testMain() {
8 var list = [1, 2, 4];
9
10 var sub = new List.fromList(list, 0, 3);
11 Expect.equals(3, sub.length);
12 Expect.equals(1, sub[0]);
13 Expect.equals(2, sub[1]);
14 Expect.equals(4, sub[2]);
15
16 sub = new List.fromList(list, 1, 3);
17 Expect.equals(2, sub.length);
18 Expect.equals(2, sub[0]);
19 Expect.equals(4, sub[1]);
20
21 sub = new List.fromList(list, 2, 3);
22 Expect.equals(1, sub.length);
23 Expect.equals(4, sub[0]);
24
25 sub = new List.fromList(list, 0, 0);
26 Expect.equals(0, sub.length);
27
28 sub = new List.fromList(list, 3, 3);
29 Expect.equals(0, sub.length);
30
31 sub = new List.fromList(list, 0, 1);
32 Expect.equals(1, sub.length);
33 Expect.equals(1, sub[0]);
34
35 sub = new List.fromList(list, 0, 2);
36 Expect.equals(2, sub.length);
37 Expect.equals(1, sub[0]);
38 Expect.equals(2, sub[1]);
39
40 sub = new List.fromList(list, 1, 2);
41 Expect.equals(1, sub.length);
42 Expect.equals(2, sub[0]);
43
44 sub = new List.fromList(list, -1, 2);
45 Expect.equals(2, sub.length);
46 Expect.equals(1, sub[0]);
47 Expect.equals(2, sub[1]);
48
49 sub = new List.fromList(list, 1, 5);
50 Expect.equals(2, sub.length);
51 Expect.equals(2, sub[0]);
52 Expect.equals(4, sub[1]);
53
54 list = [];
55 sub = new List.fromList(list, 1, 5);
56 Expect.equals(0, sub.length);
57
58 sub = new List.fromList(list, 0, 0);
59 Expect.equals(0, sub.length);
60
61 sub = new List.fromList(list, 0, 1);
62 Expect.equals(0, sub.length);
63
64 // Test that the original list is unchanged after modifications
65 // to the list.
66 list = [1, 2, 4];
67 sub = new List.fromList(list, 0, 3);
68 sub[0] = 42;
69 Expect.equals(1, list[0]);
70 Expect.equals(42, sub[0]);
71
72 sub.add(42);
73 Expect.equals(4, sub.length);
74 Expect.equals(3, list.length);
75
76 list.add(43);
77 Expect.equals(4, sub.length);
78 Expect.equals(4, list.length);
79
80 Expect.equals(42, sub[3]);
81 Expect.equals(43, list[3]);
82 }
83 }
84
85 main() {
86 ListFromListTest.testMain();
87 }
OLDNEW
« runtime/lib/array.dart ('K') | « tests/co19/co19-runtime.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698