|
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 * Throwing exception with "throw" and catching it with "try" statement |
|
6 * |
|
7 * @path ch12/12.14/S12.14_A2.js |
|
8 * @description Checking if execution of "catch" catches an exception thrown with "throw" |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 try { |
|
13 throw "catchme"; |
|
14 $ERROR('#1: throw "catchme" lead to throwing exception'); |
|
15 } |
|
16 catch(e){} |
|
17 |
|
18 // CHECK#2 |
|
19 var c2=0; |
|
20 try{ |
|
21 try{ |
|
22 throw "exc"; |
|
23 $ERROR('#2.1: throw "exc" lead to throwing exception'); |
|
24 }finally{ |
|
25 c2=1; |
|
26 } |
|
27 } |
|
28 catch(e){ |
|
29 if (c2!==1){ |
|
30 $ERROR('#2.2: "finally" block must be evaluated'); |
|
31 } |
|
32 } |
|
33 |
|
34 // CHECK#3 |
|
35 var c3=0; |
|
36 try{ |
|
37 throw "exc"; |
|
38 $ERROR('#3.1: throw "exc" lead to throwing exception'); |
|
39 } |
|
40 catch(err){ |
|
41 var x3=1; |
|
42 } |
|
43 finally{ |
|
44 c3=1; |
|
45 } |
|
46 if (x3!==1){ |
|
47 $ERROR('#3.2: "catch" block must be evaluated'); |
|
48 } |
|
49 if (c3!==1){ |
|
50 $ERROR('#3.3: "finally" block must be evaluated'); |
|
51 } |
|
52 |