js/src/jit-test/tests/collections/Array-build-surfaces.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/collections/Array-build-surfaces.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +// Check superficial features of Array.build.
     1.5 +
     1.6 +if (getBuildConfiguration().parallelJS) {
     1.7 +  load(libdir + "asserts.js");
     1.8 +
     1.9 +  var desc = Object.getOwnPropertyDescriptor(Array, "build");
    1.10 +  assertEq(desc.configurable, true);
    1.11 +  assertEq(desc.enumerable, false);
    1.12 +  assertEq(desc.writable, true);
    1.13 +  assertEq(Array.build.length, 2);
    1.14 +  assertThrowsInstanceOf(() => new Array.build(), TypeError);  // not a constructor
    1.15 +
    1.16 +  // Must pass a function to second argument.
    1.17 +  for (let v of [undefined, null, false, "cow"])
    1.18 +    assertThrowsInstanceOf(() => Array.build(1, v), TypeError);
    1.19 +
    1.20 +  // The first argument must be a legal length.
    1.21 +  assertThrowsInstanceOf(() => Array.build(-1, function() {}), RangeError);
    1.22 +
    1.23 +  // When the this-value passed in is not a constructor, the result is an array.
    1.24 +  for (let v of [undefined, null, false, "cow"])
    1.25 +    assertEq(Array.isArray(Array.build.call(v, 1, function() {})), true);
    1.26 +}

mercurial