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

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

Issue 2735563002: Migrate %TypedArray%.prototype.fill to C++ (Closed)
Patch Set: typo Created 3 years, 9 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
« src/elements.cc ('K') | « src/js/typedarray.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 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 var typedArrayConstructors = [ 5 var typedArrayConstructors = [
6 Uint8Array, 6 Uint8Array,
7 Int8Array, 7 Int8Array,
8 Uint16Array, 8 Uint16Array,
9 Int16Array, 9 Int16Array,
10 Uint32Array, 10 Uint32Array,
(...skipping 12 matching lines...) Expand all
23 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -5), [8, 8, 8, 8, 8 ]); 23 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -5), [8, 8, 8, 8, 8 ]);
24 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, 4), [0, 8, 8, 8, 0]); 24 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, 4), [0, 8, 8, 8, 0]);
25 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, -1), [0, 8, 8, 8 , 0]); 25 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, -1), [0, 8, 8, 8 , 0]);
26 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, 42), [0, 8, 8, 8 , 8]); 26 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 1, 42), [0, 8, 8, 8 , 8]);
27 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -3, 42), [0, 0, 8, 8, 8]); 27 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -3, 42), [0, 0, 8, 8, 8]);
28 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8 , 0]); 28 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8 , 0]);
29 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0]); 29 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0]);
30 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0]); 30 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0]);
31 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, 4), [8, 8, 8, 8, 0]); 31 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, 4), [8, 8, 8, 8, 0]);
32 32
33 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, Infinity), [0, 0, 0 , 0, 0]);
34 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -Infinity), [8, 8, 8, 8, 8]);
35 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, Infinity), [8, 8 , 8, 8, 8]);
36 assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, -Infinity), [0, 0, 0, 0, 0]);
37
Camillo Bruni 2017/03/13 15:58:14 Please add my Proxy test case as well, to ensure w
rongjie 2017/03/14 00:18:07 Done.
33 // Test exceptions 38 // Test exceptions
34 assertThrows('constructor.prototype.fill.call(null)', TypeError); 39 assertThrows('constructor.prototype.fill.call(null)', TypeError);
35 assertThrows('constructor.prototype.fill.call(undefined)', TypeError); 40 assertThrows('constructor.prototype.fill.call(undefined)', TypeError);
36 assertThrows('constructor.prototype.fill.call([])', TypeError); 41 assertThrows('constructor.prototype.fill.call([])', TypeError);
37 42
38 // Shadowing length doesn't affect fill, unlike Array.prototype.fill 43 // Shadowing length doesn't affect fill, unlike Array.prototype.fill
39 var a = new constructor([2, 2]); 44 var a = new constructor([2, 2]);
40 Object.defineProperty(a, 'length', {value: 1}); 45 Object.defineProperty(a, 'length', {value: 1});
41 a.fill(3); 46 a.fill(3);
42 assertArrayEquals([a[0], a[1]], [3, 3]); 47 assertArrayEquals([a[0], a[1]], [3, 3]);
43 Array.prototype.fill.call(a, 4); 48 Array.prototype.fill.call(a, 4);
44 assertArrayEquals([a[0], a[1]], [4, 3]); 49 assertArrayEquals([a[0], a[1]], [4, 3]);
45 } 50 }
51
52 // Clamping
53 assertArrayEquals(new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(-10), [0, 0, 0, 0, 0]);
54 assertArrayEquals(new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(1000), [255, 255, 255, 255, 255]);
OLDNEW
« src/elements.cc ('K') | « src/js/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698