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

Side by Side Diff: test/mjsunit/es6/typedarray-fill.js

Issue 2793233003: Revert of [typedarrays] Check detached buffer at start of typed array methods (Closed)
Patch Set: Created 3 years, 8 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 | « test/mjsunit/es6/typedarray-every.js ('k') | test/mjsunit/es6/typedarray-find.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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: --allow-natives-syntax
6
7 var intArrayConstructors = [ 5 var intArrayConstructors = [
8 Uint8Array, 6 Uint8Array,
9 Int8Array, 7 Int8Array,
10 Uint16Array, 8 Uint16Array,
11 Int16Array, 9 Int16Array,
12 Uint32Array, 10 Uint32Array,
13 Int32Array, 11 Int32Array,
14 Uint8ClampedArray 12 Uint8ClampedArray
15 ]; 13 ];
16 14
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 Symbol(Symbol.toStringTag) 69 Symbol(Symbol.toStringTag)
72 `); 70 `);
73 71
74 // Shadowing length doesn't affect fill, unlike Array.prototype.fill 72 // Shadowing length doesn't affect fill, unlike Array.prototype.fill
75 var a = new constructor([2, 2]); 73 var a = new constructor([2, 2]);
76 Object.defineProperty(a, 'length', {value: 1}); 74 Object.defineProperty(a, 'length', {value: 1});
77 a.fill(3); 75 a.fill(3);
78 assertArrayEquals([3, 3], [a[0], a[1]]); 76 assertArrayEquals([3, 3], [a[0], a[1]]);
79 Array.prototype.fill.call(a, 4); 77 Array.prototype.fill.call(a, 4);
80 assertArrayEquals([4, 3], [a[0], a[1]]); 78 assertArrayEquals([4, 3], [a[0], a[1]]);
81
82 // Detached Operation
83 var tmp = {
84 [Symbol.toPrimitive]() {
85 assertUnreachable("Parameter should not be processed when " +
86 "array.[[ViewedArrayBuffer]] is neutered.");
87 return 0;
88 }
89 };
90
91 var array = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
92 %ArrayBufferNeuter(array.buffer);
93 assertThrows(() => array.fill(tmp), TypeError);
94 } 79 }
95 80
96 for (var constructor of intArrayConstructors) { 81 for (var constructor of intArrayConstructors) {
97 assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill(undef ined)); 82 assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill(undef ined));
98 assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill()); 83 assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill());
99 assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill("abcd ")); 84 assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill("abcd "));
100 } 85 }
101 86
102 for (var constructor of floatArrayConstructors) { 87 for (var constructor of floatArrayConstructors) {
103 assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]). fill(undefined)); 88 assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]). fill(undefined));
104 assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]). fill()); 89 assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]). fill());
105 assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]). fill("abcd")); 90 assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]). fill("abcd"));
106 } 91 }
107 92
108 // Clamping 93 // Clamping
109 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(- 10)); 94 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(- 10));
110 assertArrayEquals([255, 255, 255, 255, 255], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(1000)); 95 assertArrayEquals([255, 255, 255, 255, 255], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(1000));
111 96
112 assertArrayEquals([1, 1, 1, 1, 1], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(0 .50001)); 97 assertArrayEquals([1, 1, 1, 1, 1], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(0 .50001));
113 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(0 .50000)); 98 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(0 .50000));
114 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(0 .49999)); 99 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(0 .49999));
115 // Check round half to even 100 // Check round half to even
116 assertArrayEquals([2, 2, 2, 2, 2], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(1 .50000)); 101 assertArrayEquals([2, 2, 2, 2, 2], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(1 .50000));
117 assertArrayEquals([2, 2, 2, 2, 2], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(2 .50000)); 102 assertArrayEquals([2, 2, 2, 2, 2], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(2 .50000));
118 assertArrayEquals([3, 3, 3, 3, 3], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(2 .50001)); 103 assertArrayEquals([3, 3, 3, 3, 3], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(2 .50001));
119 // Check infinity clamping. 104 // Check infinity clamping.
120 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(- Infinity)); 105 assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(- Infinity));
121 assertArrayEquals([255, 255, 255, 255, 255], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(Infinity)); 106 assertArrayEquals([255, 255, 255, 255, 255], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(Infinity));
OLDNEW
« no previous file with comments | « test/mjsunit/es6/typedarray-every.js ('k') | test/mjsunit/es6/typedarray-find.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698