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

Side by Side Diff: tests/standalone_2/float_array_test.dart

Issue 2984363004: Migrate first block of tests in standalone to standalone_2 (Closed)
Patch Set: Address review comments. 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
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 // Dart test program for testing native float arrays. 5 // Dart test program for testing native float arrays.
6 6
7 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation 7 // VMOptions=--optimization_counter_threshold=10 --no-background_compilation
8 8
9 // Library tag to be able to run in html test framework. 9 // Library tag to be able to run in html test framework.
10 library FloatArrayTest; 10 library FloatArrayTest;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Expect.throws(() { 63 Expect.throws(() {
64 floatArray.setRange(3, 4, list); 64 floatArray.setRange(3, 4, list);
65 }); 65 });
66 } 66 }
67 67
68 void testIndexOf32() { 68 void testIndexOf32() {
69 var list = new Float32List(10); 69 var list = new Float32List(10);
70 for (int i = 0; i < list.length; i++) { 70 for (int i = 0; i < list.length; i++) {
71 list[i] = i + 10.0; 71 list[i] = i + 10.0;
72 } 72 }
73 Expect.equals(0, list.indexOf(10));
74 Expect.equals(5, list.indexOf(15));
75 Expect.equals(9, list.indexOf(19));
76 Expect.equals(-1, list.indexOf(20));
77
78 list = new Float32List(10);
79 for (int i = 0; i < list.length; i++) {
80 list[i] = i + 10.0;
81 }
82 Expect.equals(0, list.indexOf(10.0)); 73 Expect.equals(0, list.indexOf(10.0));
83 Expect.equals(5, list.indexOf(15.0)); 74 Expect.equals(5, list.indexOf(15.0));
84 Expect.equals(9, list.indexOf(19.0)); 75 Expect.equals(9, list.indexOf(19.0));
85 Expect.equals(-1, list.indexOf(20.0)); 76 Expect.equals(-1, list.indexOf(20.0));
86 } 77 }
87 78
88 void testBadValues32() {
89 var list = new Float32List(10);
90 list[0] = 2.0;
91 Expect.throws(() {
92 list[0] = 2;
93 });
94 Expect.throws(() {
95 list[0] = "hello";
96 });
97 }
98
99 void testCreateFloat64Array() { 79 void testCreateFloat64Array() {
100 Float64List floatArray; 80 Float64List floatArray;
101 81
102 floatArray = new Float64List(0); 82 floatArray = new Float64List(0);
103 Expect.equals(0, floatArray.length); 83 Expect.equals(0, floatArray.length);
104 84
105 floatArray = new Float64List(10); 85 floatArray = new Float64List(10);
106 Expect.equals(10, floatArray.length); 86 Expect.equals(10, floatArray.length);
107 for (int i = 0; i < 10; i++) { 87 for (int i = 0; i < 10; i++) {
108 Expect.equals(0.0, floatArray[i]); 88 Expect.equals(0.0, floatArray[i]);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 Expect.throws(() { 127 Expect.throws(() {
148 floatArray.setRange(3, 4, list); 128 floatArray.setRange(3, 4, list);
149 }); 129 });
150 } 130 }
151 131
152 void testIndexOf64() { 132 void testIndexOf64() {
153 var list = new Float64List(10); 133 var list = new Float64List(10);
154 for (int i = 0; i < list.length; i++) { 134 for (int i = 0; i < list.length; i++) {
155 list[i] = i + 10.0; 135 list[i] = i + 10.0;
156 } 136 }
157 Expect.equals(0, list.indexOf(10));
158 Expect.equals(5, list.indexOf(15));
159 Expect.equals(9, list.indexOf(19));
160 Expect.equals(-1, list.indexOf(20));
161
162 list = new Float64List(10);
163 for (int i = 0; i < list.length; i++) {
164 list[i] = i + 10.0;
165 }
166 Expect.equals(0, list.indexOf(10.0)); 137 Expect.equals(0, list.indexOf(10.0));
167 Expect.equals(5, list.indexOf(15.0)); 138 Expect.equals(5, list.indexOf(15.0));
168 Expect.equals(9, list.indexOf(19.0)); 139 Expect.equals(9, list.indexOf(19.0));
169 Expect.equals(-1, list.indexOf(20.0)); 140 Expect.equals(-1, list.indexOf(20.0));
170 } 141 }
171 142
172 void testBadValues64() {
173 var list = new Float64List(10);
174 list[0] = 2.0;
175 Expect.throws(() {
176 list[0] = 2;
177 });
178 Expect.throws(() {
179 list[0] = "hello";
180 });
181 }
182
183 storeIt32(Float32List a, int index, value) { 143 storeIt32(Float32List a, int index, value) {
184 a[index] = value; 144 a[index] = value;
185 } 145 }
186 146
187 storeIt64(Float64List a, int index, value) { 147 storeIt64(Float64List a, int index, value) {
188 a[index] = value; 148 a[index] = value;
189 } 149 }
190 150
191 testPolymorphicLoad(var list) { 151 testPolymorphicLoad(var list) {
192 return list[0]; 152 return list[0];
(...skipping 16 matching lines...) Expand all
209 testIndexOutOfRange64(); 169 testIndexOutOfRange64();
210 testIndexOf64(); 170 testIndexOf64();
211 storeIt64(a64, 1, 2.0); 171 storeIt64(a64, 1, 2.0);
212 testPolymorphicLoad(a64); 172 testPolymorphicLoad(a64);
213 } 173 }
214 var f32x4 = new Float32x4List(5); 174 var f32x4 = new Float32x4List(5);
215 for (int i = 0; i < 20; i++) { 175 for (int i = 0; i < 20; i++) {
216 testPolymorphicLoad(f32x4); 176 testPolymorphicLoad(f32x4);
217 } 177 }
218 178
219 // These two take a long time in checked mode.
220 testBadValues32();
221 testBadValues64();
222 // Check optimized (inlined) version of []= 179 // Check optimized (inlined) version of []=
223 Expect.throws(() { 180 Expect.throws(() {
224 storeIt32(a32, 1, 2); 181 storeIt32(a32, 1, 2);
225 }); 182 });
226 Expect.throws(() { 183 Expect.throws(() {
227 storeIt64(a64, 1, 2); 184 storeIt64(a64, 1, 2);
228 }); 185 });
229 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698