Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / js1_8_5 / extensions / clone-regexp.js
1 // -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // Any copyright is dedicated to the Public Domain.
3 // http://creativecommons.org/licenses/publicdomain/
4
5 function testRegExp(b) {
6     var a = deserialize(serialize(b));
7     assertEq(a === b, false);
8     assertEq(Object.getPrototypeOf(a), RegExp.prototype);
9     assertEq(Object.prototype.toString.call(a), "[object RegExp]");
10     for (p in a)
11         throw new Error("cloned RegExp should have no enumerable properties");
12
13     assertEq(a.source, b.source);
14     assertEq(a.global, b.global);
15     assertEq(a.ignoreCase, b.ignoreCase);
16     assertEq(a.multiline, b.multiline);
17     assertEq(a.sticky, b.sticky);
18     assertEq("expando" in a, false);
19 }
20
21 testRegExp(RegExp(""));
22 testRegExp(/(?:)/);
23 testRegExp(/^(.*)$/gimy);
24 testRegExp(RegExp.prototype);
25
26 var re = /\bx\b/gi;
27 re.expando = true;
28 testRegExp(re);
29 re.__proto__ = {};
30 testRegExp(re);
31
32 reportCompare(0, 0, 'ok');