summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/collections/Array-of-generic-1.js
blob: 090a8f97c2dec4e8fb58ece727ad242528dd64e3 (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
// Array.of can be transplanted to other classes.

load(libdir + "asserts.js");

var hits = 0;
function Bag() {
    hits++;
}
Bag.of = Array.of;

hits = 0;
var actual = Bag.of("zero", "one");
assertEq(hits, 1);

var expected = new Bag;
expected[0] = "zero";
expected[1] = "one";
expected.length = 2;
assertDeepEq(actual, expected);

hits = 0;
actual = Array.of.call(Bag, "zero", "one");
assertEq(hits, 1);
assertDeepEq(actual, expected);