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

Side by Side Diff: test/mjsunit/harmony/atomics.js

Issue 2658143003: [SAB] Handle non-numerics in Atomics.isLockFree (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « src/js/harmony-atomics.js ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-sharedarraybuffer 5 // Flags: --harmony-sharedarraybuffer
6 // 6 //
7 7
8 function toRangeWrapped(value) { 8 function toRangeWrapped(value) {
9 var range = this.max - this.min + 1; 9 var range = this.max - this.min + 1;
10 while (value < this.min) { 10 while (value < this.min) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 assertEquals(0x1c, array[i], name); 379 assertEquals(0x1c, array[i], name);
380 380
381 assertEquals(0x1c, Atomics.exchange(array, i, 0x09), name); 381 assertEquals(0x1c, Atomics.exchange(array, i, 0x09), name);
382 assertEquals(0x09, array[i], name); 382 assertEquals(0x09, array[i], name);
383 } 383 }
384 }) 384 })
385 }); 385 });
386 })(); 386 })();
387 387
388 (function TestIsLockFree() { 388 (function TestIsLockFree() {
389 // Various invalid cases.
390 var valueOf = {valueOf: function(){ return 3;}};
391 var toString = {toString: function(){ return '3';}};
392 var invalid = [3.14, 'foo', Infinity, NaN, false, undefined, valueOf,
393 toString];
394 invalid.forEach(function(v) {
395 assertEquals(false, Atomics.isLockFree(v), JSON.stringify(v));
396 });
397
389 // For all platforms we support, 1, 2 and 4 bytes should be lock-free. 398 // For all platforms we support, 1, 2 and 4 bytes should be lock-free.
390 assertEquals(true, Atomics.isLockFree(1)); 399 assertEquals(true, Atomics.isLockFree(1));
391 assertEquals(true, Atomics.isLockFree(2)); 400 assertEquals(true, Atomics.isLockFree(2));
392 assertEquals(true, Atomics.isLockFree(4)); 401 assertEquals(true, Atomics.isLockFree(4));
393 402
394 // Sizes that aren't equal to a typedarray BYTES_PER_ELEMENT always return 403 // Sizes that aren't equal to a typedarray BYTES_PER_ELEMENT always return
395 // false. 404 // false.
396 var validSizes = {}; 405 var validSizes = {};
397 IntegerTypedArrayConstructors.forEach(function(t) { 406 IntegerTypedArrayConstructors.forEach(function(t) {
398 validSizes[t.constr.BYTES_PER_ELEMENT] = true; 407 validSizes[t.constr.BYTES_PER_ELEMENT] = true;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 // Exchange 557 // Exchange
549 sta[0] = val = 0x12; 558 sta[0] = val = 0x12;
550 operand = 0x22 + offset; 559 operand = 0x22 + offset;
551 valWrapped = t.toRange(operand); 560 valWrapped = t.toRange(operand);
552 assertEquals(val, Atomics.exchange(sta, 0, operand), name); 561 assertEquals(val, Atomics.exchange(sta, 0, operand), name);
553 assertEquals(valWrapped, sta[0], name); 562 assertEquals(valWrapped, sta[0], name);
554 } 563 }
555 564
556 }); 565 });
557 })(); 566 })();
OLDNEW
« no previous file with comments | « src/js/harmony-atomics.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698