summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/array-tosource.js
blob: b1f51f26d3e560a37e49209d4b426c72944c9e64 (plain)
1
2
3
4
5
6
7
8
9
10
// |jit-test| skip-if: !Array.prototype.toSource

load(libdir + 'asserts.js');

assertEq(Array.prototype.toSource.call([1, 'hi']), '[1, "hi"]');
assertEq(Array.prototype.toSource.call({1: 10, 0: 42, length: 2}), "[42, 10]");
assertEq(Array.prototype.toSource.call({1: 10, 0: 42, length: 1}), "[42]");
assertThrowsInstanceOf(() => Array.prototype.toSource.call("someString"), TypeError);
assertThrowsInstanceOf(() => Array.prototype.toSource.call(42), TypeError);
assertThrowsInstanceOf(() => Array.prototype.toSource.call(undefined), TypeError);