Index: test/mjsunit/es6/typedarray-fill.js |
diff --git a/test/mjsunit/es6/typedarray-fill.js b/test/mjsunit/es6/typedarray-fill.js |
index 2c612016f6187e43fa91a0c31554e71ed51fad7b..cd5f87d934c4ab09d201ad92aa8dcdd4dcbc0db9 100644 |
--- a/test/mjsunit/es6/typedarray-fill.js |
+++ b/test/mjsunit/es6/typedarray-fill.js |
@@ -30,11 +30,34 @@ for (var constructor of typedArrayConstructors) { |
assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0]); |
assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, 4), [8, 8, 8, 8, 0]); |
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, Infinity), [0, 0, 0, 0, 0]); |
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, -Infinity), [8, 8, 8, 8, 8]); |
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, Infinity), [8, 8, 8, 8, 8]); |
+ assertArrayEquals(new constructor([0, 0, 0, 0, 0]).fill(8, 0, -Infinity), [0, 0, 0, 0, 0]); |
+ |
// Test exceptions |
assertThrows('constructor.prototype.fill.call(null)', TypeError); |
assertThrows('constructor.prototype.fill.call(undefined)', TypeError); |
assertThrows('constructor.prototype.fill.call([])', TypeError); |
+ // Test ToNumber |
+ var s = ""; |
+ var p = new Proxy({}, {get(t,k) { s += k.toString() + '\n'; return Reflect.get(t, k)}}) |
+ new constructor(3).fill(p); |
+ assertEquals(`Symbol(Symbol.toPrimitive) |
+valueOf |
+toString |
+Symbol(Symbol.toStringTag) |
+Symbol(Symbol.toPrimitive) |
+valueOf |
+toString |
+Symbol(Symbol.toStringTag) |
+Symbol(Symbol.toPrimitive) |
+valueOf |
+toString |
+Symbol(Symbol.toStringTag) |
+`, s); |
+ |
// Shadowing length doesn't affect fill, unlike Array.prototype.fill |
var a = new constructor([2, 2]); |
Object.defineProperty(a, 'length', {value: 1}); |
@@ -43,3 +66,7 @@ for (var constructor of typedArrayConstructors) { |
Array.prototype.fill.call(a, 4); |
assertArrayEquals([a[0], a[1]], [4, 3]); |
} |
+ |
+// Clamping |
+assertArrayEquals(new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(-10), [0, 0, 0, 0, 0]); |
+assertArrayEquals(new Uint8ClampedArray([0, 0, 0, 0, 0]).fill(1000), [255, 255, 255, 255, 255]); |
Camillo Bruni
2017/03/14 09:30:36
assertArrayEquals(new Uint8ClampedArray([0, 0, 0,
|