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