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

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

Issue 10553034: Stop mapping indexOf/lastIndexOf directly to the JavaScript native on indexable primitives. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/ssa/codegen.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
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 class ListTest { 5 class ListTest {
6 6
7 static testMain() { 7 static testMain() {
8 testList(); 8 testList();
9 testExpandableList(); 9 testExpandableList();
10 } 10 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 expectValues(list, 4, val, null, null); 58 expectValues(list, 4, val, null, null);
59 double d = 2.0; 59 double d = 2.0;
60 list[3] = d; 60 list[3] = d;
61 expectValues(list, 4, val, null, d); 61 expectValues(list, 4, val, null, d);
62 62
63 for (int i = 0; i < list.length; i++) { 63 for (int i = 0; i < list.length; i++) {
64 list[i] = i; 64 list[i] = i;
65 } 65 }
66 66
67 for (int i = 0; i < 4; i++) { 67 for (int i = 0; i < 4; i++) {
68 Expect.equals(list[i], i); 68 Expect.equals(i, list[i]);
69 Expect.equals(i, list.indexOf(i));
70 Expect.equals(i, list.lastIndexOf(i));
69 } 71 }
70 72
73 Expect.equals(-1, list.indexOf(100));
74 Expect.equals(-1, list.lastIndexOf(100));
75 list[2] = new Yes();
76 Expect.equals(2, list.indexOf(100));
77 Expect.equals(2, list.lastIndexOf(100));
78 list[3] = new Yes();
79 Expect.equals(2, list.indexOf(100));
80 Expect.equals(3, list.lastIndexOf(100));
81 list[2] = 2;
82 Expect.equals(3, list.indexOf(100));
83 Expect.equals(3, list.lastIndexOf(100));
84 list[3] = 3;
85 Expect.equals(-1, list.indexOf(100));
86 Expect.equals(-1, list.lastIndexOf(100));
87
71 testClosures(list); 88 testClosures(list);
72 89
73 var exception = null; 90 var exception = null;
74 try { 91 try {
75 list.clear(); 92 list.clear();
76 } catch (UnsupportedOperationException e) { 93 } catch (UnsupportedOperationException e) {
77 exception = e; 94 exception = e;
78 } 95 }
79 Expect.equals(true, exception != null); 96 Expect.equals(true, exception != null);
80 } 97 }
81 98
82 static void testExpandableList() { 99 static void testExpandableList() {
83 List list = new List(); 100 List list = new List();
84 Expect.equals(true, list.isEmpty()); 101 Expect.equals(true, list.isEmpty());
85 Expect.equals(list.length, 0); 102 Expect.equals(list.length, 0);
86 list.add(4); 103 list.add(4);
87 Expect.equals(1, list.length); 104 Expect.equals(1, list.length);
88 Expect.equals(true, !list.isEmpty()); 105 Expect.equals(true, !list.isEmpty());
89 Expect.equals(list.length, 1); 106 Expect.equals(list.length, 1);
90 Expect.equals(list.length, 1); 107 Expect.equals(list.length, 1);
91 Expect.equals(list.removeLast(), 4); 108 Expect.equals(list.removeLast(), 4);
92 109
93 for (int i = 0; i < 10; i++) { 110 for (int i = 0; i < 10; i++) {
94 list.add(i); 111 list.add(i);
95 } 112 }
96 113
97 Expect.equals(list.length, 10); 114 Expect.equals(list.length, 10);
98 for (int i = 0; i < 10; i++) { 115 for (int i = 0; i < 10; i++) {
99 Expect.equals(list[i], i); 116 Expect.equals(i, list[i]);
117 Expect.equals(i, list.indexOf(i));
118 Expect.equals(i, list.lastIndexOf(i));
100 } 119 }
101 120
121 Expect.equals(-1, list.indexOf(100));
122 Expect.equals(-1, list.lastIndexOf(100));
123 list[2] = new Yes();
124 Expect.equals(2, list.indexOf(100));
125 Expect.equals(2, list.lastIndexOf(100));
126 list[3] = new Yes();
127 Expect.equals(2, list.indexOf(100));
128 Expect.equals(3, list.lastIndexOf(100));
129 list[2] = 2;
130 Expect.equals(3, list.indexOf(100));
131 Expect.equals(3, list.lastIndexOf(100));
132 list[3] = 3;
133 Expect.equals(-1, list.indexOf(100));
134 Expect.equals(-1, list.lastIndexOf(100));
135
102 testClosures(list); 136 testClosures(list);
103 137
104 Expect.equals(list.removeLast(), 9); 138 Expect.equals(list.removeLast(), 9);
105 list.clear(); 139 list.clear();
106 Expect.equals(list.length, 0); 140 Expect.equals(list.length, 0);
107 Expect.equals(list.length, 0); 141 Expect.equals(list.length, 0);
108 Expect.equals(true, list.isEmpty()); 142 Expect.equals(true, list.isEmpty());
109 } 143 }
110 } 144 }
111 145
146 class Yes {
147 operator ==(var other) => true;
148 }
149
112 main() { 150 main() {
113 ListTest.testMain(); 151 ListTest.testMain();
114 } 152 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698