Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/regress-9141.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 gTestfile = 'regress-9141.js';
7
8
9 /**
10 * File Name: regress-9141.js
11 * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=9141";
12 * Description:
13 * From [email protected]:
14 *
15 * The following page crashes the system:
16 *
17 * <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
18 * "http://www.w3.org/TR/REC-html40/loose.dtd">
19 * <HTML>
20 * <HEAD>
21 * </HEAD>
22 * <BODY>
23 * <SCRIPT type="text/javascript">
24 * var s = "x";
25 * for (var i = 0; i != 13; i++) s += s;
26 * var a = /(?:xx|x)*[slash](s);
27 * var b = /(xx|x)*[slash](s);
28 * document.write("Results = " + a.length + "," + b.length);
29 * </SCRIPT>
30 * </BODY>
31 */
32
33 var SECTION = "js1_2"; // provide a document reference (ie, ECMA section)
34 var VERSION = "ECMA_2"; // Version of JavaScript or ECMA
35 var TITLE = "Regression test for bugzilla # 9141"; // Provide ECMA section title or a description
36 var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; // Provide URL to bugsplat or bugzilla report
37
38 startTest(); // leave this alone
39
40 /*
41 * Calls to AddTestCase here. AddTestCase is a function that is defined
42 * in shell.js and takes three arguments:
43 * - a string representation of what is being tested
44 * - the expected result
45 * - the actual result
46 *
47 * For example, a test might look like this:
48 *
49 * var zip = /[\d]{5}$/;
50 *
51 * AddTestCase(
52 * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test
53 * "02134", // expected result
54 * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result
55 *
56 */
57
58 var s = "x";
59 for (var i = 0; i != 13; i++) s += s;
60 var a = /(?:xx|x)*/(s);
61 var b = /(xx|x)*/(s);
62
63 AddTestCase( "var s = 'x'; for (var i = 0; i != 13; i++) s += s; " +
64 "a = /(?:xx|x)*/(s); a.length",
65 1,
66 a.length );
67
68 AddTestCase( "var b = /(xx|x)*/(s); b.length",
69 2,
70 b.length );
71
72 test(); // leave this alone. this executes the test cases and
73 // displays results.