1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A5.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +// Copyright 2009 the Sputnik authors. All rights reserved. 1.5 +// This code is governed by the BSD license found in the LICENSE file. 1.6 + 1.7 +/** 1.8 + * The production TryStatement: "try Block Finally" and the production TryStatement: "try Block Catch Finally" 1.9 + * 1.10 + * @path ch12/12.14/S12.14_A5.js 1.11 + * @description Checking "catch" catches the Identifier in appropriate way 1.12 + */ 1.13 + 1.14 +// CHECK#1 1.15 +try { 1.16 + throw "catchme"; 1.17 + throw "dontcatchme"; 1.18 + $ERROR('#1.1: throw "catchme" lead to throwing exception'); 1.19 +} 1.20 +catch (e) { 1.21 + if(e==="dontcatchme"){ 1.22 + $ERROR('#1.2: Exception !== "dontcatchme"'); 1.23 + } 1.24 + if (e!=="catchme") { 1.25 + $ERROR('#1.3: Exception === "catchme". Actual: Exception ==='+ e ); 1.26 + } 1.27 +} 1.28 + 1.29 +// CHECK#2 1.30 +function SwitchTest1(value){ 1.31 + var result = 0; 1.32 + try{ 1.33 + switch(value) { 1.34 + case 1: 1.35 + result += 4; 1.36 + throw result; 1.37 + break; 1.38 + case 4: 1.39 + result += 64; 1.40 + throw "ex"; 1.41 + } 1.42 + return result; 1.43 + } 1.44 + catch(e){ 1.45 + if ((value===1)&&(e!==4)) $ERROR('#2.1: Exception === 4. Actual: '+e); 1.46 + if ((value===4)&&(e!=="ex"))$ERROR('#2.2: Exception === "ex". Actual: '+e); 1.47 + } 1.48 + finally{ 1.49 + return result; 1.50 + } 1.51 +} 1.52 +if (SwitchTest1(1)!==4) $ERROR('#2.3: "finally" block must be evaluated'); 1.53 +if (SwitchTest1(4)!==64)$ERROR('#2.4: "finally" block must be evaluated'); 1.54 +