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

Side by Side Diff: dart/tests/lib/typed_data/float32x4_test.dart

Issue 59073003: Version 0.8.10.4 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 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
« no previous file with comments | « dart/tests/lib/lib.status ('k') | dart/tests/lib/typed_data/float32x4_unbox_regress_test.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 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 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 // VMOptions=--deoptimization_counter_threshold=1000 --optimization-counter-thre shold=10 4 // VMOptions=--deoptimization_counter_threshold=1000 --optimization-counter-thre shold=10
5 5
6 // Library tag to be able to run in html test framework. 6 // Library tag to be able to run in html test framework.
7 library float32x4_test; 7 library float32x4_test;
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 Expect.equals(-1.0, o.y); 56 Expect.equals(-1.0, o.y);
57 Expect.equals(-1.0, o.z); 57 Expect.equals(-1.0, o.z);
58 Expect.equals(-1.0, o.w); 58 Expect.equals(-1.0, o.w);
59 } 59 }
60 60
61 testComparison() { 61 testComparison() {
62 var m = new Float32x4(1.0, 2.0, 0.1, 0.001); 62 var m = new Float32x4(1.0, 2.0, 0.1, 0.001);
63 var n = new Float32x4(2.0, 2.0, 0.001, 0.1); 63 var n = new Float32x4(2.0, 2.0, 0.001, 0.1);
64 var cmp; 64 var cmp;
65 cmp = m.lessThan(n); 65 cmp = m.lessThan(n);
66 Expect.equals(0xFFFFFFFF, cmp.x); 66 Expect.equals(-1, cmp.x);
67 Expect.equals(0x0, cmp.y); 67 Expect.equals(0x0, cmp.y);
68 Expect.equals(0x0, cmp.z); 68 Expect.equals(0x0, cmp.z);
69 Expect.equals(0xFFFFFFFF, cmp.w); 69 Expect.equals(-1, cmp.w);
70 70
71 cmp = m.lessThanOrEqual(n); 71 cmp = m.lessThanOrEqual(n);
72 Expect.equals(0xFFFFFFFF, cmp.x); 72 Expect.equals(-1, cmp.x);
73 Expect.equals(0xFFFFFFFF, cmp.y); 73 Expect.equals(-1, cmp.y);
74 Expect.equals(0x0, cmp.z); 74 Expect.equals(0x0, cmp.z);
75 Expect.equals(0xFFFFFFFF, cmp.w); 75 Expect.equals(-1, cmp.w);
76 76
77 cmp = m.equal(n); 77 cmp = m.equal(n);
78 Expect.equals(0x0, cmp.x); 78 Expect.equals(0x0, cmp.x);
79 Expect.equals(0xFFFFFFFF, cmp.y); 79 Expect.equals(-1, cmp.y);
80 Expect.equals(0x0, cmp.z); 80 Expect.equals(0x0, cmp.z);
81 Expect.equals(0x0, cmp.w); 81 Expect.equals(0x0, cmp.w);
82 82
83 cmp = m.notEqual(n); 83 cmp = m.notEqual(n);
84 Expect.equals(0xFFFFFFFF, cmp.x); 84 Expect.equals(-1, cmp.x);
85 Expect.equals(0x0, cmp.y); 85 Expect.equals(0x0, cmp.y);
86 Expect.equals(0xFFFFFFFF, cmp.z); 86 Expect.equals(-1, cmp.z);
87 Expect.equals(0xFFFFFFFF, cmp.w); 87 Expect.equals(-1, cmp.w);
88 88
89 cmp = m.greaterThanOrEqual(n); 89 cmp = m.greaterThanOrEqual(n);
90 Expect.equals(0x0, cmp.x); 90 Expect.equals(0x0, cmp.x);
91 Expect.equals(0xFFFFFFFF, cmp.y); 91 Expect.equals(-1, cmp.y);
92 Expect.equals(0xFFFFFFFF, cmp.z); 92 Expect.equals(-1, cmp.z);
93 Expect.equals(0x0, cmp.w); 93 Expect.equals(0x0, cmp.w);
94 94
95 cmp = m.greaterThan(n); 95 cmp = m.greaterThan(n);
96 Expect.equals(0x0, cmp.x); 96 Expect.equals(0x0, cmp.x);
97 Expect.equals(0x0, cmp.y); 97 Expect.equals(0x0, cmp.y);
98 Expect.equals(0xFFFFFFFF, cmp.z); 98 Expect.equals(-1, cmp.z);
99 Expect.equals(0x0, cmp.w); 99 Expect.equals(0x0, cmp.w);
100 } 100 }
101 101
102 testAbs() { 102 testAbs() {
103 var m = new Float32x4(1.0, -2.0, 3.0, -4.0); 103 var m = new Float32x4(1.0, -2.0, 3.0, -4.0);
104 m = m.abs(); 104 m = m.abs();
105 Expect.equals(1.0, m.x); 105 Expect.equals(1.0, m.x);
106 Expect.equals(2.0, m.y); 106 Expect.equals(2.0, m.y);
107 Expect.equals(3.0, m.z); 107 Expect.equals(3.0, m.z);
108 Expect.equals(4.0, m.w); 108 Expect.equals(4.0, m.w);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 testReciprocalSqrt() { 213 testReciprocalSqrt() {
214 var m = new Float32x4(1.0, 0.25, 0.111111, 0.0625); 214 var m = new Float32x4(1.0, 0.25, 0.111111, 0.0625);
215 m = m.reciprocalSqrt(); 215 m = m.reciprocalSqrt();
216 Expect.approxEquals(1.0, m.x, 0.001); 216 Expect.approxEquals(1.0, m.x, 0.001);
217 Expect.approxEquals(2.0, m.y, 0.001); 217 Expect.approxEquals(2.0, m.y, 0.001);
218 Expect.approxEquals(3.0, m.z, 0.001); 218 Expect.approxEquals(3.0, m.z, 0.001);
219 Expect.approxEquals(4.0, m.w, 0.001); 219 Expect.approxEquals(4.0, m.w, 0.001);
220 } 220 }
221 221
222 testSelect() { 222 testSelect() {
223 var m = new Uint32x4.bool(true, true, false, false); 223 var m = new Int32x4.bool(true, true, false, false);
224 var t = new Float32x4(1.0, 2.0, 3.0, 4.0); 224 var t = new Float32x4(1.0, 2.0, 3.0, 4.0);
225 var f = new Float32x4(5.0, 6.0, 7.0, 8.0); 225 var f = new Float32x4(5.0, 6.0, 7.0, 8.0);
226 var s = m.select(t, f); 226 var s = m.select(t, f);
227 Expect.equals(1.0, s.x); 227 Expect.equals(1.0, s.x);
228 Expect.equals(2.0, s.y); 228 Expect.equals(2.0, s.y);
229 Expect.equals(7.0, s.z); 229 Expect.equals(7.0, s.z);
230 Expect.equals(8.0, s.w); 230 Expect.equals(8.0, s.w);
231 } 231 }
232 232
233 testConversions() { 233 testConversions() {
234 var m = new Uint32x4(0x3F800000, 0x40000000, 0x40400000, 0x40800000); 234 var m = new Int32x4(0x3F800000, 0x40000000, 0x40400000, 0x40800000);
235 var n = new Float32x4.fromUint32x4Bits(m); 235 var n = new Float32x4.fromInt32x4Bits(m);
236 Expect.equals(1.0, n.x); 236 Expect.equals(1.0, n.x);
237 Expect.equals(2.0, n.y); 237 Expect.equals(2.0, n.y);
238 Expect.equals(3.0, n.z); 238 Expect.equals(3.0, n.z);
239 Expect.equals(4.0, n.w); 239 Expect.equals(4.0, n.w);
240 n = new Float32x4(5.0, 6.0, 7.0, 8.0); 240 n = new Float32x4(5.0, 6.0, 7.0, 8.0);
241 m = new Uint32x4.fromFloat32x4Bits(n); 241 m = new Int32x4.fromFloat32x4Bits(n);
242 Expect.equals(0x40A00000, m.x); 242 Expect.equals(0x40A00000, m.x);
243 Expect.equals(0x40C00000, m.y); 243 Expect.equals(0x40C00000, m.y);
244 Expect.equals(0x40E00000, m.z); 244 Expect.equals(0x40E00000, m.z);
245 Expect.equals(0x41000000, m.w); 245 Expect.equals(0x41000000, m.w);
246 // Flip sign using bit-wise operators. 246 // Flip sign using bit-wise operators.
247 n = new Float32x4(9.0, 10.0, 11.0, 12.0); 247 n = new Float32x4(9.0, 10.0, 11.0, 12.0);
248 m = new Uint32x4(0x80000000, 0x80000000, 0x80000000, 0x80000000); 248 m = new Int32x4(0x80000000, 0x80000000, 0x80000000, 0x80000000);
249 var nMask = new Uint32x4.fromFloat32x4Bits(n); 249 var nMask = new Int32x4.fromFloat32x4Bits(n);
250 nMask = nMask ^ m; // flip sign. 250 nMask = nMask ^ m; // flip sign.
251 n = new Float32x4.fromUint32x4Bits(nMask); 251 n = new Float32x4.fromInt32x4Bits(nMask);
252 Expect.equals(-9.0, n.x); 252 Expect.equals(-9.0, n.x);
253 Expect.equals(-10.0, n.y); 253 Expect.equals(-10.0, n.y);
254 Expect.equals(-11.0, n.z); 254 Expect.equals(-11.0, n.z);
255 Expect.equals(-12.0, n.w); 255 Expect.equals(-12.0, n.w);
256 nMask = new Uint32x4.fromFloat32x4Bits(n); 256 nMask = new Int32x4.fromFloat32x4Bits(n);
257 nMask = nMask ^ m; // flip sign. 257 nMask = nMask ^ m; // flip sign.
258 n = new Float32x4.fromUint32x4Bits(nMask); 258 n = new Float32x4.fromInt32x4Bits(nMask);
259 Expect.equals(9.0, n.x); 259 Expect.equals(9.0, n.x);
260 Expect.equals(10.0, n.y); 260 Expect.equals(10.0, n.y);
261 Expect.equals(11.0, n.z); 261 Expect.equals(11.0, n.z);
262 Expect.equals(12.0, n.w); 262 Expect.equals(12.0, n.w);
263 } 263 }
264 264
265 265
266 testBitOperators() { 266 testBitOperators() {
267 var m = new Uint32x4(0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA); 267 var m = new Int32x4(0xAAAAAAA, 0xAAAAAAA, 0xAAAAAAA, 0xAAAAAAA);
268 var n = new Uint32x4(0x55555555, 0x55555555, 0x55555555, 0x55555555); 268 var n = new Int32x4(0x5555555, 0x5555555, 0x5555555, 0x5555555);
269 Expect.equals(0xAAAAAAAA, m.x); 269 Expect.equals(0xAAAAAAA, m.x);
270 Expect.equals(0xAAAAAAAA, m.y); 270 Expect.equals(0xAAAAAAA, m.y);
271 Expect.equals(0xAAAAAAAA, m.z); 271 Expect.equals(0xAAAAAAA, m.z);
272 Expect.equals(0xAAAAAAAA, m.w); 272 Expect.equals(0xAAAAAAA, m.w);
273 Expect.equals(0x55555555, n.x); 273 Expect.equals(0x5555555, n.x);
274 Expect.equals(0x55555555, n.y); 274 Expect.equals(0x5555555, n.y);
275 Expect.equals(0x55555555, n.z); 275 Expect.equals(0x5555555, n.z);
276 Expect.equals(0x55555555, n.w); 276 Expect.equals(0x5555555, n.w);
277 Expect.equals(true, n.flagX); 277 Expect.equals(true, n.flagX);
278 Expect.equals(true, n.flagY); 278 Expect.equals(true, n.flagY);
279 Expect.equals(true, n.flagZ); 279 Expect.equals(true, n.flagZ);
280 Expect.equals(true, n.flagW); 280 Expect.equals(true, n.flagW);
281 var o = m|n; // or 281 var o = m|n; // or
282 Expect.equals(0xFFFFFFFF, o.x); 282 Expect.equals(0xFFFFFFF, o.x);
283 Expect.equals(0xFFFFFFFF, o.y); 283 Expect.equals(0xFFFFFFF, o.y);
284 Expect.equals(0xFFFFFFFF, o.z); 284 Expect.equals(0xFFFFFFF, o.z);
285 Expect.equals(0xFFFFFFFF, o.w); 285 Expect.equals(0xFFFFFFF, o.w);
286 Expect.equals(true, o.flagX); 286 Expect.equals(true, o.flagX);
287 Expect.equals(true, o.flagY); 287 Expect.equals(true, o.flagY);
288 Expect.equals(true, o.flagZ); 288 Expect.equals(true, o.flagZ);
289 Expect.equals(true, o.flagW); 289 Expect.equals(true, o.flagW);
290 o = m&n; // and 290 o = m&n; // and
291 Expect.equals(0x0, o.x); 291 Expect.equals(0x0, o.x);
292 Expect.equals(0x0, o.y); 292 Expect.equals(0x0, o.y);
293 Expect.equals(0x0, o.z); 293 Expect.equals(0x0, o.z);
294 Expect.equals(0x0, o.w); 294 Expect.equals(0x0, o.w);
295 n = n.withX(0xAAAAAAAA); 295 n = n.withX(0xAAAAAAA);
296 n = n.withY(0xAAAAAAAA); 296 n = n.withY(0xAAAAAAA);
297 n = n.withZ(0xAAAAAAAA); 297 n = n.withZ(0xAAAAAAA);
298 n = n.withW(0xAAAAAAAA); 298 n = n.withW(0xAAAAAAA);
299 Expect.equals(0xAAAAAAAA, n.x); 299 Expect.equals(0xAAAAAAA, n.x);
300 Expect.equals(0xAAAAAAAA, n.y); 300 Expect.equals(0xAAAAAAA, n.y);
301 Expect.equals(0xAAAAAAAA, n.z); 301 Expect.equals(0xAAAAAAA, n.z);
302 Expect.equals(0xAAAAAAAA, n.w); 302 Expect.equals(0xAAAAAAA, n.w);
303 o = m^n; // xor 303 o = m^n; // xor
304 Expect.equals(0x0, o.x); 304 Expect.equals(0x0, o.x);
305 Expect.equals(0x0, o.y); 305 Expect.equals(0x0, o.y);
306 Expect.equals(0x0, o.z); 306 Expect.equals(0x0, o.z);
307 Expect.equals(0x0, o.w); 307 Expect.equals(0x0, o.w);
308 Expect.equals(false, o.flagX); 308 Expect.equals(false, o.flagX);
309 Expect.equals(false, o.flagY); 309 Expect.equals(false, o.flagY);
310 Expect.equals(false, o.flagZ); 310 Expect.equals(false, o.flagZ);
311 Expect.equals(false, o.flagW); 311 Expect.equals(false, o.flagW);
312 } 312 }
(...skipping 11 matching lines...) Expand all
324 f = f.withZ(2.0); 324 f = f.withZ(2.0);
325 Expect.equals(2.0, f.z); 325 Expect.equals(2.0, f.z);
326 f = f.withW(1.0); 326 f = f.withW(1.0);
327 Expect.equals(1.0, f.w); 327 Expect.equals(1.0, f.w);
328 f = new Float32x4.zero(); 328 f = new Float32x4.zero();
329 f = f.withX(4.0).withZ(2.0).withW(1.0).withY(3.0); 329 f = f.withX(4.0).withZ(2.0).withW(1.0).withY(3.0);
330 Expect.equals(4.0, f.x); 330 Expect.equals(4.0, f.x);
331 Expect.equals(3.0, f.y); 331 Expect.equals(3.0, f.y);
332 Expect.equals(2.0, f.z); 332 Expect.equals(2.0, f.z);
333 Expect.equals(1.0, f.w); 333 Expect.equals(1.0, f.w);
334 var m = new Uint32x4.bool(false, false, false, false); 334 var m = new Int32x4.bool(false, false, false, false);
335 Expect.equals(false, m.flagX); 335 Expect.equals(false, m.flagX);
336 Expect.equals(false, m.flagY); 336 Expect.equals(false, m.flagY);
337 Expect.equals(false, m.flagZ); 337 Expect.equals(false, m.flagZ);
338 Expect.equals(false, m.flagW); 338 Expect.equals(false, m.flagW);
339 m = m.withFlagX(true); 339 m = m.withFlagX(true);
340 Expect.equals(true, m.flagX); 340 Expect.equals(true, m.flagX);
341 Expect.equals(false, m.flagY); 341 Expect.equals(false, m.flagY);
342 Expect.equals(false, m.flagZ); 342 Expect.equals(false, m.flagZ);
343 Expect.equals(false, m.flagW); 343 Expect.equals(false, m.flagW);
344 m = m.withFlagY(true); 344 m = m.withFlagY(true);
(...skipping 12 matching lines...) Expand all
357 Expect.equals(true, m.flagZ); 357 Expect.equals(true, m.flagZ);
358 Expect.equals(true, m.flagW); 358 Expect.equals(true, m.flagW);
359 } 359 }
360 360
361 testGetters() { 361 testGetters() {
362 var f = new Float32x4(1.0, 2.0, 3.0, 4.0); 362 var f = new Float32x4(1.0, 2.0, 3.0, 4.0);
363 Expect.equals(1.0, f.x); 363 Expect.equals(1.0, f.x);
364 Expect.equals(2.0, f.y); 364 Expect.equals(2.0, f.y);
365 Expect.equals(3.0, f.z); 365 Expect.equals(3.0, f.z);
366 Expect.equals(4.0, f.w); 366 Expect.equals(4.0, f.w);
367 var m = new Uint32x4.bool(false, true, true, false); 367 var m = new Int32x4.bool(false, true, true, false);
368 Expect.equals(false, m.flagX); 368 Expect.equals(false, m.flagX);
369 Expect.equals(true, m.flagY); 369 Expect.equals(true, m.flagY);
370 Expect.equals(true, m.flagZ); 370 Expect.equals(true, m.flagZ);
371 Expect.equals(false, m.flagW); 371 Expect.equals(false, m.flagW);
372 } 372 }
373 373
374 void testSplat() { 374 void testSplat() {
375 var f = new Float32x4.splat(2.0); 375 var f = new Float32x4.splat(2.0);
376 Expect.equals(2.0, f.x); 376 Expect.equals(2.0, f.x);
377 Expect.equals(2.0, f.y); 377 Expect.equals(2.0, f.y);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 testScale(); 416 testScale();
417 testClamp(); 417 testClamp();
418 testAbs(); 418 testAbs();
419 testMin(); 419 testMin();
420 testMax(); 420 testMax();
421 testSqrt(); 421 testSqrt();
422 testReciprocal(); 422 testReciprocal();
423 testReciprocalSqrt(); 423 testReciprocalSqrt();
424 } 424 }
425 } 425 }
OLDNEW
« no previous file with comments | « dart/tests/lib/lib.status ('k') | dart/tests/lib/typed_data/float32x4_unbox_regress_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698