summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/TypedArray/with.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--js/src/tests/non262/TypedArray/with.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/js/src/tests/non262/TypedArray/with.js b/js/src/tests/non262/TypedArray/with.js
new file mode 100644
index 0000000000..c240f7084e
--- /dev/null
+++ b/js/src/tests/non262/TypedArray/with.js
@@ -0,0 +1,34 @@
+// |reftest| shell-option(--enable-change-array-by-copy) skip-if(!Int32Array.prototype.with)
+
+class Err {}
+
+const indices = [
+ -Infinity, -10, -0.5, -0, 0, 0.5, 10, Infinity, NaN
+];
+
+let value = {
+ valueOf() {
+ throw new Err;
+ }
+};
+
+let ta = new Int32Array(5);
+for (let index of indices) {
+ assertThrowsInstanceOf(() => ta.with(index, value), Err);
+}
+
+for (let index of indices) {
+ let ta = new Int32Array(5);
+
+ let value = {
+ valueOf() {
+ detachArrayBuffer(ta.buffer);
+ return 0;
+ }
+ };
+
+ assertThrowsInstanceOf(() => ta.with(index, value), RangeError);
+}
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);