diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Tuple/of/of.js | |
parent | Initial commit. (diff) | |
download | firefox-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/of/of.js')
-rw-r--r-- | js/src/tests/non262/Tuple/of/of.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/js/src/tests/non262/Tuple/of/of.js b/js/src/tests/non262/Tuple/of/of.js new file mode 100644 index 0000000000..bbda64608d --- /dev/null +++ b/js/src/tests/non262/Tuple/of/of.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!this.hasOwnProperty("Tuple")) +/* +8.2.2.3 Tuple.of ( ...items ) +The of method takes any number of arguments, and performs the following steps: + +1. Let items be the List of arguments passed to this function. +2. For each element e of items, +a. If Type(e) is Object, throw a TypeError exception. +3. Let tuple be a new Tuple value whose [[Sequence]] is items. +4. Return tuple. +*/ + +assertEq(Tuple.of(), #[]); +assertEq(Tuple.of(undefined), #[undefined]); +assertEq(Tuple.of(null), #[null]); +assertEq(Tuple.of(1), #[1]); +assertEq(Tuple.of(1, 2), #[1,2]); +assertEq(Tuple.of(true, 5, "monkeys", #[3, 4]), #[true, 5, "monkeys", #[3, 4]]); +assertEq(Tuple.of(undefined, false, null, undefined), #[undefined, false, null, undefined]); + +/* Step 2a. */ +assertThrowsInstanceOf(() => Tuple.of([1, 2, 3]), TypeError, + "Tuple can't contain Object"); +assertThrowsInstanceOf(() => Tuple.of([]), TypeError, + "Tuple can't contain Object"); +assertThrowsInstanceOf(() => Tuple.of(new Object(), [1, 2, 3], new String("a")), TypeError, + "Tuple can't contain Object"); + +reportCompare(0, 0); |