Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/regress-119909.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /*
7 *
8 * Date: 14 Jan 2002
9 * SUMMARY: Shouldn't crash on regexps with many nested parentheses
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=119909
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var gTestfile = 'regress-119909.js';
15 var BUGNUMBER = 119909;
16 var summary = "Shouldn't crash on regexps with many nested parentheses";
17 var NO_BACKREFS = false;
18 var DO_BACKREFS = true;
19
20
21 //--------------------------------------------------
22 test();
23 //--------------------------------------------------
24
25
26 function test()
27 {
28 enterFunc('test');
29 printBugNumber(BUGNUMBER);
30 printStatus(summary);
31
32 testThis(500, NO_BACKREFS, 'hello', 'goodbye');
33 testThis(500, DO_BACKREFS, 'hello', 'goodbye');
34
35 reportCompare('No Crash', 'No Crash', '');
36
37 exitFunc('test');
38 }
39
40
41 /*
42 * Creates a regexp pattern like (((((((((hello)))))))))
43 * and tests str.search(), str.match(), str.replace()
44 */
45 function testThis(numParens, doBackRefs, strOriginal, strReplace)
46 {
47 var openParen = doBackRefs? '(' : '(?:';
48 var closeParen = ')';
49 var pattern = '';
50
51 for (var i=0; i<numParens; i++) {pattern += openParen;}
52 pattern += strOriginal;
53 for (i=0; i<numParens; i++) {pattern += closeParen;}
54 var re = new RegExp(pattern);
55
56 var res = strOriginal.search(re);
57 res = strOriginal.match(re);
58 res = strOriginal.replace(re, strReplace);
59 }