js/src/tests/ecma_5/strict/regress-599159.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/strict/regress-599159.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +
     1.6 +/*
     1.7 + * Any copyright is dedicated to the Public Domain.
     1.8 + * http://creativecommons.org/licenses/publicdomain/
     1.9 + */
    1.10 +
    1.11 +// Shu's test
    1.12 +function test(makeNonArray) {
    1.13 +    function C() {}
    1.14 +    C.prototype = []
    1.15 +    if (makeNonArray)
    1.16 +        C.prototype.constructor = C
    1.17 +    c = new C();
    1.18 +    c.push("foo");
    1.19 +    return c.length
    1.20 +}
    1.21 +assertEq(test(true), 1);
    1.22 +assertEq(test(false), 1);
    1.23 +
    1.24 +// jorendorff's longer test
    1.25 +var a = [];
    1.26 +a.slowify = 1;
    1.27 +var b = Object.create(a);
    1.28 +b.length = 12;
    1.29 +assertEq(b.length, 12);
    1.30 +
    1.31 +// jorendorff's shorter test
    1.32 +var b = Object.create(Array.prototype);
    1.33 +b.length = 12;
    1.34 +assertEq(b.length, 12);
    1.35 +
    1.36 +reportCompare(true, true);

mercurial