1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Statements/regress-226517.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * 1.11 + * Date: 04 Dec 2003 1.12 + * SUMMARY: |finally| statement should execute even after a |return| 1.13 + * 1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=226517 1.15 + * 1.16 + */ 1.17 +//----------------------------------------------------------------------------- 1.18 +var UBound = 0; 1.19 +var BUGNUMBER = 226517; 1.20 +var summary = '|finally| statement should execute even after a |return|'; 1.21 +var status = ''; 1.22 +var statusitems = []; 1.23 +var actual = ''; 1.24 +var actualvalues = []; 1.25 +var expect= ''; 1.26 +var expectedvalues = []; 1.27 + 1.28 + 1.29 +/* 1.30 + * We can only use a return statement within a function. 1.31 + * That makes the testcase more complicated to set up - 1.32 + */ 1.33 +function f() 1.34 +{ 1.35 + var return_expression_was_calculated = false; 1.36 + try 1.37 + { 1.38 + return (return_expression_was_calculated = true); 1.39 + } 1.40 + finally 1.41 + { 1.42 + actual = return_expression_was_calculated; 1.43 + } 1.44 +} 1.45 + 1.46 + 1.47 +status = inSection(1); 1.48 +f(); // sets |actual| 1.49 +expect = true; 1.50 +addThis(); 1.51 + 1.52 + 1.53 + 1.54 +//----------------------------------------------------------------------------- 1.55 +test(); 1.56 +//----------------------------------------------------------------------------- 1.57 + 1.58 + 1.59 + 1.60 +function addThis() 1.61 +{ 1.62 + statusitems[UBound] = status; 1.63 + actualvalues[UBound] = actual; 1.64 + expectedvalues[UBound] = expect; 1.65 + UBound++; 1.66 +} 1.67 + 1.68 + 1.69 +function test() 1.70 +{ 1.71 + enterFunc('test'); 1.72 + printBugNumber(BUGNUMBER); 1.73 + printStatus(summary); 1.74 + 1.75 + for (var i=0; i<UBound; i++) 1.76 + { 1.77 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.78 + } 1.79 + 1.80 + exitFunc ('test'); 1.81 +}