|
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 * Using "try" with "catch" or "finally" statement within/without a "while" statement |
|
6 * |
|
7 * @path ch12/12.14/S12.14_A10_T5.js |
|
8 * @description Throw some exceptions from different place of loop body |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 var c=0, i=0; |
|
13 var fin=0; |
|
14 while(i<10){ |
|
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 if(fin!==10){ |
|
37 $ERROR('#1.4: "finally" block must be evaluated'); |
|
38 } |
|
39 |