1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 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 + * Throwing exception with "throw" and catching it with "try" statement 1.9 + * 1.10 + * @path ch12/12.14/S12.14_A2.js 1.11 + * @description Checking if execution of "catch" catches an exception thrown with "throw" 1.12 + */ 1.13 + 1.14 +// CHECK#1 1.15 +try { 1.16 + throw "catchme"; 1.17 + $ERROR('#1: throw "catchme" lead to throwing exception'); 1.18 +} 1.19 +catch(e){} 1.20 + 1.21 +// CHECK#2 1.22 +var c2=0; 1.23 +try{ 1.24 + try{ 1.25 + throw "exc"; 1.26 + $ERROR('#2.1: throw "exc" lead to throwing exception'); 1.27 + }finally{ 1.28 + c2=1; 1.29 + } 1.30 +} 1.31 +catch(e){ 1.32 + if (c2!==1){ 1.33 + $ERROR('#2.2: "finally" block must be evaluated'); 1.34 + } 1.35 +} 1.36 + 1.37 +// CHECK#3 1.38 +var c3=0; 1.39 +try{ 1.40 + throw "exc"; 1.41 + $ERROR('#3.1: throw "exc" lead to throwing exception'); 1.42 +} 1.43 +catch(err){ 1.44 + var x3=1; 1.45 +} 1.46 +finally{ 1.47 + c3=1; 1.48 +} 1.49 +if (x3!==1){ 1.50 + $ERROR('#3.2: "catch" block must be evaluated'); 1.51 +} 1.52 +if (c3!==1){ 1.53 + $ERROR('#3.3: "finally" block must be evaluated'); 1.54 +} 1.55 +