|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * "try" with "catch" or "finally" statement within/without an "if" statement |
|
6 * |
|
7 * @path ch12/12.14/S12.14_A8.js |
|
8 * @description Throwing exception within an "if" statement |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 var c1=1; |
|
13 try{ |
|
14 if(c1===1){ |
|
15 throw "ex1"; |
|
16 $ERROR('#1.1: throw "ex1" lead to throwing exception'); |
|
17 } |
|
18 $ERROR('#1.2: throw "ex1" inside the "if" statement lead to throwing exception'); |
|
19 } |
|
20 catch(er1){ |
|
21 if (er1!=="ex1") $ERROR('#1.3: Exception ==="ex1". Actual: Exception ==='+er1); |
|
22 } |
|
23 |
|
24 // CHECK#2 |
|
25 var c2=1; |
|
26 if(c2===1){ |
|
27 try{ |
|
28 throw "ex1"; |
|
29 $ERROR('#2.1: throw "ex1" lead to throwing exception'); |
|
30 } |
|
31 catch(er1){ |
|
32 if(er1!="ex1") $ERROR('#2.2: Exception ==="ex1". Actual: Exception ==='+er1); |
|
33 } |
|
34 } |
|
35 |