summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/prototype
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Tuple/prototype
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/Tuple/prototype')
-rw-r--r--js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/invoked-as-accessor.js22
-rw-r--r--js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/length.js11
-rw-r--r--js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/name.js7
-rw-r--r--js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/prop-desc.js31
-rw-r--r--js/src/tests/non262/Tuple/prototype/concat/concat-with-array.js7
-rw-r--r--js/src/tests/non262/Tuple/prototype/concat/concat.js104
-rw-r--r--js/src/tests/non262/Tuple/prototype/concat/indexed-setters.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/concat/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/filter/filter.js82
-rw-r--r--js/src/tests/non262/Tuple/prototype/filter/indexed-setters.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/filter/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/flat/empty-tuple-elements.js8
-rw-r--r--js/src/tests/non262/Tuple/prototype/flat/flat.js96
-rw-r--r--js/src/tests/non262/Tuple/prototype/flat/indexed-setters.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/flat/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/flat/undefined-elements.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/flatMap/depth-always-one.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/flatMap/flatMap.js114
-rw-r--r--js/src/tests/non262/Tuple/prototype/flatMap/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/fromIndex-infinity.js23
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/fromIndex-minus-zero.js24
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/includes.js18
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/length-internal.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/length-zero-returns-false.js23
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/name.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/no-arg.js12
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/not-a-constructor.js20
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/prop-desc.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/return-abrupt-get-length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js15
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex.js21
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tonumber-length-symbol.js15
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/samevaluezero.js21
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/search-found-returns-true.js28
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/search-not-found-returns-false.js26
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/this-is-not-tuple.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/tointeger-fromindex.js40
-rw-r--r--js/src/tests/non262/Tuple/prototype/includes/using-fromindex.js38
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/empty-tuple.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-boolean.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-float.js15
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-greater-than-length.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-infinity-string.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-inherited-valueOf.js36
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-missing.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-nan.js15
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-infinity.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-zero.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-negative.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-null.js15
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-number.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-not-primitive.js33
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf-toString.js31
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf.js21
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object.js24
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-positive.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-side-effects-3.js23
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-2.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-exponent.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-hex.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-leading-zeros.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-neg-infinity.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-negative.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc-2.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-undefined.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-with-index.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-zero.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/includes.js18
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/length-internal.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/undefined-throws-type-error.js18
-rw-r--r--js/src/tests/non262/Tuple/prototype/indexOf/uses-internal-length.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/isTuple/isTuple.js47
-rw-r--r--js/src/tests/non262/Tuple/prototype/isTuple/length.js22
-rw-r--r--js/src/tests/non262/Tuple/prototype/join/browser.js0
-rw-r--r--js/src/tests/non262/Tuple/prototype/join/dda-separator.js17
-rw-r--r--js/src/tests/non262/Tuple/prototype/join/shell.js0
-rw-r--r--js/src/tests/non262/Tuple/prototype/length/length-getter.js42
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/callback-not-called-on-empty.js7
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg45
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg.js43
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-without-thisarg.js45
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/callbackfn-is-not-callable.js40
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/callbackfn-returns-abrupt.js8
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/indexed-setters.js12
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/invoked-as-func.js6
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/invoked-as-method.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/length-internal.js18
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/map.js85
-rw-r--r--js/src/tests/non262/Tuple/prototype/map/this-is-not-tuple.js30
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/invoked-as-func.js7
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/invoked-as-method.js9
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/length.js26
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/name.js9
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/negative-zero.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/not-a-constructor.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/prop-desc.js9
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-end.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-start.js13
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/slice.js176
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/tointeger-end.js35
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/tointeger-start.js35
-rw-r--r--js/src/tests/non262/Tuple/prototype/slice/tuple-length-internal.js23
-rw-r--r--js/src/tests/non262/Tuple/prototype/toReversed/indexed-setters.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-func.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-method.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/toReversed/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/toReversed/this-is-not-tuple.js21
-rw-r--r--js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js29
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/comparefn-call-throws.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/comparefn-calls.js25
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/comparefn-nonfunction-call-throws.js25
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-func.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-method.js10
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/sorted-values.js29
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/stability.js32
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/this-is-not-tuple.js21
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/toSorted.js36
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/toSortedcompare-with-no-tostring.js14
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSorted/tuplelength-internal.js28
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSpliced/indexed-setters.js16
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSpliced/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/toSpliced/toSpliced.js254
-rw-r--r--js/src/tests/non262/Tuple/prototype/toString/length.js27
-rw-r--r--js/src/tests/non262/Tuple/prototype/toString/to-string.js21
-rw-r--r--js/src/tests/non262/Tuple/prototype/valueOf/length.js15
-rw-r--r--js/src/tests/non262/Tuple/prototype/valueOf/name.js9
-rw-r--r--js/src/tests/non262/Tuple/prototype/valueOf/valueOf.js23
-rw-r--r--js/src/tests/non262/Tuple/prototype/with/with.js68
135 files changed, 3479 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/invoked-as-accessor.js b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/invoked-as-accessor.js
new file mode 100644
index 0000000000..809a8a41bf
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/invoked-as-accessor.js
@@ -0,0 +1,22 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%Tuple%.prototype-@@tostringtag
+description: >
+info: |
+ 8.2.3.4 %Tuple%.prototype [ @@toStringTag ]
+
+The initial value of Tuple.prototype[@@toStringTag] is the String value "Tuple".
+
+This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+
+features: [Symbol.toStringTag, Tuple]
+---*/
+
+var TuplePrototype = Tuple.prototype;
+
+assertEq(TuplePrototype[Symbol.toStringTag], "Tuple");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/length.js b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/length.js
new file mode 100644
index 0000000000..ad82466f1f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/length.js
@@ -0,0 +1,11 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype, Symbol.toStringTag);
+
+assertEq(desc.length, undefined);
+
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/name.js b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/name.js
new file mode 100644
index 0000000000..cc7c101cd7
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/name.js
@@ -0,0 +1,7 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype, Symbol.toStringTag);
+
+assertEq(desc.name, undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/prop-desc.js b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/prop-desc.js
new file mode 100644
index 0000000000..43e5c73d35
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/Symbol.toStringTag/prop-desc.js
@@ -0,0 +1,31 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-get-%Tuple%.prototype-@@tostringtag
+description: >
+info: |
+ 8.2.3.4 %Tuple%.prototype [ @@toStringTag ]
+
+The initial value of Tuple.prototype[@@toStringTag] is the String value "Tuple".
+
+This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+
+features: [Symbol.toStringTag, Tuple]
+---*/
+
+var TuplePrototype = Tuple.prototype;
+var desc = Object.getOwnPropertyDescriptor(
+ TuplePrototype, Symbol.toStringTag
+);
+
+assertEq(desc.value, "Tuple");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(desc.set, undefined);
+assertEq(desc.get, undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/concat/concat-with-array.js b/js/src/tests/non262/Tuple/prototype/concat/concat-with-array.js
new file mode 100644
index 0000000000..938f4838cf
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/concat/concat-with-array.js
@@ -0,0 +1,7 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+assertDeepEq([1, 2].concat(#[3, 4]), [1, 2, 3, 4]);
+assertDeepEq([].concat(#[3, 4]), [3, 4]);
+assertDeepEq([].concat(#[]), []);
+assertDeepEq([1, 2, 3].concat(#[]), [1, 2, 3]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/concat/concat.js b/js/src/tests/non262/Tuple/prototype/concat/concat.js
new file mode 100644
index 0000000000..92270db7e9
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/concat/concat.js
@@ -0,0 +1,104 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.6 Tuple.prototype.concat ( ...args )
+
+When the concat method is called with zero or more arguments, it returns a Tuple containing the elements of the Tuple followed by the elements of each argument in order.
+
+The following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be a new empty List.
+3. Let n be 0.
+4. Let items be a List whose first element is T and whose subsequent element are, in left to right order, the arguments that were passed to this function invocation.
+5. Repeat, while items is not empty,
+a. Remove the first element from items and let E be the value of the element.
+b. Let spreadable be ? IsConcatSpreadable(E).
+c. If spreadable is true, then
+i. Let k be 0.
+ii. Let len be ? LengthOfArrayLike(E).
+iii. If n + len > 253 - 1, throw a TypeError exception.
+iv. Repeat, while k < len,
+1. Let P be ! ToString(k).
+2. Let exists be ? HasProperty(E, P).
+3. If exists is true, then
+a. Let subElement be ? Get(E, P).
+b. If Type(subElement) is Object, throw a TypeError exception.
+c. Append subElement to the end of list list.
+4. Set n to n + 1.
+5. Set k to k + 1.
+d. Else,
+i. NOTE: E is added as a single item rather than spread.
+ii. If n ≥ 253 - 1, throw a TypeError exception.
+iii. If Type(E) is Object, throw a TypeError exception.
+iv. Append E to the end of list list.
+v. Set n to n + 1.
+6. Return a new Tuple value whose [[Sequence]] is list.
+*/
+
+/* Step 1 */
+/* concat() should throw on a non-Tuple */
+let method = Tuple.prototype.concat;
+assertEq(method.call(#[1,2,3,4,5,6], #[1],#[2,3]), #[1,2,3,4,5,6,1,2,3]);
+assertEq(method.call(Object(#[1,2,3,4,5,6]), #[1],#[2,3]), method.call(#[1,2,3,4,5,6],#[1],#[2,3]));
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+
+/* Step 5 */
+/* No arguments or empty arguments => returns this */
+let tup = #[1,2,3];
+assertEq(tup.concat(), tup);
+assertEq(tup.concat(#[]), tup);
+assertEq(tup.concat([]), tup);
+assertEq(tup.concat(#[],#[],#[]), tup);
+
+/* Step 5 */
+/* 1 spreadable argument */
+assertEq(tup.concat(tup), #[1,2,3,1,2,3]);
+assertEq(tup.concat([1,2,3]), #[1,2,3,1,2,3]);
+
+/* spreadable followed by non-spreadable */
+assertEq(tup.concat(tup, "monkeys"), #[1,2,3,1,2,3, "monkeys"]);
+assertEq(tup.concat([1,2,3], "monkeys"), #[1,2,3,1,2,3, "monkeys"]);
+
+/* non-spreadable followed by spreadable */
+assertEq(tup.concat("monkeys", tup), #[1,2,3, "monkeys", 1,2,3]);
+assertEq(tup.concat("monkeys", [1,2,3]), #[1,2,3, "monkeys", 1,2,3,]);
+
+/* Step 5.c.iii.
+ If n + len > 2^53 - 1, throw a TypeError */
+var spreadableLengthOutOfRange = {};
+spreadableLengthOutOfRange.length = Number.MAX_SAFE_INTEGER;
+spreadableLengthOutOfRange[Symbol.isConcatSpreadable] = true;
+/*
+TODO
+this.length = (2^53/2)
+this.concat(a) throws if a.length = 2^53/2 - 1
+*/
+
+
+assertThrowsInstanceOf(() => tup.concat(spreadableLengthOutOfRange),
+ TypeError,
+ 'Too long array');
+
+/* Step 5.c.iv.2. Let exists be ?HasProperty(E, P)
+ Step 5.c.iv.3 Append only if exists is true */
+assertEq(tup.concat([42,17,,5,,12]), #[1,2,3,42,17,5,12]);
+
+/* Step 5.c.iv.3.b. -- Object elements should throw */
+assertThrowsInstanceOf(() => tup.concat([1, new Object(), 2]),
+ TypeError,
+ '#[1,2,3].concat([1, new Object(), 2]) throws a TypeError exception');
+
+/* Step 5d -- add as a single item */
+assertEq(tup.concat("monkeys"), #[1,2,3, "monkeys"]);
+/*
+Step 5d.c.ii.
+- Throw if this has length 2^53
+TODO: not sure how to test this -- creating a tuple with length 2^53 takes too long
+*/
+
+/* Step 5d.iii -- Object should throw */
+assertThrowsInstanceOf(() => tup.concat(new Object()), TypeError,
+ '#[1,2,3].concat(new Object()) throws a TypeError exception');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/concat/indexed-setters.js b/js/src/tests/non262/Tuple/prototype/concat/indexed-setters.js
new file mode 100644
index 0000000000..da6840927c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/concat/indexed-setters.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// If an indexed Array setter is overridden, TupleConcat shouldn't use it
+// when constructing the intermediate array
+
+var z = 5;
+for (i = 0; i < 4; i++) {
+ Object.defineProperty(Array.prototype, i, { set: function(y) { z = 42; }});
+}
+var newT = #[1, 2].concat([3, 4]);
+assertEq(z, 5);
+
+newT = #[1, 2].concat("hello");
+assertEq(z, 5);
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/concat/length.js b/js/src/tests/non262/Tuple/prototype/concat/length.js
new file mode 100644
index 0000000000..6b801f8783
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/concat/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.concat, "length");
+assertEq(desc.value, 0);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.concat, "name");
+assertEq(desc.value, "concat");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "concat");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.concat), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.concat();
+}, TypeError, '`let t = #[1]; new t.concat()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/filter/filter.js b/js/src/tests/non262/Tuple/prototype/filter/filter.js
new file mode 100644
index 0000000000..d51c982868
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/filter/filter.js
@@ -0,0 +1,82 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.13 Tuple.prototype.filter ( callbackfn [ , thisArg ] )
+NOTE
+callbackfn should be a function that accepts three arguments and returns a value that is coercible to the Boolean value true or false. filter calls callbackfn once for each element in the tuple, in ascending order, and constructs a new tuple of all the values for which callbackfn returns true.
+
+If a thisArg parameter is provided, it will be used as the this value for each invocation of callbackfn. If it is not provided, undefined is used instead.
+
+callbackfn is called with three arguments: the value of the element, the index of the element, and the Tuple being traversed.
+
+When the filter method is called with one or two arguments, the following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be T.[[Sequence]].
+3. Let len be the number of elements in list.
+4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+5. Let newList be a new empty List.
+6. Let k be 0.
+7. Repeat, while k < len,
+a. Let kValue be list[k].
+b. Let selected be ! ToBoolean(? Call(callbackfn, thisArg, « kValue, k, T »)).
+c. If selected is true, then
+i. Append kValue to the end of list newList.
+d. Set k to k + 1.
+8. Return a new Tuple value whose [[Sequence]] is newLis.t
+
+*/
+
+/* Step 1 */
+/* filter() should throw on a non-Tuple */
+let method = Tuple.prototype.filter;
+let pred = (x, i, tup) => x % 2 === 0;
+assertEq(method.call(#[1,2,3,4,5,6],pred), #[2,4,6]);
+assertEq(method.call(Object(#[1,2,3,4,5,6]), pred), #[2,4,6]);
+assertThrowsInstanceOf(() => method.call("monkeys", pred), TypeError,
+ "value of TupleObject must be a Tuple");
+
+let tup = #[1,2,3];
+
+/* Step 4 */
+/* callbackfn not callable -- should throw */
+assertThrowsInstanceOf(() => tup.filter(), TypeError,
+ "missing function argument to Tuple.prototype.filter");
+assertThrowsInstanceOf(() => tup.filter(undefined), TypeError,
+ "missing function argument to Tuple.prototype.filter");
+assertThrowsInstanceOf(() => tup.filter("monkeys"), TypeError,
+ "bad function argument to Tuple.prototype.filter");
+
+
+/* callbackfn with 1 argument -- should be allowed */
+var pred2 = x => x % 2 === 0;
+assertEq(tup.filter(pred2), #[2]);
+
+/* callbackfn with 2 arguments -- should be allowed */
+pred2 = (x, i) => x + i < 5;
+assertEq(tup.filter(pred2), #[1, 2]);
+
+/* callbackfn with > 3 arguments -- subsequent ones will be undefined */
+var pred3 = (a, b, c, d, e) => e === undefined;
+assertEq(tup.filter(pred3), tup);
+
+/* callbackfn should be able to use index and tuple */
+var pred1 = (x, i, tup) => (tup.indexOf(x + i) !== (-1));
+assertEq(#[1,2,3,4,5,6,7].filter(pred1), #[1,2,3,4]);
+
+/* explicit thisArg */
+pred1 = function (x, i, tup) { return(this.elements.indexOf(x) !== -1); };
+assertEq(#[1,2,3,4,5].filter(pred1, { elements: [2, 4] }), #[2,4]);
+
+/* Step 3 */
+/* Test that length is still handled correctly if it's overridden */
+Object.defineProperty(Tuple.prototype, "length", { get() { return 0 } })
+assertEq(tup.filter(pred), #[2]);
+
+/* Step 7 */
+assertEq(#[].filter(pred), #[]);
+assertEq(#[1].filter(pred), #[]);
+assertEq(#[2].filter(pred), #[2]);
+assertEq(tup.filter(pred), #[2]);
+assertEq(tup.filter(x => x > 1), #[2,3]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/filter/indexed-setters.js b/js/src/tests/non262/Tuple/prototype/filter/indexed-setters.js
new file mode 100644
index 0000000000..a110b460e1
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/filter/indexed-setters.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// If an indexed Array setter is overridden, TupleSplice shouldn't use it
+// when constructing the intermediate array
+
+var z = 5;
+print("1111");
+Object.defineProperty(Array.prototype, '0', { set: function(y) { z = 42; }});
+print("2222");
+let newT = #[1,2,3].filter(x => true);
+print("3333");
+assertEq(z, 5);
+print("4444");
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/filter/length.js b/js/src/tests/non262/Tuple/prototype/filter/length.js
new file mode 100644
index 0000000000..a780c2b2b1
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/filter/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.filter, "length");
+assertEq(desc.value, 1);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.filter, "name");
+assertEq(desc.value, "filter");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "filter");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.filter), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.filter();
+}, TypeError, '`let t = #[1]; new t.filter()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/flat/empty-tuple-elements.js b/js/src/tests/non262/Tuple/prototype/flat/empty-tuple-elements.js
new file mode 100644
index 0000000000..e8acef7b43
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flat/empty-tuple-elements.js
@@ -0,0 +1,8 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var t = #[];
+assertEq(#[].flat(), #[]);
+assertEq(#[#[],#[]].flat(), #[]);
+assertEq(#[#[], #[1]].flat(), #[1]);
+assertEq(#[#[], #[1, t]].flat(), #[1, t]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/flat/flat.js b/js/src/tests/non262/Tuple/prototype/flat/flat.js
new file mode 100644
index 0000000000..93748f9c36
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flat/flat.js
@@ -0,0 +1,96 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.16 Tuple.prototype.flat ( [ depth ] )
+When the flat method is called with zero or one arguments, the following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be T.[[Sequence]].
+3. Let depthNum be 1.
+4. If depth is not undefined, then
+a. Set depthNum to ? ToInteger(depth).
+5. Let flat be a new empty List.
+6. Perform ? FlattenIntoTuple(flat, list, depthNum).
+7. Return a new Tuple value whose [[Sequence]] is flat.
+
+8.2.3.16.1 FlattenIntoTuple ( target, source, depth [ , mapperFunction, thisArg ] )
+The abstract operation FlattenIntoTuple takes arguments target, source, and depth and optional arguments mapperFunction and thisArg. It performs the following steps when called:
+
+1. Assert: target is a List.
+2. Assert: source is a List.
+3. Assert: ! IsInteger(depth) is true, or depth is either +∞ or -∞.
+4. Assert: If mapperFunction is present, then ! IsCallable(mapperFunction) is true, thisArg is present, and depth is 1.
+5. Let sourceIndex be 0.
+6. For each element of source,
+a. If mapperFunction is present, then
+i. Set element to ? Call(mapperFunction, thisArg, « element, sourceIndex, source »).
+ii. If Type(element) is Object, throw a TypeError exception.
+b. If depth > 0 and Type(element) is Tuple, then
+i. Perform ? FlattenIntoTuple(target, element, depth - 1).
+c. Else,
+i. Let len be the length of target.
+ii. If len ≥ 253 - 1, throw a TypeError exception.
+iii. Append element to target.
+d. Set sourceIndex to sourceIndex + 1.
+
+*/
+/* Step 1 */
+/* flat() should throw on a non-Tuple */
+let method = Tuple.prototype.flat;
+assertEq(method.call(#[1,#[2],3]), #[1,2,3]);
+assertEq(method.call(Object(#[1,#[2],3])), #[1,2,3]);
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(null), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(), TypeError,
+ "value of TupleObject must be a Tuple");
+
+
+let tup = #[1,2,#[3,#[4,5],6],#[5,6],7];
+let tup2 = #[1,2,#[3,#[4,#["a", "b"], 5],6],#[5,#[6,#[7,8,#[9,10]]]],7];
+
+/* Step 3 -- depth is converted to Integer */
+assertEq(tup.flat("monkeys"), tup.flat(0));
+assertEq(tup.flat({}), tup.flat(0));
+assertEq(tup.flat(+0), tup.flat(0));
+assertEq(tup.flat(-0), tup.flat(0));
+assertEq(tup.flat('2'), tup.flat(2));
+assertEq(tup.flat(true), tup.flat(1));
+assertEq(tup.flat(false), tup.flat(0));
+assertEq(tup.flat(null), tup.flat(0));
+assertEq(tup.flat(NaN), tup.flat(0));
+assertEq(tup.flat([1,2,3]), tup.flat(0));
+assertThrowsInstanceOf(() => tup.flat(Symbol("x")), TypeError,
+ "can't convert symbol to number");
+assertThrowsInstanceOf(() => tup.flat(Object.create(null)), TypeError,
+ "can't convert Object to number");
+assertThrowsInstanceOf(() => tup.flat(#[1]), TypeError,
+ "can't convert Tuple to number");
+
+
+/* Step 3 -- if depth is undefined, depthNum is set to 1 */
+assertEq(tup.flat(undefined), tup.flat(1));
+assertEq(tup.flat(), tup.flat(1));
+
+/* Step 7 */
+assertEq(#[].flat(), #[]);
+assertEq(#[1].flat(), #[1]);
+assertEq(#[#[1,2],#[3,4]].flat(), #[1,2,3,4]);
+assertEq(tup.flat(0), tup);
+assertEq(tup.flat(1), #[1,2,3,#[4,5],6,5,6,7]);
+assertEq(tup.flat(2), #[1,2,3,4,5,6,5,6,7]);
+assertEq(tup.flat(3), tup.flat(2));
+assertEq(tup2.flat(0), tup2);
+assertEq(tup2.flat(1), #[1,2,3,#[4,#["a", "b"], 5],6,5,#[6,#[7,8,#[9,10]]],7]);
+assertEq(tup2.flat(2), #[1,2,3,4,#["a", "b"],5,6,5,6,#[7, 8, #[9, 10]],7]);
+assertEq(tup2.flat(3), #[1,2,3,4,"a","b",5,6,5,6, 7, 8, #[9, 10], 7]);
+assertEq(tup2.flat(4), #[1,2,3,4,"a","b",5,6,5,6, 7, 8, 9, 10, 7]);
+
+/* FlattenIntoTuple steps: */
+/* Step 3: depth can be Infinity or -Infinity */
+assertEq(tup2.flat(Infinity), tup2.flat(4));
+assertEq(tup2.flat(-Infinity), tup2.flat(0));
+
+/* Step 6.c.ii. -- throw if len would be > n^253 - 1 -- not sure how to test this */
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/flat/indexed-setters.js b/js/src/tests/non262/Tuple/prototype/flat/indexed-setters.js
new file mode 100644
index 0000000000..26b77e03fd
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flat/indexed-setters.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// If an indexed Array setter is overridden, TupleSplice shouldn't use it
+// when constructing the intermediate array
+
+var z = 5;
+print("1111");
+Object.defineProperty(Array.prototype, '0', { set: function(y) { z = 42; }});
+print("2222");
+let newT = #[#[1],#[2,3]].flat();
+print("3333");
+assertEq(z, 5);
+print("4444");
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/flat/length.js b/js/src/tests/non262/Tuple/prototype/flat/length.js
new file mode 100644
index 0000000000..8bbbea0ae9
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flat/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.flat, "length");
+assertEq(desc.value, 0);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.flat, "name");
+assertEq(desc.value, "flat");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "flat");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.flat), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.flat();
+}, TypeError, '`let t = #[1]; new t.flat()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/flat/undefined-elements.js b/js/src/tests/non262/Tuple/prototype/flat/undefined-elements.js
new file mode 100644
index 0000000000..4a705167f5
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flat/undefined-elements.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var t = #[void 0];
+
+assertEq(#[1, null, void 0].flat(), #[1, null, undefined]);
+assertEq(#[1, #[null, void 0]].flat(), #[1, null, undefined]);
+assertEq(#[#[null, void 0], #[null, void 0]].flat(), #[null, undefined, null, undefined]);
+assertEq(#[1, #[null, t]].flat(1), #[1, null, t]);
+assertEq(#[1, #[null, t]].flat(2), #[1, null, undefined]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/flatMap/depth-always-one.js b/js/src/tests/non262/Tuple/prototype/flatMap/depth-always-one.js
new file mode 100644
index 0000000000..2f3aed6e32
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flatMap/depth-always-one.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+assertEq(#[1, 2].flatMap(function(e) {
+ return #[e, e * 2];
+}), #[1, 2, 2, 4]);
+
+var result = #[1, 2, 3].flatMap(function(ele) {
+ return #[
+ #[ele * 2]
+ ];
+});
+assertEq(result.length, 3);
+assertEq(result[0], #[2]);
+assertEq(result[1] ,#[4]);
+assertEq(result[2], #[6]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/flatMap/flatMap.js b/js/src/tests/non262/Tuple/prototype/flatMap/flatMap.js
new file mode 100644
index 0000000000..0fde7014a8
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flatMap/flatMap.js
@@ -0,0 +1,114 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.17 Tuple.prototype.flatMap ( mapperFunction [ , thisArg ] )
+When the flatMap method is called with one or two arguments, the following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be T.[[Sequence]].
+3. If ! IsCallable(mapperFunction) is false, throw a TypeError exception.
+4. Let flat be a new empty List.
+5. Perform ? FlattenIntoTuple(flat, list, 1, mapperFunction, thisArg).
+6. Return a new Tuple value whose [[Sequence]] is flat.
+
+8.2.3.16.1 FlattenIntoTuple ( target, source, depth [ , mapperFunction, thisArg ] )
+The abstract operation FlattenIntoTuple takes arguments target, source, and depth and optional arguments mapperFunction and thisArg. It performs the following steps when called:
+
+1. Assert: target is a List.
+2. Assert: source is a List.
+3. Assert: ! IsInteger(depth) is true, or depth is either +∞ or -∞.
+4. Assert: If mapperFunction is present, then ! IsCallable(mapperFunction) is true, thisArg is present, and depth is 1.
+5. Let sourceIndex be 0.
+6. For each element of source,
+a. If mapperFunction is present, then
+i. Set element to ? Call(mapperFunction, thisArg, « element, sourceIndex, source »).
+ii. If Type(element) is Object, throw a TypeError exception.
+b. If depth > 0 and Type(element) is Tuple, then
+i. Perform ? FlattenIntoTuple(target, element, depth - 1).
+c. Else,
+i. Let len be the length of target.
+ii. If len ≥ 253 - 1, throw a TypeError exception.
+iii. Append element to target.
+d. Set sourceIndex to sourceIndex + 1.
+ */
+
+/* Step 1 */
+/* flatMap() should throw on a non-Tuple */
+let method = Tuple.prototype.flatMap;
+let id = x => x;
+assertEq(method.call(#[1,#[2],3], id), #[1,2,3]);
+assertEq(method.call(Object(#[1,#[2],3]), id), #[1,2,3]);
+assertThrowsInstanceOf(() => method.call("monkeys", id), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(null, id), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(id), TypeError,
+ "value of TupleObject must be a Tuple");
+
+
+let tup = #[1,2,#[3,#[4,5],6],#[5,6],7];
+let tup2 = #[1, #[2], 3];
+
+/* Step 4 */
+/* callbackfn not callable -- should throw */
+assertThrowsInstanceOf(() => tup.flatMap(), TypeError,
+ "missing function argument to Tuple.prototype.flatMap");
+assertThrowsInstanceOf(() => tup.flatMap(undefined), TypeError,
+ "missing function argument to Tuple.prototype.flatMap");
+assertThrowsInstanceOf(() => tup.flatMap("monkeys"), TypeError,
+ "bad function argument to Tuple.prototype.flatMap");
+
+
+/* callbackfn with 1 argument -- should be allowed */
+var f2 = function(x) {
+ if (typeof(x) === "number") {
+ return(x * x);
+ } else {
+ return 0;
+ }
+};
+assertEq(tup2.flatMap(f2), #[1, 0, 9]);
+
+/* callbackfn with 2 arguments -- should be allowed */
+f2 = function(x, i) {
+ if (typeof(x) === "number") {
+ return(x + i);
+ } else {
+ return(i);
+ }
+};
+assertEq(tup2.flatMap(f2), #[1, 1, 5]);
+
+/* callbackfn with > 3 arguments -- subsequent ones will be undefined */
+var f3 = (a, b, c, d, e) => e === undefined;
+assertEq(tup2.flatMap(f3), #[true, true, true]);
+
+/* callbackfn should be able to use index and tuple */
+var f4 = function (x, i, tup) {
+ if (typeof(x) === "number") {
+ return(tup.indexOf(x+1) * i * x);
+ } else {
+ return(tup.indexOf(x) * i);
+ }
+}
+assertEq(tup2.flatMap(f4), #[-0, 1, -6]);
+
+/* explicit thisArg */
+f1 = function (x, i, tup) {
+ if (typeof(x) == "number") {
+ return(this.elements.indexOf(x) * x);
+ } else {
+ return(this.elements.indexOf(x));
+ }
+}
+assertEq(#[1,2,#[3,4],#[5]].flatMap(f1, { elements: [2, 4] }), #[-1, 0, -1, -1]);
+
+/* FlattenIntoTuple steps */
+/* Step 6.a.ii. */
+var badF = x => new Object(x);
+assertThrowsInstanceOf(() => tup.flatMap(badF), TypeError,
+ "Tuple cannot contain Object");
+/* Step 6.b.i. */
+var f = x => #[x, x];
+assertEq(#[1,#[2,3],4].flatMap(f), #[1,1,#[2,3],#[2,3],4,4]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/flatMap/length.js b/js/src/tests/non262/Tuple/prototype/flatMap/length.js
new file mode 100644
index 0000000000..4e6f5eb0ab
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/flatMap/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.flatMap, "length");
+assertEq(desc.value, 1);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.flatMap, "name");
+assertEq(desc.value, "flatMap");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "flatMap");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.flatMap), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.flatMap();
+}, TypeError, '`let t = #[1]; new t.flatMap()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/js/src/tests/non262/Tuple/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js
new file mode 100644
index 0000000000..6108e38cbc
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Return false if fromIndex >= TupleLength
+---*/
+
+var sample = #[7, 7, 7, 7];
+assertEq(sample.includes(7, 4), false, "length");
+assertEq(sample.includes(7, 5), false, "length + 1");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/fromIndex-infinity.js b/js/src/tests/non262/Tuple/prototype/includes/fromIndex-infinity.js
new file mode 100644
index 0000000000..3ed0c3b43c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/fromIndex-infinity.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.includes
+description: handle Infinity values for fromIndex
+---*/
+
+var sample = #[42, 43, 43, 41];
+
+assertEq(
+ sample.includes(43, Infinity),
+ false,
+ "includes(43, Infinity)"
+);
+assertEq(
+ sample.includes(43, -Infinity),
+ true,
+ "includes(43, -Infinity)"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/fromIndex-minus-zero.js b/js/src/tests/non262/Tuple/prototype/includes/fromIndex-minus-zero.js
new file mode 100644
index 0000000000..23ebaf8346
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/fromIndex-minus-zero.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.includes
+description: -0 fromIndex becomes 0
+info: |
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 5. If n ≥ 0, then
+ a. Let k be n.
+ ...
+ 7. Repeat, while k < len
+ ...
+---*/
+
+var sample = [42, 43];
+assertEq(sample.includes(42, -0), true, "-0 [0]");
+assertEq(sample.includes(43, -0), true, "-0 [1]");
+assertEq(sample.includes(44, -0), false, "-0 [2]");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/includes.js b/js/src/tests/non262/Tuple/prototype/includes/includes.js
new file mode 100644
index 0000000000..26ef2bfb03
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/includes.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.7 Tuple.prototype.includes ( searchElement [ , fromIndex ] )
+Tuple.prototype.includes is a distinct function that implements the same algorithm as Array.prototype.includes as defined in 22.1.3.13 except that ? thisTupleValue(this value) is used instead of directly accessing the this value. The implementation of the algorithm may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse, do not change, and their access is not observable. However, such optimization must not introduce any observable changes in the specified behaviour of the algorithm.
+
+This function is not generic, since thisTupleValue(this value) can return an abrupt completion: in that case, that exception is thrown instead of evaluating the algorithm.
+*/
+
+/* Step 1 */
+/* includes() should throw on a non-Tuple */
+let method = Tuple.prototype.includes;
+assertEq(method.call(#[1,2,3,4,5,6], 2), true);
+assertEq(method.call(Object(#[1,2,3,4,5,6]), 2), true);
+assertThrowsInstanceOf(() => method.call("monkeys", 2), TypeError,
+ "value of TupleObject must be a Tuple");
+
+/* Not sure what else to test, since it just calls the array method */
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/length-internal.js b/js/src/tests/non262/Tuple/prototype/includes/length-internal.js
new file mode 100644
index 0000000000..a199884f00
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/length-internal.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/* Tuples should have a length ownProperty that can't be overridden, which will
+ * be read by any built-in methods called on Tuples.
+ * This test is expected to fail until the spec change in
+ * https://github.com/tc39/proposal-record-tuple/issues/282 is implemented.
+ */
+
+/*
+t = #[1,2,3];
+Object.defineProperty(Tuple.prototype, "length", {value: 0});
+assertEq(t.includes(2), true);
+*/
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/length-zero-returns-false.js b/js/src/tests/non262/Tuple/prototype/includes/length-zero-returns-false.js
new file mode 100644
index 0000000000..b72397d8f3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/length-zero-returns-false.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Returns false if length is 0
+ ...
+---*/
+
+var calls = 0;
+var fromIndex = {
+ valueOf: function() {
+ calls++;
+ }
+};
+
+var sample = #[];
+assertEq(sample.includes(0), false, "returns false");
+assertEq(sample.includes(), false, "returns false - no arg");
+assertEq(sample.includes(0, fromIndex), false, "using fromIndex");
+assertEq(calls, 0, "length is checked before ToInteger(fromIndex)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/length.js b/js/src/tests/non262/Tuple/prototype/includes/length.js
new file mode 100644
index 0000000000..b8a60b837c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.includes, "length");
+assertEq(desc.value, 1);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.includes, "name");
+assertEq(desc.value, "includes");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "includes");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.includes), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.includes();
+}, TypeError, '`let t = #[1]; new t.includes()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/name.js b/js/src/tests/non262/Tuple/prototype/includes/name.js
new file mode 100644
index 0000000000..df6537a3b4
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/name.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.includes.name is "includes".
+---*/
+
+assertEq(Tuple.prototype.includes.name, "includes");
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.includes, "name");
+
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/no-arg.js b/js/src/tests/non262/Tuple/prototype/includes/no-arg.js
new file mode 100644
index 0000000000..83fee6722c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/no-arg.js
@@ -0,0 +1,12 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: no argument searches for a undefined value
+---*/
+
+assertEq(#[0].includes(), false, "#[0].includes()");
+assertEq(#[undefined].includes(), true, "#[undefined].includes()");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/not-a-constructor.js b/js/src/tests/non262/Tuple/prototype/includes/not-a-constructor.js
new file mode 100644
index 0000000000..e60846e70a
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/not-a-constructor.js
@@ -0,0 +1,20 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.includes does not implement [[Construct]], is not new-able
+---*/
+
+assertEq(
+ isConstructor(Tuple.prototype.includes),
+ false,
+ 'isConstructor(Tuple.prototype.includes) must return false'
+);
+
+assertThrowsInstanceOf(() => new Tuple.prototype.includes(1),
+ TypeError, '`new Tuple.prototype.includes(1)` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/prop-desc.js b/js/src/tests/non262/Tuple/prototype/includes/prop-desc.js
new file mode 100644
index 0000000000..4dcd03d64c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/prop-desc.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: >
+ "includes" property of Tuple.prototype
+---*/
+
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "includes");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-get-length.js b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-get-length.js
new file mode 100644
index 0000000000..169a4318d8
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-get-length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.includes
+description: Return abrupt from Get(O, "length")
+info: |
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 2. Let len be ? ToLength(? Get(O, "length")).
+ ...
+---*/
+
+var obj = {};
+
+Object.defineProperty(obj, "length", {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+assertThrowsInstanceOf(() => #[].includes.call(obj, 7), TypeError,
+ "value of TupleObject must be a tuple");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js
new file mode 100644
index 0000000000..9f6a0f5938
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Return abrupt from ToInteger(fromIndex) - using symbol
+---*/
+
+var fromIndex = Symbol("1");
+
+var sample = #[7];
+
+assertThrowsInstanceOf(() => sample.includes(7, fromIndex), TypeError);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex.js b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex.js
new file mode 100644
index 0000000000..2d8ec0ee87
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tointeger-fromindex.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Return abrupt from ToInteger(fromIndex)
+---*/
+
+function TestError() {};
+
+var fromIndex = {
+ valueOf: function() {
+ throw new TestError();
+ }
+};
+
+var sample = #[7];
+
+assertThrowsInstanceOf(() => sample.includes(7, fromIndex), TestError);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tonumber-length-symbol.js b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tonumber-length-symbol.js
new file mode 100644
index 0000000000..f94fde9772
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/return-abrupt-tonumber-length-symbol.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Return abrupt from ToNumber(symbol "length")
+---*/
+
+var obj = {
+ length: Symbol("1")
+};
+
+assertThrowsInstanceOf(() => #[].includes.call(obj, 7), TypeError);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/samevaluezero.js b/js/src/tests/non262/Tuple/prototype/includes/samevaluezero.js
new file mode 100644
index 0000000000..c8dbe08c14
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/samevaluezero.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: search element is compared using SameValueZero
+---*/
+
+var sample = #[42, 0, 1, NaN];
+assertEq(sample.includes("42"), false);
+assertEq(sample.includes([42]), false);
+assertEq(sample.includes(#[42]), false);
+assertEq(sample.includes(42.0), true);
+assertEq(sample.includes(-0), true);
+assertEq(sample.includes(true), false);
+assertEq(sample.includes(false), false);
+assertEq(sample.includes(null), false);
+assertEq(sample.includes(""), false);
+assertEq(sample.includes(NaN), true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/search-found-returns-true.js b/js/src/tests/non262/Tuple/prototype/includes/search-found-returns-true.js
new file mode 100644
index 0000000000..0084583591
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/search-found-returns-true.js
@@ -0,0 +1,28 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: returns true for found index
+---*/
+
+var symbol = Symbol("1");
+var tuple = #[];
+var record = #{};
+
+var sample = #[42, "test262", null, undefined, true, false, 0, -1, "", symbol, tuple, record];
+
+assertEq(sample.includes(42), true, "42");
+assertEq(sample.includes("test262"), true, "'test262'");
+assertEq(sample.includes(null), true, "null");
+assertEq(sample.includes(undefined), true, "undefined");
+assertEq(sample.includes(true), true, "true");
+assertEq(sample.includes(false), true, "false");
+assertEq(sample.includes(0), true, "0");
+assertEq(sample.includes(-1), true, "-1");
+assertEq(sample.includes(""), true, "the empty string");
+assertEq(sample.includes(symbol), true, "symbol");
+assertEq(sample.includes(tuple), true, "tuple");
+assertEq(sample.includes(record), true, "record");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/search-not-found-returns-false.js b/js/src/tests/non262/Tuple/prototype/includes/search-not-found-returns-false.js
new file mode 100644
index 0000000000..0e1889099f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/search-not-found-returns-false.js
@@ -0,0 +1,26 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: returns false if the element is not found
+---*/
+
+assertEq(#[42].includes(43), false, "43");
+
+assertEq(#["test262"].includes("test"), false, "string");
+
+assertEq(#[0, "test262", undefined].includes(""), false, "the empty string");
+
+assertEq(#["true", false].includes(true), false, "true");
+assertEq(#["", true].includes(false), false, "false");
+
+assertEq(#[undefined, false, 0, 1].includes(null), false, "null");
+assertEq(#[null].includes(undefined), false, "undefined");
+
+assertEq(#[Symbol("1")].includes(Symbol("1")), false, "symbol");
+
+var sample = #[42];
+assertEq(sample.includes(sample), false, "this");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/this-is-not-tuple.js b/js/src/tests/non262/Tuple/prototype/includes/this-is-not-tuple.js
new file mode 100644
index 0000000000..00679f2a73
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/this-is-not-tuple.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: >
+ Throws a TypeError exception when `this` cannot be coerced to Tuple
+---*/
+
+var includes = Tuple.prototype.includes;
+
+assertThrowsInstanceOf(() => includes.call(undefined, 42), TypeError,
+ "this is undefined");
+
+assertThrowsInstanceOf(() => includes.call(null, 42), TypeError,
+ "this is null");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/tointeger-fromindex.js b/js/src/tests/non262/Tuple/prototype/includes/tointeger-fromindex.js
new file mode 100644
index 0000000000..608dbbf732
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/tointeger-fromindex.js
@@ -0,0 +1,40 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: get the integer value from fromIndex
+*/
+
+var obj = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+var sample = #[42, 43];
+assertEq(sample.includes(42, "1"), false, "string [0]");
+assertEq(sample.includes(43, "1"), true, "string [1]");
+
+assertEq(sample.includes(42, true), false, "true [0]");
+assertEq(sample.includes(43, true), true, "true [1]");
+
+assertEq(sample.includes(42, false), true, "false [0]");
+assertEq(sample.includes(43, false), true, "false [1]");
+
+assertEq(sample.includes(42, NaN), true, "NaN [0]");
+assertEq(sample.includes(43, NaN), true, "NaN [1]");
+
+assertEq(sample.includes(42, null), true, "null [0]");
+assertEq(sample.includes(43, null), true, "null [1]");
+
+assertEq(sample.includes(42, undefined), true, "undefined [0]");
+assertEq(sample.includes(43, undefined), true, "undefined [1]");
+
+assertEq(sample.includes(42, null), true, "null [0]");
+assertEq(sample.includes(43, null), true, "null [1]");
+
+assertEq(sample.includes(42, obj), false, "object [0]");
+assertEq(sample.includes(43, obj), true, "object [1]");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/includes/using-fromindex.js b/js/src/tests/non262/Tuple/prototype/includes/using-fromindex.js
new file mode 100644
index 0000000000..7dbcc00c20
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/includes/using-fromindex.js
@@ -0,0 +1,38 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ 22.1.3.11 Tuple.prototype.includes ( searchElement [ , fromIndex ] )
+---*/
+
+var sample = #["a", "b", "c"];
+assertEq(sample.includes("a", 0), true, "includes('a', 0)");
+assertEq(sample.includes("a", 1), false, "includes('a', 1)");
+assertEq(sample.includes("a", 2), false, "includes('a', 2)");
+
+assertEq(sample.includes("b", 0), true, "includes('b', 0)");
+assertEq(sample.includes("b", 1), true, "includes('b', 1)");
+assertEq(sample.includes("b", 2), false, "includes('b', 2)");
+
+assertEq(sample.includes("c", 0), true, "includes('c', 0)");
+assertEq(sample.includes("c", 1), true, "includes('c', 1)");
+assertEq(sample.includes("c", 2), true, "includes('c', 2)");
+
+assertEq(sample.includes("a", -1), false, "includes('a', -1)");
+assertEq(sample.includes("a", -2), false, "includes('a', -2)");
+assertEq(sample.includes("a", -3), true, "includes('a', -3)");
+assertEq(sample.includes("a", -4), true, "includes('a', -4)");
+
+assertEq(sample.includes("b", -1), false, "includes('b', -1)");
+assertEq(sample.includes("b", -2), true, "includes('b', -2)");
+assertEq(sample.includes("b", -3), true, "includes('b', -3)");
+assertEq(sample.includes("b", -4), true, "includes('b', -4)");
+
+assertEq(sample.includes("c", -1), true, "includes('c', -1)");
+assertEq(sample.includes("c", -2), true, "includes('c', -2)");
+assertEq(sample.includes("c", -3), true, "includes('c', -3)");
+assertEq(sample.includes("c", -4), true, "includes('c', -4)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/empty-tuple.js b/js/src/tests/non262/Tuple/prototype/indexOf/empty-tuple.js
new file mode 100644
index 0000000000..1334ba9271
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/empty-tuple.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Tuple.prototype.indexOf returns -1 if 'length' is 0 (empty tuple)
+---*/
+
+var i = #[].indexOf(42);
+
+assertEq(i, -1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-boolean.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-boolean.js
new file mode 100644
index 0000000000..41c064370b
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-boolean.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Tuple.prototype.indexOf when fromIndex is boolean
+---*/
+
+let a = #[1, 2, 3];
+
+assertEq(a.indexOf(1, true), -1);
+assertEq(a.indexOf(1, false), 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-float.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-float.js
new file mode 100644
index 0000000000..1c2995a0af
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-float.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Tuple.prototype.indexOf when fromIndex is floating point number
+---*/
+
+var a = #[1,2,3];
+
+assertEq(a.indexOf(3, 0.49), 2);
+assertEq(a.indexOf(1, 0.51), 0);
+assertEq(a.indexOf(1, 1.51), -1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-greater-than-length.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-greater-than-length.js
new file mode 100644
index 0000000000..3514d0a444
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-greater-than-length.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf returns -1 if fromIndex is greater than
+ Tuple length
+---*/
+
+let a = #[1, 2, 3];
+
+assertEq(a.indexOf(1, 5), -1);
+assertEq(a.indexOf(1, 3), -1);
+assertEq(#[].indexOf(1, 0), -1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-infinity-string.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-infinity-string.js
new file mode 100644
index 0000000000..de5895aca3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-infinity-string.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a string
+ containing -Infinity
+---*/
+
+assertEq(#[true].indexOf(true, "-Infinity"), 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-inherited-valueOf.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-inherited-valueOf.js
new file mode 100644
index 0000000000..a2ad8353bf
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-inherited-valueOf.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf uses inherited valueOf method when value
+ of 'fromIndex' is an object with an own toString and inherited
+ valueOf methods
+---*/
+
+var toStringAccessed = false;
+var valueOfAccessed = false;
+
+var proto = {
+ valueOf: function() {
+ valueOfAccessed = true;
+ return 1;
+ }
+};
+
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+child.toString = function() {
+ toStringAccessed = true;
+ return 2;
+};
+
+assertEq(#[0, true].indexOf(true, child), 1, '[0, true].indexOf(true, child)');
+assertEq(valueOfAccessed, true);
+assertEq(toStringAccessed, false, 'toStringAccessed');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-missing.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-missing.js
new file mode 100644
index 0000000000..6a16da4847
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-missing.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: Tuple.prototype.indexOf - 'fromIndex' isn't passed
+---*/
+
+var arr = #[0, 1, 2, 3, 4];
+//'fromIndex' will be set as 0 if not passed by default
+
+assertEq(arr.indexOf(0), arr.indexOf(0, 0), 'arr.indexOf(0)');
+assertEq(arr.indexOf(2), arr.indexOf(2, 0), 'arr.indexOf(2)');
+assertEq(arr.indexOf(4), arr.indexOf(4, 0), 'arr.indexOf(4)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-nan.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-nan.js
new file mode 100644
index 0000000000..40fdde8a34
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-nan.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a number (value
+ is NaN)
+---*/
+
+assertEq(#[true].indexOf(true, NaN), 0, '[true].indexOf(true, NaN)');
+assertEq(#[true].indexOf(true, -NaN), 0, '[true].indexOf(true, -NaN)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-infinity.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-infinity.js
new file mode 100644
index 0000000000..4595230e83
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-infinity.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a number (value
+ is -Infinity)
+---*/
+
+assertEq(#[true].indexOf(true, -Infinity), 0, '#[true].indexOf(true, -Infinity)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-zero.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-zero.js
new file mode 100644
index 0000000000..2d0d856f4f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-neg-zero.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a number (value
+ is -0)
+---*/
+
+assertEq(#[true].indexOf(true, -0), 0, '#[true].indexOf(true, -0)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-negative.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-negative.js
new file mode 100644
index 0000000000..db87f171d2
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-negative.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a number (value
+ is negative number)
+---*/
+
+var target = #[];
+
+assertEq(#[0, target, 2].indexOf(target, -1), -1, '[0, target, 2].indexOf(target, -1)');
+assertEq(#[0, 1, target].indexOf(target, -1), 2, '[0, 1, target].indexOf(target, -1)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-null.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-null.js
new file mode 100644
index 0000000000..f046fe2398
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-null.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: Tuple.prototype.indexOf returns 0 if fromIndex is null
+---*/
+
+var a = #[1, 2, 3];
+
+// null resolves to 0
+assertEq(a.indexOf(1, null), 0, 'a.indexOf(1,null)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-number.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-number.js
new file mode 100644
index 0000000000..8fc53c3a5a
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-number.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a number (value
+ is 0)
+---*/
+
+assertEq(#[true].indexOf(true, 0), 0, '#[true].indexOf(true, 0)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-not-primitive.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-not-primitive.js
new file mode 100644
index 0000000000..946dc411fc
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-not-primitive.js
@@ -0,0 +1,33 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf throws TypeError exception when value of
+ 'fromIndex' is an object with toString and valueOf methods that
+ don�t return primitive values
+---*/
+
+var toStringAccessed = false;
+var valueOfAccessed = false;
+var fromIndex = {
+ toString: function() {
+ toStringAccessed = true;
+ return {};
+ },
+
+ valueOf: function() {
+ valueOfAccessed = true;
+ return {};
+ }
+};
+
+assertThrowsInstanceOf(function() {
+ #[0, true].indexOf(true, fromIndex);
+}, TypeError);
+
+assertEq(toStringAccessed, true);
+assertEq(valueOfAccessed, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf-toString.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf-toString.js
new file mode 100644
index 0000000000..5568a31bdf
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf-toString.js
@@ -0,0 +1,31 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is an object that
+ has an own valueOf method that returns an object and toString
+ method that returns a string
+---*/
+
+var toStringAccessed = false;
+var valueOfAccessed = false;
+
+var fromIndex = {
+ toString: function() {
+ toStringAccessed = true;
+ return '1';
+ },
+
+ valueOf: function() {
+ valueOfAccessed = true;
+ return {};
+ }
+};
+
+assertEq(#[0, true].indexOf(true, fromIndex), 1, '#[0, true].indexOf(true, fromIndex)');
+assertEq(toStringAccessed, true);
+assertEq(valueOfAccessed, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf.js
new file mode 100644
index 0000000000..c69aadaefb
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object-valueOf.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is an Object, which
+ has an own valueOf method
+---*/
+
+var fromIndex = {
+ valueOf: function() {
+ return 1;
+ }
+};
+
+
+assertEq(#[0, true].indexOf(true, fromIndex), 1, '#[0, true].indexOf(true, fromIndex)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object.js
new file mode 100644
index 0000000000..cb1d74ddf8
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-object.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is an Object, which
+ has an own toString method
+---*/
+
+// objects inherit the default valueOf() method from Object
+// that simply returns itself. Since the default valueOf() method
+// does not return a primitive value, ES next tries to convert the object
+// to a number by calling its toString() method and converting the
+// resulting string to a number.
+var fromIndex = {
+ toString: function() {
+ return '1';
+ }
+};
+
+assertEq(#[0, true].indexOf(true, fromIndex), 1, '#[0, true].indexOf(true, fromIndex)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-positive.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-positive.js
new file mode 100644
index 0000000000..c5b1948356
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-positive.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a number (value
+ is positive number)
+---*/
+
+var target = #[];
+
+assertEq(#[0, target, 2].indexOf(target, 2), -1, '#[0, target, 2].indexOf(target, 2)');
+assertEq(#[0, 1, target].indexOf(target, 2), 2, '#[0, 1, target].indexOf(target, 2)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-side-effects-3.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-side-effects-3.js
new file mode 100644
index 0000000000..b2a98cc58a
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-side-effects-3.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - side effects produced by step 1 are
+ visible when an exception occurs
+---*/
+
+var stepFiveOccurs = false;
+var fromIndex = {
+ valueOf: function() {
+ stepFiveOccurs = true;
+ return 0;
+ }
+};
+assertThrowsInstanceOf(function() {
+ Tuple.prototype.indexOf.call(undefined, undefined, fromIndex);
+}, TypeError);
+assertEq(stepFiveOccurs, false, 'stepFiveOccurs');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-2.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-2.js
new file mode 100644
index 0000000000..ca7591a49b
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-2.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Tuple.prototype.indexOf when fromIndex is string
+---*/
+
+var a = #[1, 2, 1, 2, 1, 2];
+
+assertEq(a.indexOf(2, "2"), 3, '"2" resolves to 2');
+assertEq(a.indexOf(2, "one"), 1, '"one" resolves to 0');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-exponent.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-exponent.js
new file mode 100644
index 0000000000..a544e56717
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-exponent.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a string
+ containing an exponential number
+---*/
+
+var target = #[];
+
+assertEq(#[0, 1, target, 3, 4].indexOf(target, "3E0"), -1, '#[0, 1, target, 3, 4].indexOf(target, "3E0")');
+assertEq(#[0, 1, 2, target, 4].indexOf(target, "3E0"), 3, '#[0, 1, 2, target, 4].indexOf(target, "3E0")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-hex.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-hex.js
new file mode 100644
index 0000000000..633a2688b3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-hex.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a string
+ containing a hex number
+---*/
+
+var target = #[];
+
+assertEq(#[0, 1, target, 3, 4].indexOf(target, "0x0003"), -1, '#[0, 1, target, 3, 4].indexOf(target, "0x0003")');
+assertEq(#[0, 1, 2, target, 4].indexOf(target, "0x0003"), 3, '#[0, 1, 2, target, 4].indexOf(target, "0x0003")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-leading-zeros.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-leading-zeros.js
new file mode 100644
index 0000000000..805516e4fa
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-leading-zeros.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' which is a string
+ containing a number with leading zeros
+---*/
+
+var target = #[];
+
+assertEq(#[0, 1, target, 3, 4].indexOf(target, "0003.10"), -1, '#[0, 1, target, 3, 4].indexOf(target, "0003.10")');
+assertEq(#[0, 1, 2, target, 4].indexOf(target, "0003.10"), 3, '#[0, 1, 2, target, 4].indexOf(target, "0003.10")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-neg-infinity.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-neg-infinity.js
new file mode 100644
index 0000000000..7595ab2bb5
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-neg-infinity.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a string
+ containing -Infinity
+---*/
+
+assertEq(#[true].indexOf(true, "-Infinity"), 0, '#[true].indexOf(true, "-Infinity")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-negative.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-negative.js
new file mode 100644
index 0000000000..1b1c330725
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string-negative.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a string
+ containing a negative number
+---*/
+
+assertEq(#[0, true, 2].indexOf(true, "-1"), -1, '#[0, true, 2].indexOf(true, "-1")');
+assertEq(#[0, 1, true].indexOf(true, "-1"), 2, '#[0, 1, true].indexOf(true, "-1")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string.js
new file mode 100644
index 0000000000..1b1c330725
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-string.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a string
+ containing a negative number
+---*/
+
+assertEq(#[0, true, 2].indexOf(true, "-1"), -1, '#[0, true, 2].indexOf(true, "-1")');
+assertEq(#[0, 1, true].indexOf(true, "-1"), 2, '#[0, 1, true].indexOf(true, "-1")');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc-2.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc-2.js
new file mode 100644
index 0000000000..4d08a4700d
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc-2.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf - 'fromIndex' is a negative non-integer,
+ verify truncation occurs in the proper direction
+---*/
+
+var target = #[];
+
+assertEq(#[0, target, 2].indexOf(target, -1.5), -1, '#[0, target, 2].indexOf(target, -1.5)');
+assertEq(#[0, 1, target].indexOf(target, -1.5), 2, '#[0, 1, target].indexOf(target, -1.5)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc.js
new file mode 100644
index 0000000000..a9cbd3fa9c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-trunc.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.indexof
+description: >
+ Tuple.prototype.indexOf - 'fromIndex' is a positive non-integer,
+ verify truncation occurs in the proper direction
+---*/
+
+var target = #[];
+
+assertEq(#[0, target, 2].indexOf(target, 2.5), -1, '#[0, target, 2].indexOf(target, 2.5)');
+assertEq(#[0, 1, target].indexOf(target, 2.5), 2, '#[0, 1, target].indexOf(target, 2.5)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-undefined.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-undefined.js
new file mode 100644
index 0000000000..054495a9d9
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-undefined.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Tuple.prototype.indexOf returns 0 if fromIndex is 'undefined'
+---*/
+
+var a = #[1, 2, 3];
+
+// undefined resolves to 0
+assertEq(a.indexOf(1, undefined), 0, 'a.indexOf(1,undefined)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-with-index.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-with-index.js
new file mode 100644
index 0000000000..75a5e5266f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-with-index.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf match on the first element, a middle
+ element and the last element when 'fromIndex' is passed
+---*/
+
+assertEq(#[0, 1, 2, 3, 4].indexOf(0, 0), 0, '#[0, 1, 2, 3, 4].indexOf(0, 0)');
+assertEq(#[0, 1, 2, 3, 4].indexOf(2, 1), 2, '#[0, 1, 2, 3, 4].indexOf(2, 1)');
+assertEq(#[0, 1, 2, 3, 4].indexOf(2, 2), 2, '#[0, 1, 2, 3, 4].indexOf(2, 2)');
+assertEq(#[0, 1, 2, 3, 4].indexOf(4, 2), 4, '#[0, 1, 2, 3, 4].indexOf(4, 2)');
+assertEq(#[0, 1, 2, 3, 4].indexOf(4, 4), 4, '#[0, 1, 2, 3, 4].indexOf(4, 4)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-zero.js b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-zero.js
new file mode 100644
index 0000000000..0fa7d114e9
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/fromIndex-zero.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - value of 'fromIndex' is a number (value
+ is +0)
+---*/
+
+assertEq(#[true].indexOf(true, +0), 0, '#[true].indexOf(true, +0)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/includes.js b/js/src/tests/non262/Tuple/prototype/indexOf/includes.js
new file mode 100644
index 0000000000..26ef2bfb03
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/includes.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.7 Tuple.prototype.includes ( searchElement [ , fromIndex ] )
+Tuple.prototype.includes is a distinct function that implements the same algorithm as Array.prototype.includes as defined in 22.1.3.13 except that ? thisTupleValue(this value) is used instead of directly accessing the this value. The implementation of the algorithm may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse, do not change, and their access is not observable. However, such optimization must not introduce any observable changes in the specified behaviour of the algorithm.
+
+This function is not generic, since thisTupleValue(this value) can return an abrupt completion: in that case, that exception is thrown instead of evaluating the algorithm.
+*/
+
+/* Step 1 */
+/* includes() should throw on a non-Tuple */
+let method = Tuple.prototype.includes;
+assertEq(method.call(#[1,2,3,4,5,6], 2), true);
+assertEq(method.call(Object(#[1,2,3,4,5,6]), 2), true);
+assertThrowsInstanceOf(() => method.call("monkeys", 2), TypeError,
+ "value of TupleObject must be a Tuple");
+
+/* Not sure what else to test, since it just calls the array method */
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/length-internal.js b/js/src/tests/non262/Tuple/prototype/indexOf/length-internal.js
new file mode 100644
index 0000000000..a199884f00
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/length-internal.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/* Tuples should have a length ownProperty that can't be overridden, which will
+ * be read by any built-in methods called on Tuples.
+ * This test is expected to fail until the spec change in
+ * https://github.com/tc39/proposal-record-tuple/issues/282 is implemented.
+ */
+
+/*
+t = #[1,2,3];
+Object.defineProperty(Tuple.prototype, "length", {value: 0});
+assertEq(t.includes(2), true);
+*/
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/length.js b/js/src/tests/non262/Tuple/prototype/indexOf/length.js
new file mode 100644
index 0000000000..46cd2b914b
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.indexOf, "length");
+assertEq(desc.value, 1);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.indexOf, "name");
+assertEq(desc.value, "indexOf");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "indexOf");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.indexOf), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.indexOf();
+}, TypeError, '`let t = #[1]; new t.indexOf()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/undefined-throws-type-error.js b/js/src/tests/non262/Tuple/prototype/indexOf/undefined-throws-type-error.js
new file mode 100644
index 0000000000..da72398b79
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/undefined-throws-type-error.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Tuple.prototype.indexOf applied to undefined throws a TypeError
+---*/
+
+
+assertThrowsInstanceOf(function() {
+ Tuple.prototype.indexOf.call(undefined);
+}, TypeError);
+
+assertThrowsInstanceOf(function() {
+ Tuple.prototype.indexOf.call(null);
+}, TypeError);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/indexOf/uses-internal-length.js b/js/src/tests/non262/Tuple/prototype/indexOf/uses-internal-length.js
new file mode 100644
index 0000000000..8c8cc1beb4
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/indexOf/uses-internal-length.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (c) 2012 Ecma International. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Tuple.prototype.indexOf - 'length' is own data property that
+ overrides an inherited data property on an Tuple
+---*/
+
+var target = #[];
+
+Tuple.prototype.length = 0;
+
+assertEq(#[0, target].indexOf(target), 1, '#[0, target].indexOf(target)');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/isTuple/isTuple.js b/js/src/tests/non262/Tuple/prototype/isTuple/isTuple.js
new file mode 100644
index 0000000000..714c9cab42
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/isTuple/isTuple.js
@@ -0,0 +1,47 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var f = Tuple.isTuple;
+
+assertEq(typeof f, "function");
+assertEq(f.length, 1);
+assertEq(f(#[]), true);
+assertEq(f(#[1]), true);
+assertEq(f(#[1,2,3]), true);
+assertEq(f(Object(#[])), true);
+assertEq(f(Object(#[1])), true);
+assertEq(f(Object(#[1,2,3])), true);
+
+for (thing of [42, new Number(-42), undefined, true, false, "abc" , new String("a\nb\\!"), {}, [], [1,2,3], new Uint8Array(1,2,3), null, new RegExp(), JSON, new SyntaxError(), function() {}, Math, new Date()]) {
+ assertEq(f(thing), false);
+}
+assertEq(f(Tuple.prototype), false);
+var arg;
+(function fun() { arg = arguments; }(1,2,3));
+assertEq(f(arg), false);
+assertEq(f(this), false);
+
+var proto = [];
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+assertEq(f(child), false);
+
+var proto = Tuple.prototype;
+var Con = function() {};
+Con.prototype = proto;
+
+var child = new Con();
+
+assertEq(f(child), false);
+
+assertEq(f({
+ 0: 12,
+ 1: 9,
+ length: 2
+}), false);
+
+
+reportCompare(0, 0);
+
+
diff --git a/js/src/tests/non262/Tuple/prototype/isTuple/length.js b/js/src/tests/non262/Tuple/prototype/isTuple/length.js
new file mode 100644
index 0000000000..75acb7aedd
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/isTuple/length.js
@@ -0,0 +1,22 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.isTuple, "length");
+assertEq(desc.value, 1);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.isTuple, "name");
+assertEq(desc.value, "isTuple");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.isTuple), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.isTuple()();
+}, TypeError, '`let t = #[1]; new t.isTuple()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/join/browser.js b/js/src/tests/non262/Tuple/prototype/join/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/join/browser.js
diff --git a/js/src/tests/non262/Tuple/prototype/join/dda-separator.js b/js/src/tests/non262/Tuple/prototype/join/dda-separator.js
new file mode 100644
index 0000000000..cee96a708d
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/join/dda-separator.js
@@ -0,0 +1,17 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+let dda = createIsHTMLDDA();
+
+assertEq(dda == null, true);
+assertEq(dda === null, false);
+
+assertEq(dda == undefined, true);
+assertEq(dda === undefined, false);
+
+let tup = Tuple("A", "B");
+assertEq(tup.join(null), "A,B");
+assertEq(tup.join(undefined), "A,B");
+assertEq(tup.join(dda), "A" + dda.toString() + "B");
+
+if (typeof reportCompare === "function")
+ reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/join/shell.js b/js/src/tests/non262/Tuple/prototype/join/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/join/shell.js
diff --git a/js/src/tests/non262/Tuple/prototype/length/length-getter.js b/js/src/tests/non262/Tuple/prototype/length/length-getter.js
new file mode 100644
index 0000000000..7d07c152e3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/length/length-getter.js
@@ -0,0 +1,42 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*---
+esid: sec-get-%tuple%.prototype.length
+description: >
+info: |
+ get %Tuple%.prototype.length
+
+Tuple.prototype.length is an accessor property whose set accessor function is undefined. Its get accessor function performs the following steps:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let size be the length of T.[[Sequence]].
+3. Return size.
+
+features: [Tuple]
+---*/
+
+/* Section 8.2.3.2 */
+
+let TuplePrototype = Tuple.prototype;
+let desc = Object.getOwnPropertyDescriptor(TuplePrototype, "length");
+
+assertEq(typeof desc.get, "function");
+
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(desc.set, undefined);
+
+let values = [[#[1,2,3], 3], [#[1], 1], [#[], 0]];
+
+for (pair of values) {
+ let tup = pair[0];
+ let len = pair[1];
+ assertEq(desc.get.call(tup), len);
+ assertEq(desc.get.call(Object(tup)), len);
+ assertEq(tup["length"], len);
+}
+
+assertThrowsInstanceOf(() => desc.get.call("monkeys"), TypeError, "get length method called on incompatible string");
+assertThrowsInstanceOf(() => desc.get.call(new Object()), TypeError, "get length method called on incompatible Object");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/callback-not-called-on-empty.js b/js/src/tests/non262/Tuple/prototype/map/callback-not-called-on-empty.js
new file mode 100644
index 0000000000..a28699c282
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/callback-not-called-on-empty.js
@@ -0,0 +1,7 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var called = 0;
+#[].map(() => called++);
+assertEq(called, 0);
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg b/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg
new file mode 100644
index 0000000000..88a9454e87
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg
@@ -0,0 +1,45 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%Tuple%.prototype.map
+description: >
+ callbackfn arguments
+info: |
+ 8.2.3.20 %Tuple%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+7. Repeat, while k < len,
+a. Let kValue be list[k].
+b. Let mappedValue be ? Call(callbackfn, thisArg, « kValue, k, T »).
+ ...
+features: [Tuple]
+---*/
+
+var sample = #[42,43,44];
+
+var results = [];
+
+sample.map(function() {
+ results.push(arguments);
+ return 0;
+});
+
+assertEq(results.length, 3);
+
+assertEq(results[0].length, 3);
+assertEq(results[0][0], 42);
+assertEq(results[0][1], 0);
+assertEq(results[0][2], sample);
+
+assertEq(results[1].length, 3);
+assertEq(results[1][0], 43);
+assertEq(results[1][1], 1);
+assertEq(results[1][2], sample);
+
+assertEq(results[2].length, 3);
+assertEq(results[2][0], 44);
+assertEq(results[2][1], 2);
+assertEq(results[2][2], sample);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg.js b/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg.js
new file mode 100644
index 0000000000..380f493995
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-with-thisarg.js
@@ -0,0 +1,43 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%Tuple%.prototype.map
+description: >
+ callbackfn arguments
+info: |
+ 8.2.3.20 %Tuple%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+7. Repeat, while k < len,
+a. Let kValue be list[k].
+b. Let mappedValue be ? Call(callbackfn, thisArg, « kValue, k, T »).
+ ...
+features: [Tuple]
+---*/
+
+var sample = #[42,43,44];
+var results = [];
+var thisArg = ["monkeys", 0, "bunnies", 0];
+
+sample.map(function() { results.push(arguments); return 0; }, thisArg);
+
+assertEq(results.length, 3);
+assertEq(thisArg.length, 4);
+
+assertEq(results[0].length, 3);
+assertEq(results[0][0], 42);
+assertEq(results[0][1], 0);
+assertEq(results[0][2], sample);
+
+assertEq(results[1].length, 3);
+assertEq(results[1][0], 43);
+assertEq(results[1][1], 1);
+assertEq(results[1][2], sample);
+
+assertEq(results[2].length, 3);
+assertEq(results[2][0], 44);
+assertEq(results[2][1], 2);
+assertEq(results[2][2], sample);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-without-thisarg.js b/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-without-thisarg.js
new file mode 100644
index 0000000000..88a9454e87
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/callbackfn-arguments-without-thisarg.js
@@ -0,0 +1,45 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%Tuple%.prototype.map
+description: >
+ callbackfn arguments
+info: |
+ 8.2.3.20 %Tuple%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+7. Repeat, while k < len,
+a. Let kValue be list[k].
+b. Let mappedValue be ? Call(callbackfn, thisArg, « kValue, k, T »).
+ ...
+features: [Tuple]
+---*/
+
+var sample = #[42,43,44];
+
+var results = [];
+
+sample.map(function() {
+ results.push(arguments);
+ return 0;
+});
+
+assertEq(results.length, 3);
+
+assertEq(results[0].length, 3);
+assertEq(results[0][0], 42);
+assertEq(results[0][1], 0);
+assertEq(results[0][2], sample);
+
+assertEq(results[1].length, 3);
+assertEq(results[1][0], 43);
+assertEq(results[1][1], 1);
+assertEq(results[1][2], sample);
+
+assertEq(results[2].length, 3);
+assertEq(results[2][0], 44);
+assertEq(results[2][1], 2);
+assertEq(results[2][2], sample);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/callbackfn-is-not-callable.js b/js/src/tests/non262/Tuple/prototype/map/callbackfn-is-not-callable.js
new file mode 100644
index 0000000000..e2a3c10bcb
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/callbackfn-is-not-callable.js
@@ -0,0 +1,40 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%Tuple%.prototype.map
+description: >
+ callbackfn arguments
+info: |
+ 8.2.3.20 %Tuple%.prototype.map ( callbackfn [ , thisArg ] )
+
+ ...
+ 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+ ...
+features: [Tuple]
+---*/
+
+var sample = #[1,2,3];
+
+assertThrowsInstanceOf(() => sample.map(), TypeError,
+ "map: callbackfn is not callable (no argument)");
+
+assertThrowsInstanceOf(() => sample.map(undefined), TypeError,
+ "map: callbackfn is not callable (undefined)");
+
+assertThrowsInstanceOf(() => sample.map(null), TypeError,
+ "map: callbackfn is not callable (null)");
+
+assertThrowsInstanceOf(() => sample.map({}), TypeError,
+ "map: callbackfn is not callable ({})");
+
+assertThrowsInstanceOf(() => sample.map(1), TypeError,
+ "map: callbackfn is not callable (1)");
+
+assertThrowsInstanceOf(() => sample.map(""), TypeError,
+ "map: callbackfn is not callable (\"\")");
+
+assertThrowsInstanceOf(() => sample.map(false), TypeError,
+ "map: callbackfn is not callable (false)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/callbackfn-returns-abrupt.js b/js/src/tests/non262/Tuple/prototype/map/callbackfn-returns-abrupt.js
new file mode 100644
index 0000000000..1819aac0c4
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/callbackfn-returns-abrupt.js
@@ -0,0 +1,8 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var sample = #[1,2,3];
+
+assertThrowsInstanceOf(() => sample.map(function () { throw new TypeError("monkeys"); }),
+ TypeError,
+ "should throw TypeError: monkeys");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/indexed-setters.js b/js/src/tests/non262/Tuple/prototype/map/indexed-setters.js
new file mode 100644
index 0000000000..774f1dc349
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/indexed-setters.js
@@ -0,0 +1,12 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// If an indexed Array setter is overridden, TupleMap shouldn't use it
+// when constructing the intermediate array
+
+z = 5;
+Object.defineProperty(Array.prototype, '0', { set: function(y) { z = 42; }});
+newT = #[1,2,3].map(x => x*x);
+assertEq(z, 5);
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/map/invoked-as-func.js b/js/src/tests/non262/Tuple/prototype/map/invoked-as-func.js
new file mode 100644
index 0000000000..6a485157b2
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/invoked-as-func.js
@@ -0,0 +1,6 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var map = Tuple.prototype.map;
+
+assertEq(typeof map, 'function');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/invoked-as-method.js b/js/src/tests/non262/Tuple/prototype/map/invoked-as-method.js
new file mode 100644
index 0000000000..bf838117b8
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/invoked-as-method.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var TuplePrototype = Tuple.prototype;
+
+assertEq(typeof TuplePrototype.map, 'function');
+
+assertThrowsInstanceOf(function() {
+ TuplePrototype.map();
+}, TypeError, "Tuple.prototype.map() with no argument");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/length-internal.js b/js/src/tests/non262/Tuple/prototype/map/length-internal.js
new file mode 100644
index 0000000000..9d4538288c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/length-internal.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+Object.defineProperty(Tuple.prototype, "length", {value: 0});
+let t = #[1,2,3];
+var result = t.map(x => x + 1);
+// overriding length shouldn't have an effect
+assertEq(result, #[2,3,4]);
+
+
+Object.defineProperty(Tuple.prototype, "length", {
+ get() { return 0 }
+});
+let u = #[1,2,3];
+var result = u.map(x => x + 1);
+// overriding length shouldn't have an effect
+assertEq(result, #[2,3,4]);
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/map/length.js b/js/src/tests/non262/Tuple/prototype/map/length.js
new file mode 100644
index 0000000000..02d77af7ed
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.map, "length");
+assertEq(desc.value, 1);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.map, "name");
+assertEq(desc.value, "map");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "map");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.map), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.map();
+}, TypeError, '`let t = #[1]; new t.map()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/map.js b/js/src/tests/non262/Tuple/prototype/map/map.js
new file mode 100644
index 0000000000..40f871b1d2
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/map.js
@@ -0,0 +1,85 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.20 Tuple.prototype.map ( callbackfn [ , thisArg ] )
+NOTE
+callbackfn should be a function that accepts three arguments. map calls callbackfn once for each element in the Tuple, in ascending order, and constructs a new tuple from the results.
+
+If a thisArg parameter is provided, it will be used as the this value for each invocation of callbackfn. If it is not provided, undefined is used instead.
+
+callbackfn is called with three arguments: the value of the element, the index of the element, and the Tuple being traversed.
+
+When the map method is called with one or two arguments, the following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be T.[[Sequence]].
+3. Let len be the number of elements in list.
+4. If IsCallable(callbackfn) is false, throw a TypeError exception.
+5. Let newList be a new empty List.
+6. Let k be 0.
+7. Repeat, while k < len,
+a. Let kValue be list[k].
+b. Let mappedValue be ? Call(callbackfn, thisArg, « kValue, k, T »).
+c. If Type(mappedValue) is Object, throw a TypeError exception.
+d. Append mappedValue to the end of list newList.
+e. Set k to k + 1.
+8. Return a new Tuple value whose [[Sequence]] is newList.
+
+*/
+
+/* Step 1 */
+/* map() should throw on a non-Tuple */
+let method = Tuple.prototype.map;
+let f = (x, i, tup) => x + 1;
+assertEq(method.call(#[1,2,3,4,5,6],f), #[2,3,4,5,6,7]);
+assertEq(method.call(Object(#[1,2,3,4,5,6]), f), #[2,3,4,5,6,7]);
+assertThrowsInstanceOf(() => method.call("monkeys", f), TypeError,
+ "value of TupleObject must be a Tuple");
+
+let tup = #[1,2,3];
+
+/* Step 4 */
+/* callbackfn not callable -- should throw */
+assertThrowsInstanceOf(() => tup.map(), TypeError,
+ "missing function argument to Tuple.prototype.map");
+assertThrowsInstanceOf(() => tup.map(undefined), TypeError,
+ "missing function argument to Tuple.prototype.map");
+assertThrowsInstanceOf(() => tup.map("monkeys"), TypeError,
+ "bad function argument to Tuple.prototype.map");
+
+
+/* callbackfn with 1 argument -- should be allowed */
+var f2 = x => x * x;
+assertEq(tup.map(f2), #[1, 4, 9]);
+
+/* callbackfn with 2 arguments -- should be allowed */
+f2 = (x, i) => x + i;
+assertEq(tup.map(f2), #[1, 3, 5]);
+
+/* callbackfn with > 3 arguments -- subsequent ones will be undefined */
+var f3 = (a, b, c, d, e) => e === undefined;
+assertEq(tup.map(f3), #[true, true, true]);
+
+/* callbackfn should be able to use index and tuple */
+var f4 = (x, i, tup) => (tup.indexOf(x+1) * i * x);
+assertEq(tup.map(f4), #[0, 4, -6]);
+
+/* explicit thisArg */
+f1 = function (x, i, tup) { return(this.elements.indexOf(x) * x); };
+assertEq(#[1,2,3,4,5].map(f1, { elements: [2, 4] }), #[-1, 0, -3, 4, -5]);
+
+/* Step 3 */
+/* Test that length is still handled correctly if it's overridden */
+Object.defineProperty(Tuple.prototype, "length", { get() { return 0 } })
+assertEq(tup.map(f), #[2,3,4]);
+
+/* Step 7 */
+assertEq(#[].map(f), #[]);
+assertEq(#[1].map(f), #[2]);
+assertEq(#[1,2].map(f), #[2,3]);
+
+/* Step 7c. */
+var badFun = x => new Object(x);
+assertThrowsInstanceOf(() => tup.map(badFun),
+ TypeError, "Tuples cannot contain Objects");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/map/this-is-not-tuple.js b/js/src/tests/non262/Tuple/prototype/map/this-is-not-tuple.js
new file mode 100644
index 0000000000..5464da96f5
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/map/this-is-not-tuple.js
@@ -0,0 +1,30 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-%typedarray%.prototype.map
+description: Throws a TypeError exception when `this` is not a Tuple
+info: |
+
+features: [Tuple]
+---*/
+
+var map = Tuple.prototype.map;
+var callbackfn = function() {};
+
+var thisVals = [[undefined, "undefined"],
+ [null, "null"],
+ [42, "42"],
+ ["1", "1"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol("s"), "Symbol(\"s\")"]];
+
+for (pair of thisVals) {
+ thisVal = pair[0];
+ errorMsg = "this is: " + pair[1];
+ assertThrowsInstanceOf(() => map.call(thisVal, callbackfn),
+ TypeError, errorMsg);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/invoked-as-func.js b/js/src/tests/non262/Tuple/prototype/slice/invoked-as-func.js
new file mode 100644
index 0000000000..961ed9aff5
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/invoked-as-func.js
@@ -0,0 +1,7 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var slice = Tuple.prototype.slice;
+
+assertThrowsInstanceOf(function() { slice() }, TypeError,
+ "value of TupleObject must be a Tuple");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/invoked-as-method.js b/js/src/tests/non262/Tuple/prototype/slice/invoked-as-method.js
new file mode 100644
index 0000000000..291bf433cd
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/invoked-as-method.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var TuplePrototype = Tuple.prototype;
+
+assertEq(typeof TuplePrototype.slice, 'function');
+
+assertThrowsInstanceOf(function() { TuplePrototype.slice() }, TypeError,
+ "value of TupleObject must be a Tuple");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/length.js b/js/src/tests/non262/Tuple/prototype/slice/length.js
new file mode 100644
index 0000000000..d0e9359934
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/length.js
@@ -0,0 +1,26 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.slice, "length");
+assertEq(desc.value, 2);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.slice, "name");
+assertEq(desc.value, "slice");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "slice");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.slice), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.slice();
+}, TypeError, '`let t = #[1]; new t.slice()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/name.js b/js/src/tests/non262/Tuple/prototype/slice/name.js
new file mode 100644
index 0000000000..19b6957105
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/name.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.slice, "name");
+assertEq(desc.value, "slice");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/negative-zero.js b/js/src/tests/non262/Tuple/prototype/slice/negative-zero.js
new file mode 100644
index 0000000000..029455c5d0
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/negative-zero.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var sample = #[40,41,42,43];
+
+assertEq(sample.slice(-0), sample);
+assertEq(sample.slice(-0, 4), sample);
+assertEq(sample.slice(0, -0), #[]);
+assertEq(sample.slice(-0, -0), #[]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/not-a-constructor.js b/js/src/tests/non262/Tuple/prototype/slice/not-a-constructor.js
new file mode 100644
index 0000000000..ebd27dd17d
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/not-a-constructor.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+assertEq(isConstructor(Tuple.prototype.slice), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.slice();
+}, TypeError, '`let t = #[1]; new t.slice()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/prop-desc.js b/js/src/tests/non262/Tuple/prototype/slice/prop-desc.js
new file mode 100644
index 0000000000..1eda464d2f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/prop-desc.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "slice");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+assertEq(typeof Tuple.prototype.slice, 'function');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-end.js b/js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-end.js
new file mode 100644
index 0000000000..9d9f8733a3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-end.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var o1 = { valueOf: function() { throw new SyntaxError(); } };
+var o2 = { toString: function() { throw new SyntaxError(); } };
+
+var sample = #[];
+
+assertThrowsInstanceOf(() => sample.slice(0, o1),
+ SyntaxError, "valueOf throws");
+assertThrowsInstanceOf(() => sample.slice(0, o2),
+ SyntaxError, "toString throws");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-start.js b/js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-start.js
new file mode 100644
index 0000000000..0c8b23acf7
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/return-abrupt-from-start.js
@@ -0,0 +1,13 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var o1 = { valueOf: function() { throw new SyntaxError(); } };
+var o2 = { toString: function() { throw new SyntaxError(); } };
+
+var sample = #[];
+
+assertThrowsInstanceOf(() => sample.slice(o1),
+ SyntaxError, "valueOf throws");
+assertThrowsInstanceOf(() => sample.slice(o2),
+ SyntaxError, "toString throws");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/slice.js b/js/src/tests/non262/Tuple/prototype/slice/slice.js
new file mode 100644
index 0000000000..c1d30dfefa
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/slice.js
@@ -0,0 +1,176 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.5 Tuple.prototype.slice ( start, end )
+When the slice method is called with two arguments, start and end, and returns a Tuple containing the elements of the Tuple from element start up to, but not including, element end (or through the end of the tuple if end is undefined). If start is negative, it is treated as length + start where length is the length of the tuple. If end is negative, it is treated as length + end where length is the length of the tuple.
+
+The following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be T.[[Sequence]].
+3. Let len be the number of elements in list.
+4. Let relativeStart be ? ToInteger(start).
+5. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len).
+6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
+7. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len).
+8. Let newList be a new empty List.
+9. Repeat, while k < final,
+a. Let kValue be list[k].
+b. Assert: Type(kValue) is not Object.
+c. Append kValue to the end of newList.
+d. Set k to k + 1.
+10. Return a new Tuple value whose [[Sequence]] is newList.
+*/
+
+/* Step 1 */
+/* slice() should throw on a non-Tuple */
+let method = Tuple.prototype.slice;
+assertEq(method.call(#[1,2,3,4,5,6], 2, 4), #[3,4]);
+assertEq(method.call(Object(#[1,2,3,4,5,6]), 2, 4), #[3,4]);
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(true), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(false), TypeError,
+ "value of TupleObject must be a Tuple");
+
+
+let tup = #[1,2,3];
+let len = 3;
+/* Step 4 -- toInteger returns 0 for non-integers */
+assertEq(tup.slice("monkeys", 4), tup.slice(0, 4));
+assertThrowsInstanceOf(() => tup.slice(Symbol("1"), 4),
+ TypeError, "can't convert symbol to number");
+assertEq(tup.slice(undefined, 4), tup.slice(0, 4));
+assertEq(tup.slice(undefined), tup.slice(0));
+assertEq(tup.slice(NaN), tup.slice(0));
+assertEq(tup.slice(Number.POSITIVE_INFINITY), tup.slice(len));
+assertEq(tup.slice(Number.NEGATIVE_INFINITY), tup.slice(0));
+assertEq(tup.slice({valueOf: function() { return 0 },
+ toString: function() { return 3 }}),
+ tup.slice(0, 3));
+assertEq(tup.slice(), tup.slice(0));
+
+
+/* Step 5 -- if relativeStart < 0, k should be max((len + relativeStart), 0) */
+/* Case 1: len + relativeStart > 0 */
+var relativeStart = -2;
+assertEq(tup.slice(relativeStart, 4), tup.slice(len + relativeStart, 4));
+/* Case 2: len + relativeStart === 0 */
+relativeStart = (-1 * len);
+assertEq(tup.slice(relativeStart, 4), tup.slice(0, 4));
+/* Case 3: len + relativeStart < 0 */
+relativeStart = -256;
+assertEq(tup.slice(relativeStart, 4), tup.slice(0, 4));
+
+/* Step 5 -- start positive, end positive */
+var tup2 = #[1,2,3,4,5,6,7];
+relativeStart = 2;
+/* length > end > start */
+assertEq(tup2.slice(relativeStart, 4), #[3,4]);
+/* start == len */
+/* length == end == start */
+assertEq(tup2.slice(tup2.length, tup2.length), #[]);
+/* start > len */
+/* start > end == len */
+assertEq(tup2.slice(tup2.length + 5, tup2.length), tup2.slice(tup2.length, tup2.length));
+/* length > end > start = 0 */
+relativeStart = 0;
+assertEq(tup2.slice(relativeStart, 4), #[1,2,3,4]);
+/* length > end == start > 0 */
+relativeStart = 2;
+assertEq(tup2.slice(relativeStart, relativeStart), #[]);
+/* length > start > end > 0 */
+relativeStart = 4;
+relativeEnd = 2;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[]);
+/* length = end > start > 0 */
+relativeEnd = tup2.length;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[5,6,7]);
+/* end > length > start > 0 */
+relativeEnd = tup2.length + 3;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[5,6,7]);
+
+/* length > end == abs(start), start < 0 */
+relativeStart = -4;
+relativeEnd = 4;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[4]);
+/* length == end > abs(start), start < 0 */
+relativeEnd = tup2.length;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[4,5,6,7]);
+/* abs(start) = length > end > 0, start < 0 */
+relativeStart = -1*tup2.length;
+relativeEnd = 5;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[1,2,3,4,5]);
+/* abs(start) > length = end > 0 */
+relativeStart = (-1*tup2.length) - 4;
+relativeEnd = tup2.length;
+assertEq(tup2.slice(relativeStart, relativeEnd), tup2);
+
+/* Step 6 -- if end is undefined, let relativeEnd = len */
+assertEq(tup.slice(2, undefined), tup.slice(2, len));
+assertEq(tup.slice(2), tup.slice(2, len));
+/* relativeEnd converted with toInteger */
+assertEq(tup.slice(2, "monkeys"), tup.slice(2, 0));
+assertThrowsInstanceOf(() => tup.slice(2, Symbol("x")),
+ TypeError, "can't convert Symbol to Number");
+assertEq(tup.slice(2, 2.5), tup.slice(2, 0));
+assertEq(tup.slice(2, NaN), tup.slice(2, 0));
+assertEq(tup.slice(2, Number.POSITIVE_INFINITY), tup.slice(2, len));
+assertEq(tup.slice(2, Number.NEGATIVE_INFINITY), tup.slice(2, 0));
+assertEq(tup.slice(0, Number.POSITIVE_INFINITY), tup.slice(0, len));
+assertEq(tup.slice(0, Number.NEGATIVE_INFINITY), tup.slice(0, 0));
+assertEq(tup.slice({valueOf: function() { return 3 },
+ toString: function() { return 0 }}),
+ tup.slice(0, 0));
+
+/* Step 7 -- if relativeEnd < 0, final should be max((len + relativeEnd), 0) */
+/* Case 1: len + relativeEnd > 0 */
+var relativeEnd = -1;
+relativeStart = 2;
+assertEq(tup.slice(relativeStart, relativeEnd), tup.slice(relativeStart, len + relativeEnd));
+/* Case 2: len + relativeEnd === 0 */
+relativeEnd = (-1 * len);
+assertEq(tup.slice(relativeStart, relativeEnd), tup.slice(relativeStart, 0));
+/* Case 3: len + relativeEnd < 0 */
+relativeEnd = -256;
+assertEq(tup.slice(relativeStart, relativeEnd), tup.slice(relativeStart, 0));
+/* start and end both negative */
+relativeStart = -3;
+relativeEnd = -1;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[5, 6]);
+relativeEnd = (-1*len);
+assertEq(tup2.slice(relativeStart, relativeEnd), #[]);
+relativeEnd = -256;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[]);
+
+/* length > abs(end) > start === 0 */
+relativeStart = 0;
+relativeEnd = -3;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[1,2,3,4]);
+/* length > abs(end) > start > 0 */
+relativeStart = 2;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[3,4]);
+/* length == abs(end) > start == 0 */
+relativeEnd = -1*tup2.length;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[]);
+/* abs(end) > length > start > 0 */
+relativeEnd = (-1*tup2.length) - 5;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[]);
+/* -length == start < end < 0 */
+relativeStart = -1*tup2.length;
+relativeEnd = 5;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[1,2,3,4,5]);
+/* -length < start < end < 0 */
+relativeStart = -3;
+relativeEnd = -1;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[5,6]);
+/* start < -length < end < 0 */
+relativeStart = (-1*tup2.length) - 5;
+relativeEnd = -3;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[1,2,3,4]);
+/* start = end < -length */
+relativeEnd = relativeStart;
+assertEq(tup2.slice(relativeStart, relativeEnd), #[]);
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/slice/tointeger-end.js b/js/src/tests/non262/Tuple/prototype/slice/tointeger-end.js
new file mode 100644
index 0000000000..a379e5d7d3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/tointeger-end.js
@@ -0,0 +1,35 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.5
+...
+6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end).
+*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+
+var sample = #[40, 41, 42, 43];
+
+assertEq(sample.slice(0, false), #[]);
+assertEq(sample.slice(0, true), #[40]);
+
+assertEq(sample.slice(0, NaN), #[]);
+assertEq(sample.slice(0, null), #[]);
+assertEq(sample.slice(0, undefined), #[40, 41, 42, 43]);
+
+assertEq(sample.slice(0, 0.6), #[]);
+assertEq(sample.slice(0, 1.1), #[40]);
+assertEq(sample.slice(0, 1.5), #[40]);
+assertEq(sample.slice(0, -0.6), #[]);
+assertEq(sample.slice(0, -1.1), #[40, 41, 42]);
+assertEq(sample.slice(0, -1.5), #[40, 41, 42]);
+
+assertEq(sample.slice(0, "3"), #[40, 41, 42]);
+
+assertEq(sample.slice(0, obj), #[40, 41]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/tointeger-start.js b/js/src/tests/non262/Tuple/prototype/slice/tointeger-start.js
new file mode 100644
index 0000000000..55a59ad024
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/tointeger-start.js
@@ -0,0 +1,35 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.5
+...
+4. Let relativeStart be ? ToInteger(start).
+*/
+
+var obj = {
+ valueOf: function() {
+ return 2;
+ }
+};
+
+
+var sample = #[40, 41, 42, 43];
+
+assertEq(sample.slice(false), sample);
+assertEq(sample.slice(true), #[41, 42, 43]);
+
+assertEq(sample.slice(NaN), sample);
+assertEq(sample.slice(null), sample);
+assertEq(sample.slice(undefined), sample);
+
+assertEq(sample.slice(0.6), sample);
+assertEq(sample.slice(1.1), #[41, 42, 43]);
+assertEq(sample.slice(1.5), #[41, 42, 43]);
+assertEq(sample.slice(-0.6), sample);
+assertEq(sample.slice(-1.1), #[43]);
+assertEq(sample.slice(-1.5), #[43]);
+
+assertEq(sample.slice("3"), #[43]);
+
+assertEq(sample.slice(obj), #[42, 43]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/slice/tuple-length-internal.js b/js/src/tests/non262/Tuple/prototype/slice/tuple-length-internal.js
new file mode 100644
index 0000000000..f0fff9693e
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/slice/tuple-length-internal.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+/* Ensure that slice uses internal length and not length property */
+
+
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+Object.defineProperty(Tuple.prototype, "length", desc);
+
+var sample = Object(#[42, 43]);
+
+var result = sample.slice();
+
+assertEq(getCalls, 0, "ignores length properties");
+assertEq(result, #[42, 43]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toReversed/indexed-setters.js b/js/src/tests/non262/Tuple/prototype/toReversed/indexed-setters.js
new file mode 100644
index 0000000000..a2477d37e3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toReversed/indexed-setters.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// If an indexed Array setter is overridden, TupleSplice shouldn't use it
+// when constructing the intermediate array
+
+var z = 5;
+print("1111");
+Object.defineProperty(Array.prototype, '0', { set: function(y) { z = 42; }});
+print("2222");
+let newT = #[1,2,3].toReversed();
+print("3333");
+assertEq(z, 5);
+print("4444");
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-func.js b/js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-func.js
new file mode 100644
index 0000000000..2e2c6facce
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-func.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var toReversed = Tuple.prototype.toReversed;
+
+assertEq(typeof toReversed, 'function');
+
+assertThrowsInstanceOf(function() {
+ toReversed();
+}, TypeError, "toReversed() invoked as function");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-method.js b/js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-method.js
new file mode 100644
index 0000000000..4014c97e4f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toReversed/invoked-as-method.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var TuplePrototype = Tuple.prototype;
+
+assertEq(typeof TuplePrototype.toReversed, 'function');
+
+assertThrowsInstanceOf(function() {
+ TuplePrototype.toReversed();
+}, TypeError, "toReversed() invoked as method");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toReversed/length.js b/js/src/tests/non262/Tuple/prototype/toReversed/length.js
new file mode 100644
index 0000000000..ff4d7e6114
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toReversed/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toReversed, "length");
+assertEq(desc.value, 0);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toReversed, "name");
+assertEq(desc.value, "toReversed");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "toReversed");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.toReversed), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.toReversed();
+}, TypeError, '`let t = #[1]; new t.toReversed()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toReversed/this-is-not-tuple.js b/js/src/tests/non262/Tuple/prototype/toReversed/this-is-not-tuple.js
new file mode 100644
index 0000000000..7df6300533
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toReversed/this-is-not-tuple.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var withReversed = Tuple.prototype.withReversed;
+
+var thisVals = [[undefined, "undefined"],
+ [null, "null"],
+ [42, "42"],
+ ["1", "1"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol("s"), "Symbol(\"s\")"],
+ [[], "[]"],
+ [{}, "{}"]];
+
+for (pair of thisVals) {
+ thisVal = pair[0];
+ errorMsg = "this is: " + pair[1];
+ assertThrowsInstanceOf(() => withReversed.call(thisVal),
+ TypeError, errorMsg);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js b/js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js
new file mode 100644
index 0000000000..2c672ef1ce
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toReversed/toReversed.js
@@ -0,0 +1,29 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.28 Tuple.prototype.toReversed ( )
+When the toReversed method is called, the following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let oldList be a new List containing the elements of T.[[Sequence]].
+3. Let newList be a new empty List.
+4. Repeat, while oldList is not empty,
+a. Remove the last element from oldList, and let E be the value of the element.
+b. Append E to the end of List newList.
+5. Return a new Tuple value whose [[Sequence]] is newList.
+*/
+/* Step 1 */
+/* toReversed() should throw on a non-Tuple */
+let method = Tuple.prototype.toReversed;
+assertEq(method.call(#[1,2,3,4,5,6]), #[6,5,4,3,2,1]);
+assertEq(method.call(Object(#[1,2,3,4,5,6])), #[6,5,4,3,2,1]);
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+
+assertEq(#[].toReversed(), #[]);
+assertEq(#[1].toReversed(), #[1]);
+
+/* Test that length is still handled correctly if it's overridden */
+Object.defineProperty(Tuple.prototype, "length", { get() { return 0 } })
+assertEq(#[1,2,3,4,5].toReversed(), #[5,4,3,2,1]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-call-throws.js b/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-call-throws.js
new file mode 100644
index 0000000000..4442b0d3d5
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-call-throws.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+let sample = #[42, 43, 44, 45, 46];
+var calls = 0;
+
+let comparefn = function() {
+ calls += 1;
+ throw new TypeError();
+};
+
+assertThrowsInstanceOf(function() {
+ sample.toSorted(comparefn);
+}, TypeError, "comparefn should throw");
+
+assertEq(calls, 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-calls.js b/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-calls.js
new file mode 100644
index 0000000000..e8d65b9445
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-calls.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var expectedThis = (function() {
+ return this;
+})();
+
+
+var sample = #[42, 42, 42, 42, 42];
+var calls = [];
+
+var comparefn = function() {
+ calls.push([this, arguments]);
+};
+
+let result = sample.toSorted(comparefn);
+
+assertEq(calls.length > 0, true);
+
+calls.forEach(function(args) {
+ assertEq(args[0], expectedThis);
+ assertEq(args[1].length, 2);
+ assertEq(args[1][0], 42);
+ assertEq(args[1][0], 42);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-nonfunction-call-throws.js b/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-nonfunction-call-throws.js
new file mode 100644
index 0000000000..5a68e1d343
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/comparefn-nonfunction-call-throws.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+ 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception.
+ ...
+*/
+
+let sample = #[42, 43, 44, 45, 46];
+
+let compareFnVals = [[null, "null"],
+ [true, "true"],
+ [false, "false"],
+ ['', "\'\'"],
+ [/a/g, "/a/g"],
+ [42, "42"],
+ [[], "[]"],
+ [{}, "{}"]];
+
+for (pair of compareFnVals) {
+ f = pair[0];
+ errorMsg = "comparefn is: " + pair[1];
+ assertThrowsInstanceOf(() => sample.withSorted(f),
+ TypeError, errorMsg);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-func.js b/js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-func.js
new file mode 100644
index 0000000000..da68b8b8fc
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-func.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var toSorted = Tuple.prototype.toSorted;
+
+assertEq(typeof toSorted, 'function');
+
+assertThrowsInstanceOf(function() {
+ toSorted();
+}, TypeError, "toSorted invoked as function");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-method.js b/js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-method.js
new file mode 100644
index 0000000000..86fc2e713b
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/invoked-as-method.js
@@ -0,0 +1,10 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var TuplePrototype = Tuple.prototype;
+
+assertEq(typeof TuplePrototype.toSorted, 'function');
+
+assertThrowsInstanceOf(function() {
+ TuplePrototype.toSorted();
+}, TypeError, "toSorted() invoked as method");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/length.js b/js/src/tests/non262/Tuple/prototype/toSorted/length.js
new file mode 100644
index 0000000000..7a94575ce6
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toSorted, "length");
+assertEq(desc.value, 1);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toSorted, "name");
+assertEq(desc.value, "toSorted");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "toSorted");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.toSorted), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.toSorted();
+}, TypeError, '`let t = #[1]; new t.toSorted()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/sorted-values.js b/js/src/tests/non262/Tuple/prototype/toSorted/sorted-values.js
new file mode 100644
index 0000000000..ecdd349145
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/sorted-values.js
@@ -0,0 +1,29 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var sample;
+
+sample = #[4,3,2,1].toSorted();
+assertEq(sample, #[1,2,3,4]);
+
+sample = #[3, 4, 1, 2].toSorted();
+assertEq(sample, #[1, 2, 3, 4]);
+
+sample = #[3,4,3,1,0,1,2].toSorted();
+assertEq(sample, #[0,1,1,2,3,3,4]);
+
+sample = #[1,0,-0,2].toSorted();
+// This matches the behavior of Array.sort()
+assertEq(sample, #[0,-0,1,2]);
+
+sample = #[-4,3,4,-3,2,-1,1,0].toSorted();
+assertEq(sample, #[-1,-3,-4,0,1,2,3,4]);
+
+sample = #[0.5,0,1.5,1].toSorted();
+assertEq(sample, #[0,0.5,1,1.5]);
+
+sample = #[0.5,0,1.5,-0.5,-1,-1.5,1].toSorted();
+assertEq(sample, #[-0.5,-1,-1.5,0,0.5,1,1.5]);
+
+sample = #[3,4,Infinity,-Infinity,1,2].toSorted();
+assertEq(sample, #[-Infinity,1,2,3,4,Infinity]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/stability.js b/js/src/tests/non262/Tuple/prototype/toSorted/stability.js
new file mode 100644
index 0000000000..1b2d0eb193
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/stability.js
@@ -0,0 +1,32 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+// Treat 0..3, 4..7, etc. as equal.
+const compare = (a, b) => (a / 4 | 0) - (b / 4 | 0);
+
+// Create a tuple of the form `[0, 1, …, 126, 127]`.
+var tup = Tuple.from({ length: 128 }, (_, i) => i);
+
+const tuple1 = tup;
+assertEq(tuple1.toSorted(compare), tup);
+
+
+// Reverse `tup` so it becomes `[127, 126, …, 1, 0]`.
+tup = tup.toReversed();
+
+const tuple2 = tup;
+assertEq(tuple2.toSorted(compare),
+ #[
+ 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8,
+ 15, 14, 13, 12, 19, 18, 17, 16, 23, 22, 21, 20,
+ 27, 26, 25, 24, 31, 30, 29, 28, 35, 34, 33, 32,
+ 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44,
+ 51, 50, 49, 48, 55, 54, 53, 52, 59, 58, 57, 56,
+ 63, 62, 61, 60, 67, 66, 65, 64, 71, 70, 69, 68,
+ 75, 74, 73, 72, 79, 78, 77, 76, 83, 82, 81, 80,
+ 87, 86, 85, 84, 91, 90, 89, 88, 95, 94, 93, 92,
+ 99, 98, 97, 96, 103, 102, 101, 100, 107, 106, 105, 104,
+ 111, 110, 109, 108, 115, 114, 113, 112, 119, 118, 117, 116,
+ 123, 122, 121, 120, 127, 126, 125, 124,
+ ]);
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/this-is-not-tuple.js b/js/src/tests/non262/Tuple/prototype/toSorted/this-is-not-tuple.js
new file mode 100644
index 0000000000..3d1761f08f
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/this-is-not-tuple.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var withSorted = Tuple.prototype.withSorted;
+
+var thisVals = [[undefined, "undefined"],
+ [null, "null"],
+ [42, "42"],
+ ["1", "1"],
+ [true, "true"],
+ [false, "false"],
+ [Symbol("s"), "Symbol(\"s\")"],
+ [[], "[]"],
+ [{}, "{}"]];
+
+for (pair of thisVals) {
+ thisVal = pair[0];
+ errorMsg = "this is: " + pair[1];
+ assertThrowsInstanceOf(() => withSorted.call(thisVal),
+ TypeError, errorMsg);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/toSorted.js b/js/src/tests/non262/Tuple/prototype/toSorted/toSorted.js
new file mode 100644
index 0000000000..c2d90f06f6
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/toSorted.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.29 Tuple.prototype.toSorted ( compareFn )
+Except as described below, implements the same requirements as those of Array.prototype.sort as defined in 22.1.3.27. The implementation may be optimized with the knowledge that the this value is an object that has a fixed length and whose integer-indexed properties are not sparse.
+
+Upon entry, the following steps are performed to initialize evaluation of the sorted function. These steps are used instead of the entry steps in 22.1.3.27:
+
+1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
+2. Let T be ? thisTupleValue(this value).
+3. Let list be a new List containing the elements of T.[[Sequence]].
+4. Let len be the length of list.
+A new Tuple containing the elements from the original Tuple is returned, where the elements are sorted. The sort order is the ordering, after completion of this function, of the elements of list. The sort order of the result of sorted is the same order as if the elements of list were sorted in an Array via %Array.prototype.sort% with comparefn as the first argument.
+
+*/
+/* Step 2 */
+/* toSorted() should throw on a non-Tuple */
+let method = Tuple.prototype.toSorted;
+assertEq(method.call(#[6,5,4,3,2,1]), #[1,2,3,4,5,6]);
+assertEq(method.call(Object(#[6,5,4,3,2,1])), #[1,2,3,4,5,6]);
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+
+/* Test that length is still handled correctly if it's overridden */
+Object.defineProperty(Tuple.prototype, "length", { get() { return 0 } })
+assertEq(#[5,4,3,2,1].toSorted(), #[1,2,3,4,5]);
+
+/* Step 1. If comparefn is not undefined... */
+assertEq(#[5,4,3,2,1].toSorted(), #[1,2,3,4,5]);
+assertEq(#[5,4,3,2,1].toSorted(undefined), #[1,2,3,4,5]);
+assertThrowsInstanceOf(() => #[1].toSorted("monkeys"), TypeError,
+ "bad comparefn passed to toSorted");
+let comparefn = (x, y) => x < y;
+assertEq(#[1,2,3,4,5].toSorted(comparefn), #[5,4,3,2,1]);
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/toSortedcompare-with-no-tostring.js b/js/src/tests/non262/Tuple/prototype/toSorted/toSortedcompare-with-no-tostring.js
new file mode 100644
index 0000000000..68b5774d61
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/toSortedcompare-with-no-tostring.js
@@ -0,0 +1,14 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/* description: Tuple toSorted does cast values to String */
+
+var toStringCalled = false;
+Number.prototype.toString = function() {
+ toStringCalled = true;
+}
+
+let sample = #[20, 100, 3];
+let result = sample.toSorted();
+assertEq(toStringCalled, false);
+assertEq(result, #[100, 20, 3]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSorted/tuplelength-internal.js b/js/src/tests/non262/Tuple/prototype/toSorted/tuplelength-internal.js
new file mode 100644
index 0000000000..8353eaea11
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSorted/tuplelength-internal.js
@@ -0,0 +1,28 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/* Use internal length rather than getting a length property */
+var getCalls = 0;
+var desc = {
+ get: function getLen() {
+ getCalls++;
+ return 0;
+ }
+};
+
+var internalLength = Object.getOwnPropertyDescriptor(Tuple.prototype, "length").get;
+Object.defineProperty(Tuple.prototype, "length", desc);
+
+let sample = #[42,42,42];
+
+getCalls = 0;
+
+var result = sample.toSorted();
+
+assertEq(getCalls, 0)
+assertEq(result, sample);
+assertEq(result[0], sample[0]);
+assertEq(result[1], sample[1]);
+assertEq(result[2], sample[2]);
+assertEq(result.length, 0);
+assertEq(internalLength.call(result), 3);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSpliced/indexed-setters.js b/js/src/tests/non262/Tuple/prototype/toSpliced/indexed-setters.js
new file mode 100644
index 0000000000..ce2fc39954
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSpliced/indexed-setters.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+// If an indexed Array setter is overridden, TupleSplice shouldn't use it
+// when constructing the intermediate array
+
+var z = 5;
+print("1111");
+Object.defineProperty(Array.prototype, '0', { set: function(y) { z = 42; }});
+print("2222");
+let newT = #[1,2,3].toSpliced(0, 2);
+print("3333");
+assertEq(z, 5);
+print("4444");
+
+reportCompare(0, 0);
+
diff --git a/js/src/tests/non262/Tuple/prototype/toSpliced/length.js b/js/src/tests/non262/Tuple/prototype/toSpliced/length.js
new file mode 100644
index 0000000000..a95d957533
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSpliced/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toSpliced, "length");
+assertEq(desc.value, 2);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toSpliced, "name");
+assertEq(desc.value, "toSpliced");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "toSpliced");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.toSpliced), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.toSpliced();
+}, TypeError, '`let t = #[1]; new t.toSpliced()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toSpliced/toSpliced.js b/js/src/tests/non262/Tuple/prototype/toSpliced/toSpliced.js
new file mode 100644
index 0000000000..dd5ccdfcbf
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toSpliced/toSpliced.js
@@ -0,0 +1,254 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.30 Tuple.prototype.toSpliced ( start, deleteCount, ...items )
+When the toSpliced method is called with two or more arguments start, deleteCount and zero or more items, a new Tuple is returned where the deleteCount elements of the Tuple starting at integer index start are replaced by the arguments items.
+
+The following steps are taken:
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be T.[[Sequence]].
+3. Let len be the number of elements in list.
+4. Let relativeStart be ? ToInteger(start).
+5. If relativeStart < 0, let actualStart be max((len + relativeStart), 0); else let actualStart be min(relativeStart, len).
+6. If the number of actual arguments is 0, then
+a. Let insertCount be 0.
+b. Let actualDeleteCount be 0.
+7. Else if the number of actual arguments is 1, then
+a. Let insertCount be 0.
+b. Let actualDeleteCount be len - actualStart.
+8. Else,
+a. Let insertCount be the number of actual arguments minus 2.
+b. Let dc be ? ToInteger(deleteCount).
+c. Let actualDeleteCount be min(max(dc, 0), len - actualStart).
+9. If len + insertCount - actualDeleteCount > 253 - 1, throw a TypeError exception.
+10. Let k be 0.
+11. Let items be a List whose elements are, in left to right order, the portion of the actual argument list starting with the third argument. The list is empty if fewer than three arguments were passed.
+12. Let itemCount be the number of elements in items.
+13. Let newList be a new empty List.
+14. Repeat, while k < actualStart,
+a. Let E be list[k].
+b. Append E to the end of list newList.
+c. Set k to k + 1.
+15. Let itemK be 0.
+16. Repeat, while itemK < itemCount.
+a. Let E be items[itemK].
+b. If Type(E) is Object, throw a TypeError exception.
+c. Append E to the end of newList.
+d. Set itemK to itemK + 1.
+17. Set k to actualStart + actualDeleteCount.
+18. Repeat, while k < len,
+a. Let E be list[k].
+b. Append E to the end of newList.
+c. Set k to k + 1.
+19. Return a new Tuple value whose [[Sequence]] is newList.
+*/
+/* Step 1 */
+/* toSpliced() should throw on a non-Tuple */
+let method = Tuple.prototype.toSpliced;
+assertEq(method.call(#[1,2,3,4,5,6], 2, 3), #[1,2,6]);
+assertEq(method.call(Object(#[1,2,3,4,5,6]),2,3), #[1,2,6]);
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(true), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(false), TypeError,
+ "value of TupleObject must be a Tuple");
+
+/* method does not access constructor */
+var t = #[];
+t.constructor = null;
+var result = t.toSpliced(0, 0);
+assertEq(result, #[]);
+assertEq(Object.getPrototypeOf(result), Tuple.prototype);
+
+/* Step 3 */
+/* Test that length is still handled correctly if it's overridden */
+Object.defineProperty(Tuple.prototype, "length", { get() { return 0 } })
+assertEq(#[1,2,3,4,5].toSpliced(1, 2), #[1,4,5]);
+
+var tup = #[1,2,3];
+var len = 3;
+/* Step 4 -- toInteger returns 0 for non-integers */
+assertEq(tup.toSpliced("monkeys", 2), tup.toSpliced(0, 2));
+assertEq(tup.toSpliced(undefined, 2), tup.toSpliced(0, 2));
+assertEq(tup.toSpliced(undefined), tup.toSpliced(0, len));
+assertEq(tup.toSpliced(), tup.slice(0));
+
+/* Step 5 */
+/* relativeStart < 0, len + relativeStart > 0 */
+var relativeStart = -1;
+var result = tup.toSpliced(relativeStart, 1);
+assertEq(result, tup.toSpliced(len + relativeStart, 1));
+assertEq(result, #[1,2]);
+/* relativeStart < 0, len + relativeStart < 0 */
+relativeStart = -4;
+result = tup.toSpliced(relativeStart, 1);
+assertEq(result, tup.toSpliced(0, 1));
+assertEq(result, #[2,3]);
+/* relativeStart < 0, len + relativeStart === 0 */
+relativeStart = -3;
+result = tup.toSpliced(relativeStart, 1);
+assertEq(result, tup.toSpliced(0, 1));
+/* relativeStart === 0 */
+relativeStart = 0;
+result = tup.toSpliced(relativeStart, 2);
+assertEq(result, #[3]);
+/* relativeStart > 0, relativeStart < len */
+relativeStart = 2;
+result = tup.toSpliced(relativeStart, 1);
+assertEq(result, #[1,2]);
+/* relativeStart > 0, relativeStart > len */
+relativeStart = 5;
+result = tup.toSpliced(relativeStart, 1);
+assertEq(result, tup.toSpliced(len, 1));
+assertEq(result, tup);
+/* relativeStart > 0, relativeStart === len */
+relativeStart = len;
+result = tup.toSpliced(relativeStart, 1);
+assertEq(result, tup);
+
+/* Step 6 - no arguments */
+result = tup.toSpliced();
+assertEq(result, tup.toSpliced(0, 0));
+assertEq(result, tup);
+
+/* Step 7 -- 1 argument */
+result = tup.toSpliced(1);
+assertEq(result, tup.toSpliced(1, len - 1));
+assertEq(result, #[1]);
+
+/* Step 8 */
+/* 2 arguments */
+/* insertCount = 0 */
+/* (a) deleteCount = non-integer */
+assertEq(tup.toSpliced(1, "monkeys"), tup.toSpliced(1, 0));
+assertEq(tup.toSpliced(1, undefined), tup.toSpliced(1, 0));
+assertEq(tup.toSpliced(1, true), tup.toSpliced(1, 1));
+/* (b) deleteCount < 0, len - actualStart > 0 */
+result = tup.toSpliced(1, -1);
+assertEq(result, tup.toSpliced(1, 0));
+assertEq(result, tup);
+/* (c) deleteCount < 0, len - actualStart === 0 */
+result = tup.toSpliced(3, -1);
+assertEq(result, tup.toSpliced(3, 0));
+assertEq(result, tup);
+/* (d) deleteCount < 0, len - actualStart < 0 */
+/* Step 5 guarantees this case can't happen */
+/* (e) deleteCount === 0 */
+assertEq(tup.toSpliced(1, 0), tup);
+/* (f) deleteCount > 0, deleteCount < (len - actualStart) */
+var tup2 = #[1,2,3,4,5];
+var tup2_len = 5;
+result = tup2.toSpliced(1, 3);
+assertEq(result, #[1, 5]);
+/* (g) deleteCount > 0, deleteCount > (len - actualStart) */
+var actualStart = 3;
+result = tup2.toSpliced(actualStart, 4);
+assertEq(result, tup2.toSpliced(actualStart, tup2_len - actualStart));
+assertEq(result, #[1,2,3]);
+/* 3 arguments */
+assertEq(tup2.toSpliced(1, "bunnies", "monkeys"), tup2.toSpliced(1, 0, "monkeys")); // (a)
+assertEq(tup2.toSpliced(1, -1, "monkeys"), tup2.toSpliced(1, 0, "monkeys")); // (b)
+assertEq(tup2.toSpliced(tup2_len, -1, "monkeys"), tup2.toSpliced(tup2_len, 0, "monkeys")); // (c)
+assertEq(tup2.toSpliced(2, 0, "monkeys"), #[1, 2, "monkeys", 3, 4, 5]); // (e)
+assertEq(tup2.toSpliced(1, 3, "monkeys"), #[1, "monkeys", 5]); // (f)
+assertEq(tup2.toSpliced(3, 4, "monkeys"), #[1, 2, 3, "monkeys"]); // (g)
+/* 4 arguments */
+assertEq(tup2.toSpliced(1, "monkeys", 42, 17), tup2.toSpliced(1, 0, 42, 17)); // (a)
+assertEq(tup2.toSpliced(1, -1, 42, 17), tup2.toSpliced(1, 0, 42, 17)); // (b)
+assertEq(tup2.toSpliced(tup2_len, -1, 42, 17), tup2.toSpliced(tup2_len, 0, 42, 17)); // (c)
+assertEq(tup2.toSpliced(2, 0, 42, 17), #[1, 2, 42, 17, 3, 4, 5]); // (e)
+assertEq(tup2.toSpliced(1, 3, 42, 17), #[1, 42, 17, 5]); // (f)
+assertEq(tup2.toSpliced(3, 4, 42, 17), #[1, 2, 3, 42, 17]); // (g)
+
+/* Step 9 */
+/* If len + insertCount - actualDeleteCount > 2^53 - 1, throw a TypeError exception.
+ Not sure how to test the error case without constructing a tuple with length 2^53 */
+
+/* Steps 14-18 */
+/* each combination of:
+ actualStart = 0, actualStart = 1, actualStart = 4
+ itemCount = 0, itemCount = 1, itemCount = 4
+ actualStart + actualDeleteCount = len, actualStart + actualDeleteCount < len */
+
+/* actualStart = 0, itemCount = 0, actualDeleteCount = len */
+var tup = #[1,2,3,4,5,6];
+var len = 6;
+var actualStart;
+var actualDeleteCount;
+actualStart = 0;
+actualDeleteCount = len;
+assertEq(tup.toSpliced(actualStart, actualDeleteCount), #[]);
+
+/* actualStart = 0, itemCount = 1, actualDeleteCount = len */
+actualStart = 0;
+actualDeleteCount = len;
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "monkeys"), #["monkeys"]);
+
+/* actualStart = 0, itemCount = 4, actualDeleteCount = len */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "a", "b", "c", "d"), #["a", "b", "c", "d"]);
+
+/* actualStart = 0, itemCount = 0, actualDeleteCount < len */
+actualDeleteCount = 3;
+assertEq(tup.toSpliced(actualStart, actualDeleteCount), #[4, 5, 6]);
+
+/* actualStart = 0, itemCount = 1, actualDeleteCount < len */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "monkeys"), #["monkeys", 4, 5, 6]);
+
+/* actualStart = 0, itemCount = 4, actualDeleteCount < len */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, 42, 43, 44, 45), #[42, 43, 44, 45, 4, 5, 6]);
+
+/* actualStart = 1, itemCount = 0, actualDeleteCount = len - 1 */
+actualStart = 1;
+actualDeleteCount = len - 1;
+assertEq(tup.toSpliced(actualStart, actualDeleteCount), #[1]);
+
+/* actualStart = 1, itemCount = 1, actualDeleteCount = len - 1 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "monkeys"), #[1, "monkeys"]);
+
+/* actualStart = 1, itemCount = 4, actualDeleteCount = len - 1 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, 0.0, 0.1, 0.2, 0.3), #[1, 0.0, 0.1, 0.2, 0.3]);
+
+/* actualStart = 1, itemCount = 0, actualDeleteCount < len - 1 */
+actualDeleteCount = 1;
+assertEq(tup.toSpliced(actualStart, actualDeleteCount), #[1, 3, 4, 5, 6]);
+
+/* actualStart = 1, itemCount = 1, actualDeleteCount < len - 1 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "monkeys"), #[1, "monkeys", 3, 4, 5, 6]);
+
+/* actualStart = 1, itemCount = 4, actualDeleteCount < len - 1 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, 8, 9, 10, 11), #[1, 8, 9, 10, 11, 3, 4, 5, 6]);
+
+/* actualStart = 4, itemCount = 0, actualDeleteCount = len - 4 */
+actualStart = 4;
+actualDeleteCount = len - 4;
+assertEq(tup.toSpliced(actualStart, actualDeleteCount), #[1, 2, 3, 4]);
+
+/* actualStart = 4, itemCount = 1, actualDeleteCount = len - 4 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "monkeys"), #[1, 2, 3, 4, "monkeys"]);
+
+/* actualStart = 4, itemCount = 4, actualDeleteCount = len - 4 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, 0, -1, -2, -3), #[1, 2, 3, 4, 0, -1, -2, -3]);
+
+/* actualStart = 4, itemCount = 0, actualDeleteCount < len - 4 */
+actualDeleteCount = 1;
+assertEq(tup.toSpliced(actualStart, actualDeleteCount), #[1, 2, 3, 4, 6]);
+
+/* actualStart = 4, itemCount = 1, actualDeleteCount < len - 4 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "monkeys"), #[1, 2, 3, 4, "monkeys", 6]);
+
+/* actualStart = 4, itemCount = 4, actualDeleteCount < len - 4 */
+assertEq(tup.toSpliced(actualStart, actualDeleteCount, "p", "q", "r", "s"), #[1, 2, 3, 4, "p", "q", "r", "s", 6]);
+
+/* Step 16.b -- item is Object */
+assertThrowsInstanceOf(() => tup.toSpliced(actualStart, actualDeleteCount, []),
+ TypeError, "Tuple can't contain Object");
+assertThrowsInstanceOf(() => tup.toSpliced(actualStart, actualDeleteCount, [], 2, 3),
+ TypeError, "Tuple can't contain Object");
+assertThrowsInstanceOf(() => tup.toSpliced(actualStart, actualDeleteCount, 2, new Object(), 3),
+ TypeError, "Tuple can't contain Object");
+assertThrowsInstanceOf(() => tup.toSpliced(actualStart, actualDeleteCount, 2, 3, {"a": "b"}),
+ TypeError, "Tuple can't contain Object");
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toString/length.js b/js/src/tests/non262/Tuple/prototype/toString/length.js
new file mode 100644
index 0000000000..1a12340df3
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toString/length.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+var desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toString, "length");
+assertEq(desc.value, 0);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype.toString, "name");
+assertEq(desc.value, "toString");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+desc = Object.getOwnPropertyDescriptor(Tuple.prototype, "toString");
+assertEq(desc.writable, true);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.prototype.toString), false);
+
+assertThrowsInstanceOf(() => {
+ let t = #[1];
+ new t.toString();
+}, TypeError, '`let t = #[1]; new t.toString()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/toString/to-string.js b/js/src/tests/non262/Tuple/prototype/toString/to-string.js
new file mode 100644
index 0000000000..e600ca78a2
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/toString/to-string.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/* Step 1 */
+/* toString() should throw on a non-Tuple */
+let method = Tuple.prototype.toString;
+assertEq(method.call(#[1,2,3,4,5,6]), "1,2,3,4,5,6");
+assertEq(method.call(Object(#[1,2,3,4,5,6])), "1,2,3,4,5,6");
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+
+// Normal case
+assertEq(#[].toString(), "");
+assertEq(#[1].toString(), "1");
+assertEq(#[1,2].toString(), "1,2");
+
+// if join method isn't callable, Object.toString should be called
+Tuple.prototype.join = 7;
+var t = #[1,2,3];
+assertEq(t.toString(), "[object Tuple]");
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/valueOf/length.js b/js/src/tests/non262/Tuple/prototype/valueOf/length.js
new file mode 100644
index 0000000000..1865563514
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/valueOf/length.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+var desc = Object.getOwnPropertyDescriptor(Tuple.valueOf, "length");
+assertEq(desc.value, 0);
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+assertEq(isConstructor(Tuple.valueOf), false);
+
+assertThrowsInstanceOf(() => {
+ new Tuple.valueOf([]);
+}, TypeError, '`new Tuple.valueOf()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/valueOf/name.js b/js/src/tests/non262/Tuple/prototype/valueOf/name.js
new file mode 100644
index 0000000000..b20e121479
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/valueOf/name.js
@@ -0,0 +1,9 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+
+desc = Object.getOwnPropertyDescriptor(Tuple.valueOf, "name");
+assertEq(desc.value, "valueOf");
+assertEq(desc.writable, false);
+assertEq(desc.enumerable, false);
+assertEq(desc.configurable, true);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/valueOf/valueOf.js b/js/src/tests/non262/Tuple/prototype/valueOf/valueOf.js
new file mode 100644
index 0000000000..967f7fac3c
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/valueOf/valueOf.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.3 Tuple.prototype.valueOf ( )
+When the valueOf function is called, the following steps are taken:
+
+1. Return ? thisTupleValue(this value).
+*/
+
+var valueOf = Tuple.prototype.valueOf;
+assertEq(typeof valueOf, 'function');
+
+var tup = #[1,2,3];
+assertEq(valueOf.call(tup), tup);
+assertEq(valueOf.call(Object(tup)), tup);
+assertThrowsInstanceOf(() => valueOf.call("monkeys"), TypeError,
+ "this is not Tuple");
+assertThrowsInstanceOf(() => valueOf.call({}), TypeError,
+ "this is not Tuple");
+assertThrowsInstanceOf(() => valueOf.call(new Object(1)), TypeError,
+ "this is not Tuple");
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/non262/Tuple/prototype/with/with.js b/js/src/tests/non262/Tuple/prototype/with/with.js
new file mode 100644
index 0000000000..d4f8c4d62b
--- /dev/null
+++ b/js/src/tests/non262/Tuple/prototype/with/with.js
@@ -0,0 +1,68 @@
+// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
+/*
+8.2.3.31 Tuple.prototype.with ( index, value )
+When the with method is called with two arguments, it returns a new Tuple with the element at index index replaced with value value.
+
+1. Let T be ? thisTupleValue(this value).
+2. Let list be a new List containing the elements of T.[[Sequence]].
+3. Let length be the length of list list.
+4. Let I be ? ToIndex(index).
+5. If I ≥ length, throw a RangeError exception.
+6. If Type(value) is Object, throw a TypeError exception.
+7. Set list[I] to value.
+8. Return a new Tuple value whose [[Sequence]] is list.
+*/
+/* Step 1 */
+/* with() should throw on a non-Tuple */
+let method = Tuple.prototype.with;
+assertEq(method.call(#[1,2,3], 1, "monkeys"), #[1, "monkeys", 3]);
+assertEq(method.call(Object(#[1,2,3]), 1, "monkeys"), #[1, "monkeys", 3]);
+assertThrowsInstanceOf(() => method.call("monkeys"), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(true), TypeError,
+ "value of TupleObject must be a Tuple");
+assertThrowsInstanceOf(() => method.call(false), TypeError,
+ "value of TupleObject must be a Tuple");
+
+/* method does not access constructor */
+var t = #[1];
+t.constructor = null;
+var result = t.with(0, 0);
+assertEq(result, #[0]);
+assertEq(Object.getPrototypeOf(result), Tuple.prototype);
+
+/* Step 3 */
+/* Test that length is still handled correctly if it's overridden */
+Object.defineProperty(Tuple.prototype, "length", { get() { return 0 } })
+assertEq(#[1,2,3,4,5].with(1, 5), #[1,5,3,4,5]);
+
+var tup = #[1,2,3];
+var len = 3;
+/* Step 4 -- toIndex returns 0 for non-integers */
+assertEq(tup.with("monkeys", 2), tup.with(0, 2));
+assertEq(tup.with(undefined, 2), tup.with(0, 2));
+assertEq(tup.with(undefined), tup.with(0, undefined));
+assertEq(tup.with(), tup.with(0, undefined));
+
+/* Step 5 */
+assertThrowsInstanceOf(() => tup.with(-5, "monkeys"),
+ RangeError, "index out of range");
+assertThrowsInstanceOf(() => tup.with(Number.MAX_SAFE_INTEGER, "monkeys"),
+ RangeError, "index out of range");
+assertThrowsInstanceOf(() => tup.with(len + 5, "monkeys"),
+ RangeError, "index out of range");
+
+/* Step 6 -- item is Object */
+assertThrowsInstanceOf(() => tup.with(1, []),
+ TypeError, "Tuple can't contain Object");
+assertThrowsInstanceOf(() => tup.with(0, new Object()),
+ TypeError, "Tuple can't contain Object");
+assertThrowsInstanceOf(() => tup.with(2, {'a': 'b'}),
+ TypeError, "Tuple can't contain Object");
+
+/* Step 8 */
+assertEq(tup.with(0, "monkeys"), #["monkeys", 2, 3]);
+assertEq(tup.with(1, #['a', 'b', 'c']), #[1, #['a', 'b', 'c'], 3]);
+assertEq(tup.with(2, 42), #[1, 2, 42]);
+
+reportCompare(0, 0);