michael@0: // Check superficial features of Array.build. michael@0: michael@0: if (getBuildConfiguration().parallelJS) { michael@0: load(libdir + "asserts.js"); michael@0: michael@0: var desc = Object.getOwnPropertyDescriptor(Array, "build"); michael@0: assertEq(desc.configurable, true); michael@0: assertEq(desc.enumerable, false); michael@0: assertEq(desc.writable, true); michael@0: assertEq(Array.build.length, 2); michael@0: assertThrowsInstanceOf(() => new Array.build(), TypeError); // not a constructor michael@0: michael@0: // Must pass a function to second argument. michael@0: for (let v of [undefined, null, false, "cow"]) michael@0: assertThrowsInstanceOf(() => Array.build(1, v), TypeError); michael@0: michael@0: // The first argument must be a legal length. michael@0: assertThrowsInstanceOf(() => Array.build(-1, function() {}), RangeError); michael@0: michael@0: // When the this-value passed in is not a constructor, the result is an array. michael@0: for (let v of [undefined, null, false, "cow"]) michael@0: assertEq(Array.isArray(Array.build.call(v, 1, function() {})), true); michael@0: }