|
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_T2.js |
|
8 * @description "try" statement within a loop, the statement contains "continue" statement |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 var c1=0,fin=0; |
|
13 do{ |
|
14 try{ |
|
15 c1+=1; |
|
16 continue; |
|
17 } |
|
18 catch(er1){} |
|
19 finally{ |
|
20 fin=1; |
|
21 } |
|
22 fin=-1; |
|
23 } |
|
24 while(c1<2); |
|
25 if(fin!==1){ |
|
26 $ERROR('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); |
|
27 } |
|
28 |
|
29 // CHECK#2 |
|
30 var c2=0,fin2=0; |
|
31 do{ |
|
32 try{ |
|
33 throw "ex1"; |
|
34 } |
|
35 catch(er1){ |
|
36 c2+=1; |
|
37 continue; |
|
38 } |
|
39 finally{ |
|
40 fin2=1; |
|
41 } |
|
42 fin2=-1; |
|
43 } |
|
44 while(c2<2); |
|
45 if(fin2!==1){ |
|
46 $ERROR('#2: "finally" block must be evaluated at "try catch{continue} finally" construction'); |
|
47 } |
|
48 |
|
49 // CHECK#3 |
|
50 var c3=0,fin3=0; |
|
51 do{ |
|
52 try{ |
|
53 throw "ex1"; |
|
54 } |
|
55 catch(er1){ |
|
56 c3+=1; |
|
57 } |
|
58 finally{ |
|
59 fin3=1; |
|
60 continue; |
|
61 } |
|
62 fin3=0; |
|
63 } |
|
64 while(c3<2); |
|
65 if(fin3!==1){ |
|
66 $ERROR('#3: "finally" block must be evaluated at "try catch finally{continue}" construction'); |
|
67 } |
|
68 |
|
69 // CHECK#4 |
|
70 var c4=0,fin4=0; |
|
71 do{ |
|
72 try{ |
|
73 c4+=1; |
|
74 continue; |
|
75 } |
|
76 finally{ |
|
77 fin4=1; |
|
78 } |
|
79 fin4=-1; |
|
80 } |
|
81 while(c4<2); |
|
82 if(fin4!==1){ |
|
83 $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); |
|
84 } |
|
85 |
|
86 // CHECK#5 |
|
87 var c5=0; |
|
88 do{ |
|
89 try{ |
|
90 throw "ex1"; |
|
91 } |
|
92 catch(er1){ |
|
93 c5+=1; |
|
94 continue; |
|
95 } |
|
96 } |
|
97 while(c5<2); |
|
98 if(c5!==2){ |
|
99 $ERROR('#5: "try catch{continue}" must work correctly'); |
|
100 } |
|
101 |
|
102 // CHECK#6 |
|
103 var c6=0,fin6=0; |
|
104 do{ |
|
105 try{ |
|
106 c6+=1; |
|
107 throw "ex1" |
|
108 } |
|
109 finally{ |
|
110 fin6=1; |
|
111 continue; |
|
112 } |
|
113 fin6=-1; |
|
114 } |
|
115 while(c6<2); |
|
116 if(fin6!==1){ |
|
117 $ERROR('#6.1: "finally" block must be evaluated'); |
|
118 } |
|
119 if(c6!==2){ |
|
120 $ERROR('#6.2: "try finally{continue}" must work correctly'); |
|
121 } |
|
122 |