Imported tests
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma_3 / RegExp / regress-98306.js
1 /* ***** BEGIN LICENSE BLOCK *****\r
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1\r
3  *\r
4  * The contents of this file are subject to the Mozilla Public License Version\r
5  * 1.1 (the "License"); you may not use this file except in compliance with\r
6  * the License. You may obtain a copy of the License at\r
7  * http://www.mozilla.org/MPL/\r
8  *\r
9  * Software distributed under the License is distributed on an "AS IS" basis,\r
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
11  * for the specific language governing rights and limitations under the\r
12  * License.\r
13  *\r
14  * The Original Code is mozilla.org code.\r
15  *\r
16  * The Initial Developer of the Original Code is\r
17  * Netscape Communications Corporation.\r
18  * Portions created by the Initial Developer are Copyright (C) 1998\r
19  * the Initial Developer. All Rights Reserved.\r
20  *\r
21  * Contributor(s):\r
22  *   jrgm@netscape.com, pschwartau@netscape.com\r
23  *\r
24  * Alternatively, the contents of this file may be used under the terms of\r
25  * either the GNU General Public License Version 2 or later (the "GPL"), or\r
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
27  * in which case the provisions of the GPL or the LGPL are applicable instead\r
28  * of those above. If you wish to allow use of your version of this file only\r
29  * under the terms of either the GPL or the LGPL, and not to allow others to\r
30  * use your version of this file under the terms of the MPL, indicate your\r
31  * decision by deleting the provisions above and replace them with the notice\r
32  * and other provisions required by the GPL or the LGPL. If you do not delete\r
33  * the provisions above, a recipient may use your version of this file under\r
34  * the terms of any one of the MPL, the GPL or the LGPL.\r
35  *\r
36  * ***** END LICENSE BLOCK *****\r
37  *\r
38  * Date: 04 September 2001\r
39  *\r
40  * SUMMARY: Regression test for Bugzilla bug 98306\r
41  * "JS parser crashes in ParseAtom for script using Regexp()"\r
42  *\r
43  * See http://bugzilla.mozilla.org/show_bug.cgi?id=98306\r
44  */\r
45 //-----------------------------------------------------------------------------\r
46 var bug = 98306;\r
47 var summary = "Testing that we don't crash on this code -";\r
48 var cnUBOUND = 10;\r
49 var re;\r
50 var s;\r
51 \r
52 \r
53 //-----------------------------------------------------------------------------\r
54 test();\r
55 //-----------------------------------------------------------------------------\r
56 \r
57 \r
58 function test()\r
59 {\r
60   enterFunc ('test');\r
61   printBugNumber (bug);\r
62   printStatus (summary);\r
63 \r
64   s = '"Hello".match(/[/]/)';\r
65   tryThis(s);\r
66 \r
67   s = 're = /[/';\r
68   tryThis(s);\r
69 \r
70   s = 're = /[/]/';\r
71   tryThis(s);\r
72 \r
73   s = 're = /[//]/';\r
74   tryThis(s);\r
75 \r
76   exitFunc ('test');\r
77 }\r
78 \r
79 \r
80 // Try to provoke a crash -\r
81 function tryThis(sCode)\r
82 {\r
83   // sometimes more than one attempt is necessary -\r
84   for (var i=0; i<cnUBOUND; i++)\r
85   {\r
86     try\r
87     {\r
88       eval(sCode);\r
89     }\r
90     catch(e)\r
91     {\r
92       // do nothing; keep going -\r
93     }\r
94   }\r
95 }\r