diff options
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); |