Debian Codegraph @

js/src/tests/non262/RegExp/regress-9141.js

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