|
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 "do while" statement |
|
6 * |
|
7 * @path ch12/12.14/S12.14_A9_T5.js |
|
8 * @description Checking if exceptions are thrown correctly from wherever of loop body |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 var c=0, i=0; |
|
13 var fin=0; |
|
14 do{ |
|
15 i+=1; |
|
16 try{ |
|
17 if(c===0){ |
|
18 throw "ex1"; |
|
19 $ERROR('#1.1: throw "ex1" lead to throwing exception'); |
|
20 } |
|
21 c+=2; |
|
22 if(c===1){ |
|
23 throw "ex2"; |
|
24 $ERROR('#1.2: throw "ex2" lead to throwing exception'); |
|
25 } |
|
26 } |
|
27 catch(er1){ |
|
28 c-=1; |
|
29 continue; |
|
30 $ERROR('#1.3: "try catch{continue} finally" must work correctly'); |
|
31 } |
|
32 finally{ |
|
33 fin+=1; |
|
34 } |
|
35 } |
|
36 while(i<10); |
|
37 if(fin!==10){ |
|
38 $ERROR('#1.4: "finally" block must be evaluated'); |
|
39 } |
|
40 |
|
41 |