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

Side by Side Diff: tests/standalone/typed_array_test.dart

Issue 1477043002: Fix tests that don't catch asynchronous errors from isolate spawning. Update co19 status. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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/standalone/typed_array_int64_uint64_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
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 and int arrays. 64-bit int arrays 5 // Dart test program for testing native float and int arrays. 64-bit int arrays
6 // are in a separate test. 6 // are in a separate test.
7 7
8 // Library tag to be able to run in html test framework. 8 // Library tag to be able to run in html test framework.
9 library TypedArray; 9 library TypedArray;
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import 'package:async_helper/async_helper.dart';
11 import 'dart:isolate'; 12 import 'dart:isolate';
12 import 'dart:typed_data'; 13 import 'dart:typed_data';
13 14
14 void main() { 15 void main() {
15 int8_receiver(); 16 test(int8_receiver);
16 uint8_receiver(); 17 test(uint8_receiver);
17 int16_receiver(); 18 test(int16_receiver);
18 uint16_receiver(); 19 test(uint16_receiver);
19 int32_receiver(); 20 test(int32_receiver);
20 uint32_receiver(); 21 test(uint32_receiver);
21 // int64 and uint64 in separate test. 22 // int64 and uint64 in separate test.
22 float32_receiver(); 23 test(float32_receiver);
23 float64_receiver(); 24 test(float64_receiver);
25 }
26
27 test(f) {
28 asyncStart();
29 return f().whenComplete(asyncEnd);
24 } 30 }
25 31
26 // Int8 array. 32 // Int8 array.
27 Int8List initInt8() { 33 Int8List initInt8() {
28 var int8 = new Int8List(2); 34 var int8 = new Int8List(2);
29 int8[0] = 10; 35 int8[0] = 10;
30 int8[1] = 100; 36 int8[1] = 100;
31 return int8; 37 return int8;
32 } 38 }
33 Int8List int8 = initInt8(); 39 Int8List int8 = initInt8();
34 40
35 void int8_receiver() { 41 int8_receiver() {
36 var response = new ReceivePort(); 42 var response = new ReceivePort();
37 var remote = Isolate.spawn(int8_sender, [int8.length, response.sendPort]); 43 var remote = Isolate.spawn(int8_sender, [int8.length, response.sendPort]);
38 response.first.then((a) { 44 asyncStart();
45 return response.first.then((a) {
39 Expect.equals(int8.length, a.length); 46 Expect.equals(int8.length, a.length);
40 for (int i = 0; i < a.length; i++) { 47 for (int i = 0; i < a.length; i++) {
41 Expect.equals(int8[i], a[i]); 48 Expect.equals(int8[i], a[i]);
42 } 49 }
43 print("int8_receiver"); 50 print("int8_receiver");
51 asyncEnd();
44 }); 52 });
45 } 53 }
46 54
47 int8_sender(message) { 55 int8_sender(message) {
48 var len = message[0]; 56 var len = message[0];
49 var r = message[1]; 57 var r = message[1];
50 Expect.equals(int8.length, len); 58 Expect.equals(int8.length, len);
51 var a = new Int8List(len); 59 var a = new Int8List(len);
52 for (int i = 0; i < len; i++) { 60 for (int i = 0; i < len; i++) {
53 a[i] = int8[i]; 61 a[i] = int8[i];
54 } 62 }
55 r.send(a); 63 r.send(a);
56 } 64 }
57 65
58 66
59 // Uint8 array. 67 // Uint8 array.
60 Uint8List initUint8() { 68 Uint8List initUint8() {
61 var uint8 = new Uint8List(2); 69 var uint8 = new Uint8List(2);
62 uint8[0] = 0xff; 70 uint8[0] = 0xff;
63 uint8[1] = 0x7f; 71 uint8[1] = 0x7f;
64 return uint8; 72 return uint8;
65 } 73 }
66 Uint8List uint8 = initUint8(); 74 Uint8List uint8 = initUint8();
67 75
68 void uint8_receiver() { 76 uint8_receiver() {
69 var response = new ReceivePort(); 77 var response = new ReceivePort();
70 var remote = Isolate.spawn(uint8_sender, [uint8.length, response.sendPort]); 78 var remote = Isolate.spawn(uint8_sender, [uint8.length, response.sendPort]);
71 response.first.then((a) { 79 asyncStart();
80 return response.first.then((a) {
72 Expect.equals(uint8.length, a.length); 81 Expect.equals(uint8.length, a.length);
73 for (int i = 0; i < a.length; i++) { 82 for (int i = 0; i < a.length; i++) {
74 Expect.equals(uint8[i], a[i]); 83 Expect.equals(uint8[i], a[i]);
75 } 84 }
76 print("uint8_receiver"); 85 print("uint8_receiver");
86 asyncEnd();
77 }); 87 });
78 } 88 }
79 89
80 uint8_sender(message) { 90 uint8_sender(message) {
81 var len = message[0]; 91 var len = message[0];
82 var r = message[1]; 92 var r = message[1];
83 Expect.equals(uint8.length, len); 93 Expect.equals(uint8.length, len);
84 var a = new Uint8List(len); 94 var a = new Uint8List(len);
85 for (int i = 0; i < len; i++) { 95 for (int i = 0; i < len; i++) {
86 a[i] = uint8[i]; 96 a[i] = uint8[i];
87 } 97 }
88 r.send(a); 98 r.send(a);
89 } 99 }
90 100
91 101
92 // Int16 array. 102 // Int16 array.
93 Int16List initInt16() { 103 Int16List initInt16() {
94 var int16 = new Int16List(2); 104 var int16 = new Int16List(2);
95 int16[0] = 1000; 105 int16[0] = 1000;
96 int16[1] = 10000; 106 int16[1] = 10000;
97 return int16; 107 return int16;
98 } 108 }
99 Int16List int16 = initInt16(); 109 Int16List int16 = initInt16();
100 110
101 void int16_receiver() { 111 int16_receiver() {
102 var response = new ReceivePort(); 112 var response = new ReceivePort();
103 var remote = Isolate.spawn(int16_sender, [int16.length, response.sendPort]); 113 var remote = Isolate.spawn(int16_sender, [int16.length, response.sendPort]);
104 response.first.then((a) { 114 asyncStart();
115 return response.first.then((a) {
105 Expect.equals(int16.length, a.length); 116 Expect.equals(int16.length, a.length);
106 for (int i = 0; i < a.length; i++) { 117 for (int i = 0; i < a.length; i++) {
107 Expect.equals(int16[i], a[i]); 118 Expect.equals(int16[i], a[i]);
108 } 119 }
109 print("int16_receiver"); 120 print("int16_receiver");
121 asyncEnd();
110 }); 122 });
111 } 123 }
112 124
113 int16_sender(message) { 125 int16_sender(message) {
114 var len = message[0]; 126 var len = message[0];
115 var r = message[1]; 127 var r = message[1];
116 Expect.equals(int16.length, len); 128 Expect.equals(int16.length, len);
117 var a = new Int16List(len); 129 var a = new Int16List(len);
118 for (int i = 0; i < len; i++) { 130 for (int i = 0; i < len; i++) {
119 a[i] = int16[i]; 131 a[i] = int16[i];
120 } 132 }
121 r.send(a); 133 r.send(a);
122 } 134 }
123 135
124 136
125 // Uint16 array. 137 // Uint16 array.
126 Uint16List initUint16() { 138 Uint16List initUint16() {
127 var uint16 = new Uint16List(2); 139 var uint16 = new Uint16List(2);
128 uint16[0] = 0xffff; 140 uint16[0] = 0xffff;
129 uint16[1] = 0x7fff; 141 uint16[1] = 0x7fff;
130 return uint16; 142 return uint16;
131 } 143 }
132 Uint16List uint16 = initUint16(); 144 Uint16List uint16 = initUint16();
133 145
134 void uint16_receiver() { 146 uint16_receiver() {
135 var response = new ReceivePort(); 147 var response = new ReceivePort();
136 var remote = Isolate.spawn(uint16_sender, [uint16.length, response.sendPort]); 148 var remote = Isolate.spawn(uint16_sender, [uint16.length, response.sendPort]);
137 response.first.then((a) { 149 asyncStart();
150 return response.first.then((a) {
138 Expect.equals(uint16.length, a.length); 151 Expect.equals(uint16.length, a.length);
139 for (int i = 0; i < a.length; i++) { 152 for (int i = 0; i < a.length; i++) {
140 Expect.equals(uint16[i], a[i]); 153 Expect.equals(uint16[i], a[i]);
141 } 154 }
142 print("uint16_receiver"); 155 print("uint16_receiver");
156 asyncEnd();
143 }); 157 });
144 } 158 }
145 159
146 uint16_sender(message) { 160 uint16_sender(message) {
147 var len = message[0]; 161 var len = message[0];
148 var r = message[1]; 162 var r = message[1];
149 Expect.equals(uint16.length, len); 163 Expect.equals(uint16.length, len);
150 var a = new Uint16List(len); 164 var a = new Uint16List(len);
151 for (int i = 0; i < len; i++) { 165 for (int i = 0; i < len; i++) {
152 a[i] = uint16[i]; 166 a[i] = uint16[i];
153 } 167 }
154 r.send(a); 168 r.send(a);
155 } 169 }
156 170
157 171
158 // Int32 array. 172 // Int32 array.
159 Int32List initInt32() { 173 Int32List initInt32() {
160 var int32 = new Int32List(2); 174 var int32 = new Int32List(2);
161 int32[0] = 100000; 175 int32[0] = 100000;
162 int32[1] = 1000000; 176 int32[1] = 1000000;
163 return int32; 177 return int32;
164 } 178 }
165 Int32List int32 = initInt32(); 179 Int32List int32 = initInt32();
166 180
167 void int32_receiver() { 181 int32_receiver() {
168 var response = new ReceivePort(); 182 var response = new ReceivePort();
169 var remote = Isolate.spawn(int32_sender, [int32.length, response.sendPort]); 183 var remote = Isolate.spawn(int32_sender, [int32.length, response.sendPort]);
170 response.first.then((a) { 184 asyncStart();
185 return response.first.then((a) {
171 Expect.equals(int32.length, a.length); 186 Expect.equals(int32.length, a.length);
172 for (int i = 0; i < a.length; i++) { 187 for (int i = 0; i < a.length; i++) {
173 Expect.equals(int32[i], a[i]); 188 Expect.equals(int32[i], a[i]);
174 } 189 }
175 print("int32_receiver"); 190 print("int32_receiver");
191 asyncEnd();
176 }); 192 });
177 } 193 }
178 194
179 int32_sender(message) { 195 int32_sender(message) {
180 var len = message[0]; 196 var len = message[0];
181 var r = message[1]; 197 var r = message[1];
182 Expect.equals(int32.length, len); 198 Expect.equals(int32.length, len);
183 var a = new Int32List(len); 199 var a = new Int32List(len);
184 for (int i = 0; i < len; i++) { 200 for (int i = 0; i < len; i++) {
185 a[i] = int32[i]; 201 a[i] = int32[i];
186 } 202 }
187 r.send(a); 203 r.send(a);
188 } 204 }
189 205
190 206
191 // Uint32 array. 207 // Uint32 array.
192 Uint32List initUint32() { 208 Uint32List initUint32() {
193 var uint32 = new Uint32List(2); 209 var uint32 = new Uint32List(2);
194 uint32[0] = 0xffffffff; 210 uint32[0] = 0xffffffff;
195 uint32[1] = 0x7fffffff; 211 uint32[1] = 0x7fffffff;
196 return uint32; 212 return uint32;
197 } 213 }
198 Uint32List uint32 = initUint32(); 214 Uint32List uint32 = initUint32();
199 215
200 void uint32_receiver() { 216 uint32_receiver() {
201 var response = new ReceivePort(); 217 var response = new ReceivePort();
202 var remote = Isolate.spawn(uint32_sender, [uint32.length, response.sendPort]); 218 var remote = Isolate.spawn(uint32_sender, [uint32.length, response.sendPort]);
203 response.first.then((a) { 219 asyncStart();
220 return response.first.then((a) {
204 Expect.equals(uint32.length, a.length); 221 Expect.equals(uint32.length, a.length);
205 for (int i = 0; i < a.length; i++) { 222 for (int i = 0; i < a.length; i++) {
206 Expect.equals(uint32[i], a[i]); 223 Expect.equals(uint32[i], a[i]);
207 } 224 }
208 print("uint32_receiver"); 225 print("uint32_receiver");
226 asyncEnd();
209 }); 227 });
210 } 228 }
211 229
212 uint32_sender(message) { 230 uint32_sender(message) {
213 var len = message[0]; 231 var len = message[0];
214 var r = message[1]; 232 var r = message[1];
215 Expect.equals(uint32.length, len); 233 Expect.equals(uint32.length, len);
216 var a = new Uint32List(len); 234 var a = new Uint32List(len);
217 for (int i = 0; i < len; i++) { 235 for (int i = 0; i < len; i++) {
218 a[i] = uint32[i]; 236 a[i] = uint32[i];
219 } 237 }
220 r.send(a); 238 r.send(a);
221 } 239 }
222 240
223 241
224 // Float32 Array. 242 // Float32 Array.
225 Float32List initFloat32() { 243 Float32List initFloat32() {
226 var float32 = new Float32List(2); 244 var float32 = new Float32List(2);
227 float32[0] = 1.0; 245 float32[0] = 1.0;
228 float32[1] = 2.0; 246 float32[1] = 2.0;
229 return float32; 247 return float32;
230 } 248 }
231 Float32List float32 = initFloat32(); 249 Float32List float32 = initFloat32();
232 250
233 void float32_receiver() { 251 float32_receiver() {
234 var response = new ReceivePort(); 252 var response = new ReceivePort();
235 var remote = 253 var remote =
236 Isolate.spawn(float32_sender, [float32.length, response.sendPort]); 254 Isolate.spawn(float32_sender, [float32.length, response.sendPort]);
237 response.first.then((a) { 255 asyncStart();
256 return response.first.then((a) {
238 Expect.equals(float32.length, a.length); 257 Expect.equals(float32.length, a.length);
239 for (int i = 0; i < a.length; i++) { 258 for (int i = 0; i < a.length; i++) {
240 Expect.equals(float32[i], a[i]); 259 Expect.equals(float32[i], a[i]);
241 } 260 }
242 print("float32_receiver"); 261 print("float32_receiver");
262 asyncEnd();
243 }); 263 });
244 } 264 }
245 265
246 float32_sender(message) { 266 float32_sender(message) {
247 var len = message[0]; 267 var len = message[0];
248 var r = message[1]; 268 var r = message[1];
249 Expect.equals(float32.length, len); 269 Expect.equals(float32.length, len);
250 var a = new Float32List(len); 270 var a = new Float32List(len);
251 for (int i = 0; i < len; i++) { 271 for (int i = 0; i < len; i++) {
252 a[i] = float32[i]; 272 a[i] = float32[i];
253 } 273 }
254 r.send(a); 274 r.send(a);
255 } 275 }
256 276
257 277
258 // Float64 Array. 278 // Float64 Array.
259 Float64List initFloat64() { 279 Float64List initFloat64() {
260 var float64 = new Float64List(2); 280 var float64 = new Float64List(2);
261 float64[0] = 101.234; 281 float64[0] = 101.234;
262 float64[1] = 201.765; 282 float64[1] = 201.765;
263 return float64; 283 return float64;
264 } 284 }
265 Float64List float64 = initFloat64(); 285 Float64List float64 = initFloat64();
266 286
267 void float64_receiver() { 287 float64_receiver() {
268 var response = new ReceivePort(); 288 var response = new ReceivePort();
269 var remote = 289 var remote =
270 Isolate.spawn(float64_sender, [float64.length, response.sendPort]); 290 Isolate.spawn(float64_sender, [float64.length, response.sendPort]);
271 response.first.then((a) { 291 asyncStart();
292 return response.first.then((a) {
272 Expect.equals(float64.length, a.length); 293 Expect.equals(float64.length, a.length);
273 for (int i = 0; i < a.length; i++) { 294 for (int i = 0; i < a.length; i++) {
274 Expect.equals(float64[i], a[i]); 295 Expect.equals(float64[i], a[i]);
275 } 296 }
276 print("float64_receiver"); 297 print("float64_receiver");
298 asyncEnd();
277 }); 299 });
278 } 300 }
279 301
280 float64_sender(message) { 302 float64_sender(message) {
281 var len = message[0]; 303 var len = message[0];
282 var r = message[1]; 304 var r = message[1];
283 Expect.equals(float64.length, len); 305 Expect.equals(float64.length, len);
284 var a = new Float64List(len); 306 var a = new Float64List(len);
285 for (int i = 0; i < len; i++) { 307 for (int i = 0; i < len; i++) {
286 a[i] = float64[i]; 308 a[i] = float64[i];
287 } 309 }
288 r.send(a); 310 r.send(a);
289 } 311 }
OLDNEW
« no previous file with comments | « tests/standalone/typed_array_int64_uint64_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698