Lines Matching refs:of

2 // Use of this source code is governed by a BSD-style license that can be
5 // Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/source/js/src/jit-test/tests/collections
11 // Array.of makes real arrays.
21 check(Array.of());
22 check(Array.of(0));
23 check(Array.of(0, 1, 2));
24 var f = Array.of;
28 // Array.of basics
30 var a = Array.of();
33 a = Array.of(undefined, null, 3.14, []);
38 assertEquals(Array.of.apply(null, a), a);
41 // Array.of does not leave holes
43 assertEquals(Array.of(undefined), [undefined]);
44 assertEquals(Array.of(undefined, undefined), [undefined, undefined]);
45 assertEquals(Array.of.apply(null, [,,undefined]), [undefined, undefined, undefined]);
46 assertEquals(Array.of.apply(null, Array(4)), [undefined, undefined, undefined, undefined]);
49 // Array.of can be transplanted to other classes.
55 Bag.of = Array.of;
58 var actual = Bag.of("zero", "one");
69 actual = Array.of.call(Bag, "zero", "one");
82 // Array.of does not trigger prototype setters.
87 assertEquals(Array.of(1)[0], 1);
91 assertEquals(Bag.of(1)[0], 1);
95 // Array.of passes the number of arguments to the constructor it calls.
105 Herd.of = Array.of;
106 Herd.of("sheep", "cattle", "elephants", "whales", "seals");
110 // Array.of calls a "length" setter if one is present.
124 Pack.of = Array.of;
125 var pack = Pack.of("wolves", "cards", "cigarettes", "lies");
132 Bevy.of = Array.of;
133 var bevy = Bevy.of("quail");
138 // Array.of does a strict assignment to the new object's .length.
142 Empty.of = Array.of;
148 assertThrows(function() { Empty.of(); }, TypeError);
151 // Check superficial features of Array.of.
153 var desc = Object.getOwnPropertyDescriptor(Array, "of");
158 assertEquals(Array.of.length, 0);
159 assertThrows(function() { new Array.of() }, TypeError); // not a constructor
163 assertEquals(Array.isArray(Array.of(val)), true);