Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * "try" with "catch" or "finally" statement within/without an "do while" statement
6 *
7 * @path ch12/12.14/S12.14_A9_T3.js
8 * @description "try" statement within a loop, the statement contains "break" statement
9 */
11 // CHECK#1
12 var c1=0,fin=0;
13 do{
14 try{
15 c1+=1;
16 break;
17 }
18 catch(er1){}
19 finally{
20 fin=1;
21 }
22 fin=-1;
23 c1+=2;
24 }
25 while(c1<2);
26 if(fin!==1){
27 $ERROR('#1.1: "finally" block must be evaluated');
28 }
29 if(c1!==1){
30 $ERROR('#1.2: "try{break}catch finally" must work correctly');
31 }
33 // CHECK#2
34 var c2=0,fin2=0;
35 do{
36 try{
37 throw "ex1";
38 }
39 catch(er1){
40 c2+=1;
41 break;
42 }
43 finally{
44 fin2=1;
45 }
46 c2+=2;
47 fin2=-1;
48 }
49 while(c2<2);
50 if(fin2!==1){
51 $ERROR('#2.1: "finally" block must be evaluated');
52 }
53 if(c2!==1){
54 $ERROR('#2.2: "try catch{break} finally" must work correctly');
55 }
57 // CHECK#3
58 var c3=0,fin3=0;
59 do{
60 try{
61 throw "ex1";
62 }
63 catch(er1){
64 c3+=1;
65 }
66 finally{
67 fin3=1;
68 break;
69 }
70 c3+=2;
71 fin3=0;
72 }
73 while(c3<2);
74 if(fin3!==1){
75 $ERROR('#3.1: "finally" block must be evaluated');
76 }
77 if(c3!==1){
78 $ERROR('#3.2: "try catch finally{break}" must work correctly');
79 }
81 // CHECK#4
82 var c4=0,fin4=0;
83 do{
84 try{
85 c4+=1;
86 break;
87 }
88 finally{
89 fin4=1;
90 }
91 fin4=-1;
92 c4+=2;
93 }
94 while(c4<2);
95 if(fin4!==1){
96 $ERROR('#4.1: "finally" block must be evaluated');
97 }
98 if(c4!==1){
99 $ERROR('#4.2: "try{break} finally" must work correctly');
100 }
102 // CHECK#5
103 var c5=0;
104 do{
105 try{
106 throw "ex1";
107 }
108 catch(er1){
109 break;
110 }
111 }
112 while(c5<2);
113 if(c5!==0){
114 $ERROR('#5: "try catch{break}" must work correctly');
115 }
117 // CHECK#6
118 var c6=0;
119 do{
120 try{
121 c6+=1;
122 break;
123 }
124 catch(er1){}
125 c6+=2;
126 }
127 while(c6<2);
128 if(c6!==1){
129 $ERROR('#6: "try{break} catch" must work correctly');
130 }
132 // CHECK#7
133 var c7=0,fin7=0;
134 try{
135 do{
136 try{
137 c7+=1;
138 throw "ex1";
139 }
140 finally{
141 fin7=1;
142 break;
143 }
144 fin7=-1;
145 c7+=2;
146 }
147 while(c7<2);
148 }
149 catch(ex1){
150 c7=10;
151 }
152 if(fin7!==1){
153 $ERROR('#7.1: "finally" block must be evaluated');
154 }
155 if(c7!==1){
156 $ERROR('#7.2: try finally{break} error');
157 }