js/src/tests/js1_8_5/extensions/clone-regexp.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_8_5/extensions/clone-regexp.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +// |reftest| skip-if(!xulRuntime.shell)
     1.5 +// -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.6 +// Any copyright is dedicated to the Public Domain.
     1.7 +// http://creativecommons.org/licenses/publicdomain/
     1.8 +
     1.9 +function testRegExp(b) {
    1.10 +    var a = deserialize(serialize(b));
    1.11 +    assertEq(a === b, false);
    1.12 +    assertEq(Object.getPrototypeOf(a), RegExp.prototype);
    1.13 +    assertEq(Object.prototype.toString.call(a), "[object RegExp]");
    1.14 +    for (p in a)
    1.15 +        throw new Error("cloned RegExp should have no enumerable properties");
    1.16 +
    1.17 +    assertEq(a.source, b.source);
    1.18 +    assertEq(a.global, b.global);
    1.19 +    assertEq(a.ignoreCase, b.ignoreCase);
    1.20 +    assertEq(a.multiline, b.multiline);
    1.21 +    assertEq(a.sticky, b.sticky);
    1.22 +    assertEq("expando" in a, false);
    1.23 +}
    1.24 +
    1.25 +testRegExp(RegExp(""));
    1.26 +testRegExp(/(?:)/);
    1.27 +testRegExp(/^(.*)$/gimy);
    1.28 +testRegExp(RegExp.prototype);
    1.29 +
    1.30 +var re = /\bx\b/gi;
    1.31 +re.expando = true;
    1.32 +testRegExp(re);
    1.33 +re.__proto__ = {};
    1.34 +testRegExp(re);
    1.35 +
    1.36 +reportCompare(0, 0, 'ok');

mercurial