1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is JavaScript Engine testing utilities.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corp.
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
23 * chwu@nortelnetworks.com, timeless@mac.com,
24 * brendan@mozilla.org, pschwartau@netscape.com
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
42 * Date: 10 October 2001
43 * SUMMARY: Regression test for Bugzilla bug 104077
44 * See http://bugzilla.mozilla.org/show_bug.cgi?id=104077
45 * "JS crash: with/finally/return"
47 * Also http://bugzilla.mozilla.org/show_bug.cgi?id=120571
48 * "JS crash: try/catch/continue."
50 * SpiderMonkey crashed on this code - it shouldn't.
52 * NOTE: the finally-blocks below should execute even if their try-blocks
53 * have return or throw statements in them:
55 * ------- Additional Comment #76 From Mike Shaver 2001-12-07 01:21 -------
56 * finally trumps return, and all other control-flow constructs that cause
57 * program execution to jump out of the try block: throw, break, etc. Once you
58 * enter a try block, you will execute the finally block after leaving the try,
59 * regardless of what happens to make you leave the try.
62 //-----------------------------------------------------------------------------
64 var BUGNUMBER = 104077;
65 var summary = "Just testing that we don't crash on with/finally/return -";
69 var actualvalues = [];
71 var expectedvalues = [];
74 function addValues(obj)
90 status = inSection(1);
91 var obj = new Object();
94 actual = addValues(obj);
114 print("In finally case of tryThis() function");
120 status = inSection(2);
129 var obj = new Object();
134 msg = (x != null) ? "NO" : "YES";
135 print("Is the provided argument to myTest() null? : " + msg);
143 print("Caught thrown exception = " + e);
150 status = inSection(3);
151 actual = myTest(null);
157 function addValues_2(obj)
177 print('Caught an exception in addValues_2() function: ' + e);
189 status = inSection(4);
193 obj.arg3 = new Object();
196 actual = addValues_2(obj);
202 status = inSection(5);
231 function testfunc(mode)
233 var obj = new Object();
243 throw "authentication.0";
259 throw "authentication.0";
275 status = inSection(6);
276 actual = testfunc(0);
280 status = inSection(7);
288 function entry_menu()
290 var document = new Object();
291 var dialog = new Object();
312 status = inSection(8);
313 actual = entry_menu();
320 function addValues_5(obj)
352 print("In finally block of addValues_5() function: sum = " + sum);
357 print("In finally catch block of addValues_5() function: sum = " + sum + ", e = " + e);
362 print("In finally finally block of addValues_5() function: sum = " + sum);
369 status = inSection(11);
373 obj.arg3 = new Object();
376 actual = addValues_5(obj);
383 function testObj(obj)
398 print("in finally block of testObj() function");
403 status = inSection(12);
405 actual = testObj(obj);
412 * Next two cases are from http://bugzilla.mozilla.org/show_bug.cgi?id=120571
428 // this caused a crash! Test to see that it doesn't now.
431 // Now test that we have a non-null value for a120571.toString()
432 status = inSection(13);
435 actual = a120571.toString().match(/continue/)[0];
439 actual = 'FAILED! Did not find "continue" in function body';
461 // this caused a crash!!! Test to see that it doesn't now.
464 // Now test that we have a non-null value for b.toString()
465 status = inSection(14);
468 actual = b.toString().match(/continue/)[0];
472 actual = 'FAILED! Did not find "continue" in function body';
481 //-----------------------------------------------------------------------------
483 //-----------------------------------------------------------------------------
487 function captureThis()
489 statusitems[UBound] = status;
490 actualvalues[UBound] = actual;
491 expectedvalues[UBound] = expect;
499 printBugNumber(BUGNUMBER);
500 printStatus (summary);
502 for (var i=0; i<UBound; i++)
504 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);