Debian Codegraph @

js/src/tests/test262/language/statements/try/S12.14_A9_T3.js

raw
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 info: |
6 "try" with "catch" or "finally" statement within/without an "do while"
7 statement
8 es5id: 12.14_A9_T3
9 description: >
10 "try" statement within a loop, the statement contains "break"
11 statement
12 ---*/
13
14 // CHECK#1
15 var c1=0,fin=0;
16 do{
17 try{
18 c1+=1;
19 break;
20 }
21 catch(er1){}
22 finally{
23 fin=1;
24 }
25 fin=-1;
26 c1+=2;
27 }
28 while(c1<2);
29 if(fin!==1){
30 throw new Test262Error('#1.1: "finally" block must be evaluated');
31 }
32 if(c1!==1){
33 throw new Test262Error('#1.2: "try{break}catch finally" must work correctly');
34 }
35
36 // CHECK#2
37 var c2=0,fin2=0;
38 do{
39 try{
40 throw "ex1";
41 }
42 catch(er1){
43 c2+=1;
44 break;
45 }
46 finally{
47 fin2=1;
48 }
49 c2+=2;
50 fin2=-1;
51 }
52 while(c2<2);
53 if(fin2!==1){
54 throw new Test262Error('#2.1: "finally" block must be evaluated');
55 }
56 if(c2!==1){
57 throw new Test262Error('#2.2: "try catch{break} finally" must work correctly');
58 }
59
60 // CHECK#3
61 var c3=0,fin3=0;
62 do{
63 try{
64 throw "ex1";
65 }
66 catch(er1){
67 c3+=1;
68 }
69 finally{
70 fin3=1;
71 break;
72 }
73 c3+=2;
74 fin3=0;
75 }
76 while(c3<2);
77 if(fin3!==1){
78 throw new Test262Error('#3.1: "finally" block must be evaluated');
79 }
80 if(c3!==1){
81 throw new Test262Error('#3.2: "try catch finally{break}" must work correctly');
82 }
83
84 // CHECK#4
85 var c4=0,fin4=0;
86 do{
87 try{
88 c4+=1;
89 break;
90 }
91 finally{
92 fin4=1;
93 }
94 fin4=-1;
95 c4+=2;
96 }
97 while(c4<2);
98 if(fin4!==1){
99 throw new Test262Error('#4.1: "finally" block must be evaluated');
100 }
101 if(c4!==1){
102 throw new Test262Error('#4.2: "try{break} finally" must work correctly');
103 }
104
105 // CHECK#5
106 var c5=0;
107 do{
108 try{
109 throw "ex1";
110 }
111 catch(er1){
112 break;
113 }
114 }
115 while(c5<2);
116 if(c5!==0){
117 throw new Test262Error('#5: "try catch{break}" must work correctly');
118 }
119
120 // CHECK#6
121 var c6=0;
122 do{
123 try{
124 c6+=1;
125 break;
126 }
127 catch(er1){}
128 c6+=2;
129 }
130 while(c6<2);
131 if(c6!==1){
132 throw new Test262Error('#6: "try{break} catch" must work correctly');
133 }
134
135 // CHECK#7
136 var c7=0,fin7=0;
137 try{
138 do{
139 try{
140 c7+=1;
141 throw "ex1";
142 }
143 finally{
144 fin7=1;
145 break;
146 }
147 fin7=-1;
148 c7+=2;
149 }
150 while(c7<2);
151 }
152 catch(ex1){
153 c7=10;
154 }
155 if(fin7!==1){
156 throw new Test262Error('#7.1: "finally" block must be evaluated');
157 }
158 if(c7!==1){
159 throw new Test262Error('#7.2: try finally{break} error');
160 }
161
162 reportCompare(0, 0);