summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Tuple/from/elements-added-after.js
blob: d0c045ffb68ce326e1a06e274ad6b1e0a6575edc (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"))
var tupleIndex = -1;
var originalLength = 7;
var obj = {
  length: originalLength,
  0: 2,
  1: 4,
  2: 8,
  3: 16,
  4: 32,
  5: 64,
  6: 128
};
var tuple = #[2, 4, 8, 16, 32, 64, 128];

function mapFn(value, index) {
    tupleIndex++;
    assertEq(value, obj[tupleIndex]);
    assertEq(index, tupleIndex);
    obj[originalLength + tupleIndex] = 2 * tupleIndex + 1;

    return obj[tupleIndex];
}


var t = Tuple.from(obj, mapFn);
assertEq(t, tuple);

reportCompare(0, 0);