Debian Codegraph @

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

raw
1 /* -*- 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 * 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 printBugNumber(BUGNUMBER);
30 printStatus (summary);
31
32 s = '"Hello".match(/[/]/)';
33 tryThis(s);
34
35 s = 're = /[/';
36 tryThis(s);
37
38 s = 're = /[/]/';
39 tryThis(s);
40
41 s = 're = /[//]/';
42 tryThis(s);
43
44 reportCompare('No Crash', 'No Crash', '');
45 }
46
47
48 // Try to provoke a crash -
49 function tryThis(sCode)
50 {
51 // sometimes more than one attempt is necessary -
52 for (var i=0; i<cnUBOUND; i++)
53 {
54 try
55 {
56 eval(sCode);
57 }
58 catch(e)
59 {
60 // do nothing; keep going -
61 }
62 }
63 }