array-tosource.js (546B)
1 // |jit-test| skip-if: !Array.prototype.toSource 2 3 load(libdir + 'asserts.js'); 4 5 assertEq(Array.prototype.toSource.call([1, 'hi']), '[1, "hi"]'); 6 assertEq(Array.prototype.toSource.call({1: 10, 0: 42, length: 2}), "[42, 10]"); 7 assertEq(Array.prototype.toSource.call({1: 10, 0: 42, length: 1}), "[42]"); 8 assertThrowsInstanceOf(() => Array.prototype.toSource.call("someString"), TypeError); 9 assertThrowsInstanceOf(() => Array.prototype.toSource.call(42), TypeError); 10 assertThrowsInstanceOf(() => Array.prototype.toSource.call(undefined), TypeError);