Debian Codegraph @

js/src/tests/test262/language/statements/try/S12.14_A12_T2.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 Using "try" with "catch" or "finally" statement within/without a "for-in"
7 statement
8 es5id: 12.14_A12_T2
9 description: Try statement inside loop, where use continue loop
10 ---*/
11
12 var x;
13 var mycars = new Array();
14 mycars[0] = "Saab";
15 mycars[1] = "Volvo";
16 mycars[2] = "BMW";
17
18 // CHECK#1
19 var fin=0;
20 var i=0;
21 for (x in mycars){
22 try{
23 i+=1;
24 continue;
25 }
26 catch(er1){}
27 finally{
28 fin=1;
29 }
30 fin=-1;
31 }
32 if(fin!==1){
33 throw new Test262Error('#1.1: "finally" block must be evaluated');
34 }
35 if(i!==3){
36 throw new Test262Error('#1.2: "try{continue} catch finally" must work correctly');
37 }
38
39 // CHECK#2
40 var c2=0,fin2=0;
41 for (x in mycars){
42 try{
43 throw "ex1";
44 }
45 catch(er1){
46 c2+=1;
47 continue;
48 }
49 finally{
50 fin2=1;
51 }
52 fin2=-1;
53 }
54 if(fin2!==1){
55 throw new Test262Error('#2.1: "finally" block must be evaluated');
56 }
57 if(c2!==3){
58 throw new Test262Error('#2.1: "try catch{continue} finally" must work correctly');
59 }
60
61 // CHECK#3
62 var c3=0,fin3=0;
63 for (x in mycars){
64 try{
65 throw "ex1";
66 }
67 catch(er1){
68 c3+=1;
69 }
70 finally{
71 fin3=1;
72 continue;
73 }
74 fin3=0;
75 }
76 if(c3!==3){
77 throw new Test262Error('#3.1: "finally" block must be evaluated');
78 }
79 if(fin3!==1){
80 throw new Test262Error('#3.2: "try catch finally{continue}" must work correctly');
81 }
82
83 // CHECK#4
84 var fin=0;
85 for (x in mycars){
86 try{
87 continue;
88 }
89 finally{
90 fin=1;
91 }
92 fin=-1;
93 }
94 if(fin!==1){
95 throw new Test262Error('#4: "finally" block must be evaluated at "try{continue} finally" construction');
96 }
97
98 // CHECK#5
99 var c5=0;
100 for (x in mycars){
101 try{
102 throw "ex1";
103 }
104 catch(er1){
105 c5+=1;
106 continue;
107 }
108 c5+=12;
109 }
110 if(c5!==3){
111 throw new Test262Error('#5: "try catch{continue}" must work correctly');
112 }
113
114 // CHECK#6
115 var c6=0,fin6=0;
116 for (x in mycars){
117 try{
118 c6+=1;
119 throw "ex1";
120 }
121 finally{
122 fin6=1;
123 continue;
124 }
125 fin6=-1;
126 }
127 if(fin6!==1){
128 throw new Test262Error('#6.1: "finally" block must be evaluated');
129 }
130 if(c6!==3){
131 throw new Test262Error('#6.2: "try finally{continue}" must work correctly');
132 }
133
134 reportCompare(0, 0);