]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_3/RegExp/regress-98306.js
JavaScriptCore-1097.3.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma_3 / RegExp / regress-98306.js
1 /*
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
6 *
7 * Software distributed under the License is distributed on an "AS IS"
8 * basis, WITHOUT WARRANTY OF ANY KIND, either expressed
9 * or implied. See the License for the specific language governing
10 * rights and limitations under the License.
11 *
12 * The Original Code is mozilla.org code.
13 *
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
18 *
19 * Contributor(s): jrgm@netscape.com, pschwartau@netscape.com
20 * Date: 04 September 2001
21 *
22 * SUMMARY: Regression test for Bugzilla bug 98306
23 * "JS parser crashes in ParseAtom for script using Regexp()"
24 *
25 * See http://bugzilla.mozilla.org/show_bug.cgi?id=98306
26 */
27 //-----------------------------------------------------------------------------
28 var bug = 98306;
29 var summary = "Testing that we don't crash on this code -";
30 var cnUBOUND = 10;
31 var re;
32 var s;
33
34
35 //-----------------------------------------------------------------------------
36 test();
37 //-----------------------------------------------------------------------------
38
39
40 function test()
41 {
42 enterFunc ('test');
43 printBugNumber (bug);
44 printStatus (summary);
45
46 s = '"Hello".match(/[/]/)';
47 tryThis(s);
48
49 s = 're = /[/';
50 tryThis(s);
51
52 s = 're = /[/]/';
53 tryThis(s);
54
55 s = 're = /[//]/';
56 tryThis(s);
57
58 exitFunc ('test');
59 }
60
61
62 // Try to provoke a crash -
63 function tryThis(sCode)
64 {
65 // sometimes more than one attempt is necessary -
66 for (var i=0; i<cnUBOUND; i++)
67 {
68 try
69 {
70 eval(sCode);
71 }
72 catch(e)
73 {
74 // do nothing; keep going -
75 }
76 }
77 }