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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// |reftest| skip-if(!this.hasOwnProperty("Tuple"))
var list = {
'0': 41,
'1': 42,
'2': 43,
length: 3
};
var calls = [];
function mapFn(value) {
calls.push({
args: arguments,
thisArg: this
});
return value * 2;
}
var result = Tuple.from(list, mapFn);
assertEq(result.length, 3);
assertEq(result[0], 82);
assertEq(result[1], 84);
assertEq(result[2], 86);
assertEq(calls.length, 3);
assertEq(calls[0].args.length, 2);
assertEq(calls[0].args[0], 41);
assertEq(calls[0].args[1], 0);
assertEq(calls[0].thisArg, this);
assertEq(calls[1].args.length, 2);
assertEq(calls[1].args[0], 42);
assertEq(calls[1].args[1], 1);
assertEq(calls[1].thisArg, this);
assertEq(calls[2].args.length, 2);
assertEq(calls[2].args[0], 43);
assertEq(calls[2].args[1], 2);
assertEq(calls[2].thisArg, this);
reportCompare(0, 0);
|