| 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 |
* |
| 8 |
* Date: 04 Dec 2003 |
| 9 |
* SUMMARY: |finally| statement should execute even after a |return| |
| 10 |
* |
| 11 |
* See http://bugzilla.mozilla.org/show_bug.cgi?id=226517 |
| 12 |
* |
| 13 |
*/ |
| 14 |
//----------------------------------------------------------------------------- |
| 15 |
var UBound = 0; |
| 16 |
var BUGNUMBER = 226517; |
| 17 |
var summary = '|finally| statement should execute even after a |return|'; |
| 18 |
var status = ''; |
| 19 |
var statusitems = []; |
| 20 |
var actual = ''; |
| 21 |
var actualvalues = []; |
| 22 |
var expect= ''; |
| 23 |
var expectedvalues = []; |
| 24 |
|
| 25 |
|
| 26 |
/* |
| 27 |
* We can only use a return statement within a function. |
| 28 |
* That makes the testcase more complicated to set up - |
| 29 |
*/ |
| 30 |
function f() |
| 31 |
{ |
| 32 |
var return_expression_was_calculated = false; |
| 33 |
try |
| 34 |
{ |
| 35 |
return (return_expression_was_calculated = true); |
| 36 |
} |
| 37 |
finally |
| 38 |
{ |
| 39 |
actual = return_expression_was_calculated; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
status = inSection(1); |
| 45 |
f(); // sets |actual| |
| 46 |
expect = true; |
| 47 |
addThis(); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
//----------------------------------------------------------------------------- |
| 52 |
test(); |
| 53 |
//----------------------------------------------------------------------------- |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
function addThis() |
| 58 |
{ |
| 59 |
statusitems[UBound] = status; |
| 60 |
actualvalues[UBound] = actual; |
| 61 |
expectedvalues[UBound] = expect; |
| 62 |
UBound++; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
function test() |
| 67 |
{ |
| 68 |
printBugNumber(BUGNUMBER); |
| 69 |
printStatus(summary); |
| 70 |
|
| 71 |
for (var i=0; i<UBound; i++) |
| 72 |
{ |
| 73 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 74 |
} |
| 75 |
} |