summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/of/of.js
blob: bbda64608d25dacc02d26c47baaf8bdd4477ec49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);