]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_5/Regress/regress-104077.js
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Netscape Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/NPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is JavaScript Engine testing utilities.
16 * The Initial Developer of the Original Code is Netscape Communications Corp.
17 * Portions created by the Initial Developer are Copyright (C) 2001
18 * the Initial Developer. All Rights Reserved.
20 * Contributor(s): chwu@nortelnetworks.com, timeless@mac.com,
21 * brendan@mozilla.org, pschwartau@netscape.com
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the NPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the NPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK *****
38 * Date: 10 October 2001
39 * SUMMARY: Regression test for Bugzilla bug 104077
40 * See http://bugzilla.mozilla.org/show_bug.cgi?id=104077
41 * "JS crash: with/finally/return"
43 * Also http://bugzilla.mozilla.org/show_bug.cgi?id=120571
44 * "JS crash: try/catch/continue."
46 * SpiderMonkey crashed on this code - it shouldn't.
48 * NOTE: the finally-blocks below should execute even if their try-blocks
49 * have return or throw statements in them:
51 * ------- Additional Comment #76 From Mike Shaver 2001-12-07 01:21 -------
52 * finally trumps return, and all other control-flow constructs that cause
53 * program execution to jump out of the try block: throw, break, etc. Once you
54 * enter a try block, you will execute the finally block after leaving the try,
55 * regardless of what happens to make you leave the try.
58 //-----------------------------------------------------------------------------
61 var summary
= "Just testing that we don't crash on with/finally/return -";
65 var actualvalues
= [];
67 var expectedvalues
= [];
70 function addValues(obj
)
86 status
= inSection(1);
87 var obj
= new Object();
90 actual
= addValues(obj
);
110 print("In finally case of tryThis() function");
116 status
= inSection(2);
125 var obj
= new Object();
130 msg
= (x
!= null) ? "NO" : "YES";
131 print("Is the provided argument to myTest() null? : " + msg
);
139 print("Caught thrown exception = " + e
);
146 status
= inSection(3);
147 actual
= myTest(null);
153 function addValues_2(obj
)
173 print('Caught an exception in addValues_2() function: ' + e
);
185 status
= inSection(4);
189 obj
.arg3
= new Object();
192 actual
= addValues_2(obj
);
198 status
= inSection(5);
227 function testfunc(mode
)
229 var obj
= new Object();
239 throw "authentication.0";
255 throw "authentication.0";
271 status
= inSection(6);
272 actual
= testfunc(0);
276 status
= inSection(7);
284 function entry_menu()
286 var document
= new Object();
287 var dialog
= new Object();
308 status
= inSection(8);
309 actual
= entry_menu();
316 function addValues_3(obj
)
348 print("In finally block of addValues_3() function: sum = " + sum
);
353 print('In finally catch block of addValues_3() function: sum = ' + sum
+ ', e = ' + e
);
358 print("In finally finally block of addValues_3() function: sum = " + sum
);
365 status
= inSection(9);
369 obj
.arg3
= new Object();
372 actual
= addValues_3(obj
);
379 function addValues_4(obj
)
411 print("In finally block of addValues_4() function: sum = " + sum
);
416 print("In 1st finally catch block of addValues_4() function: sum = " + sum
+ ", e = " + e
);
421 print("In 2nd finally catch block of addValues_4() function: sum = " + sum
+ ", e = " + e
);
426 print("In finally finally block of addValues_4() function: sum = " + sum
);
433 status
= inSection(10);
437 obj
.arg3
= new Object();
440 actual
= addValues_4(obj
);
447 function addValues_5(obj
)
479 print("In finally block of addValues_5() function: sum = " + sum
);
484 print("In finally catch block of addValues_5() function: sum = " + sum
+ ", e = " + e
);
489 print("In finally finally block of addValues_5() function: sum = " + sum
);
496 status
= inSection(11);
500 obj
.arg3
= new Object();
503 actual
= addValues_5(obj
);
510 function testObj(obj
)
525 print("in finally block of testObj() function");
530 status
= inSection(12);
532 actual
= testObj(obj
);
539 * Next two cases are from http://bugzilla.mozilla.org/show_bug.cgi?id=120571
555 // this caused a crash! Test to see that it doesn't now.
558 // Now test that we have a non-null value for a120571.toString()
559 status
= inSection(13);
562 actual
= a120571
.toString().match(/continue/)[0];
566 actual
= 'FAILED! Did not find "continue" in function body';
588 // this caused a crash!!! Test to see that it doesn't now.
591 // Now test that we have a non-null value for b.toString()
592 status
= inSection(14);
595 actual
= b
.toString().match(/continue/)[0];
599 actual
= 'FAILED! Did not find "continue" in function body';
608 //-----------------------------------------------------------------------------
610 //-----------------------------------------------------------------------------
614 function captureThis()
616 statusitems
[UBound
] = status
;
617 actualvalues
[UBound
] = actual
;
618 expectedvalues
[UBound
] = expect
;
626 printBugNumber (bug
);
627 printStatus (summary
);
629 for (var i
=0; i
<UBound
; i
++)
631 reportCompare(expectedvalues
[i
], actualvalues
[i
], statusitems
[i
]);