js/src/tests/ecma_3/RegExp/regress-98306.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:2342b0416176
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 * Date: 04 September 2001
8 *
9 * SUMMARY: Regression test for Bugzilla bug 98306
10 * "JS parser crashes in ParseAtom for script using Regexp()"
11 *
12 * See http://bugzilla.mozilla.org/show_bug.cgi?id=98306
13 */
14 //-----------------------------------------------------------------------------
15 var BUGNUMBER = 98306;
16 var summary = "Testing that we don't crash on this code -";
17 var cnUBOUND = 10;
18 var re;
19 var s;
20
21
22 //-----------------------------------------------------------------------------
23 test();
24 //-----------------------------------------------------------------------------
25
26
27 function test()
28 {
29 enterFunc ('test');
30 printBugNumber(BUGNUMBER);
31 printStatus (summary);
32
33 s = '"Hello".match(/[/]/)';
34 tryThis(s);
35
36 s = 're = /[/';
37 tryThis(s);
38
39 s = 're = /[/]/';
40 tryThis(s);
41
42 s = 're = /[//]/';
43 tryThis(s);
44
45 reportCompare('No Crash', 'No Crash', '');
46 exitFunc ('test');
47 }
48
49
50 // Try to provoke a crash -
51 function tryThis(sCode)
52 {
53 // sometimes more than one attempt is necessary -
54 for (var i=0; i<cnUBOUND; i++)
55 {
56 try
57 {
58 eval(sCode);
59 }
60 catch(e)
61 {
62 // do nothing; keep going -
63 }
64 }
65 }

mercurial