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

Unified Diff: test/mjsunit/es6/typedarray-fill.js

Issue 2769673002: Move Oddball/String to %Typearray%.prototype.fill fast path (Closed)
Patch Set: Oddball and String 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/elements.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/typedarray-fill.js
diff --git a/test/mjsunit/es6/typedarray-fill.js b/test/mjsunit/es6/typedarray-fill.js
index 000c41441384ac4fb355245641ef282bf0296a59..9e72f5ec896cc617371e9cde0ddddbb58b554e0d 100644
--- a/test/mjsunit/es6/typedarray-fill.js
+++ b/test/mjsunit/es6/typedarray-fill.js
@@ -2,16 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var typedArrayConstructors = [
+var intArrayConstructors = [
Uint8Array,
Int8Array,
Uint16Array,
Int16Array,
Uint32Array,
Int32Array,
- Uint8ClampedArray,
+ Uint8ClampedArray
+];
+
+var floatArrayConstructors = [
Float32Array,
- Float64Array];
+ Float64Array
+];
+
+var typedArrayConstructors = [...intArrayConstructors, ...floatArrayConstructors];
for (var constructor of typedArrayConstructors) {
assertEquals(1, constructor.prototype.fill.length);
@@ -40,6 +46,11 @@ for (var constructor of typedArrayConstructors) {
assertThrows('constructor.prototype.fill.call(undefined)', TypeError);
assertThrows('constructor.prototype.fill.call([])', TypeError);
+ assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill(false));
+ assertArrayEquals([1, 1, 1, 1, 1], new constructor([0, 0, 0, 0, 0]).fill(true));
+ assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill(null));
+ assertArrayEquals([8, 8, 8, 8, 8], new constructor([0, 0, 0, 0, 0]).fill("8"));
+
// Test ToNumber
var s = "";
var p = new Proxy({}, {get(t,k) { s += k.toString() + '\n'; return Reflect.get(t, k)}})
@@ -67,9 +78,17 @@ Symbol(Symbol.toStringTag)
assertArrayEquals([4, 3], [a[0], a[1]]);
}
-// Empty args
-assertArrayEquals([0], new Uint8Array([0]).fill());
-assertArrayEquals([NaN], new Float32Array([0]).fill());
+for (var constructor of intArrayConstructors) {
+ assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill(undefined));
+ assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill());
+ assertArrayEquals([0, 0, 0, 0, 0], new constructor([0, 0, 0, 0, 0]).fill("abcd"));
+}
+
+for (var constructor of floatArrayConstructors) {
+ assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]).fill(undefined));
+ assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]).fill());
+ assertArrayEquals([NaN, NaN, NaN, NaN, NaN], new constructor([0, 0, 0, 0, 0]).fill("abcd"));
+}
// Clamping
assertArrayEquals([0, 0, 0, 0, 0], new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(-10));
« no previous file with comments | « src/elements.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698