MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 22 lines 1.1 kB view raw
1function assert(cond, msg) { 2 if (!cond) throw new Error(msg); 3} 4 5console.log("array prototype and subclassing regression"); 6 7assert(Array.isArray(Array.prototype), "Array.prototype should be an array exotic"); 8assert(Object.getPrototypeOf(Array.prototype) === Object.prototype, "Array.prototype should inherit from Object.prototype"); 9 10class C extends Array {} 11const c = new C(1, 2, 3); 12 13assert(c instanceof C, "Array subclass instances should preserve subclass identity"); 14assert(c instanceof Array, "Array subclass instances should still be arrays"); 15assert(c.concat(4) instanceof C, "concat should preserve Array subclass"); 16assert(c.map(x => x) instanceof C, "map should preserve Array subclass"); 17assert(c.filter(() => true) instanceof C, "filter should preserve Array subclass"); 18assert(c.slice(0) instanceof C, "slice should preserve Array subclass"); 19assert(C.from([1, 2]) instanceof C, "Array.from on subclass should preserve subclass"); 20assert(C.of(1, 2) instanceof C, "Array.of on subclass should preserve subclass"); 21 22console.log("PASS");