|
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 * Evaluating the nested productions TryStatement |
|
6 * |
|
7 * @path ch12/12.14/S12.14_A7_T3.js |
|
8 * @description Checking if the production of nested TryStatement statements evaluates correct |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 try{ |
|
13 try{ |
|
14 throw "ex2"; |
|
15 } |
|
16 catch(er2){ |
|
17 if (er2!=="ex2") $ERROR('#1.1: Exception === "ex2". Actual: Exception ==='+er2); |
|
18 throw "ex1"; |
|
19 } |
|
20 finally{ |
|
21 throw "ex3"; |
|
22 } |
|
23 } |
|
24 catch(er1){ |
|
25 if (er1!=="ex3") $ERROR('#1.2: Exception === "ex3". Actual: Exception ==='+er1); |
|
26 if (er1==="ex2") $ERROR('#1.3: Exception !=="ex2". Actual: catch previous catched exception'); |
|
27 if (er1==="ex1") $ERROR('#1.4: Exception !=="ex1". Actual: catch previous embedded exception'); |
|
28 } |
|
29 |
|
30 // CHECK#2 |
|
31 var c2=0; |
|
32 try{ |
|
33 throw "ex1"; |
|
34 } |
|
35 catch(er1){ |
|
36 try{ |
|
37 throw "ex2"; |
|
38 } |
|
39 catch(er1){ |
|
40 if (er1==="ex1") $ERROR('#2.1: Exception !=="ex1". Actual: catch previous catched exception'); |
|
41 if (er1!=="ex2") $ERROR('#2.2: Exception === "ex2". Actual: Exception ==='+er1); |
|
42 } |
|
43 finally{ |
|
44 c2=1; |
|
45 } |
|
46 if (er1!=="ex1") $ERROR('#2.3: Exception === "ex1". Actual: Exception ==='+er1); |
|
47 if (er1==="ex2") $ERROR('#2.4: Exception !== "ex2". Actual: catch previous embedded exception'); |
|
48 } |
|
49 if (c2!==1) $ERROR('#2.5: "finally" block must be evaluated'); |
|
50 |
|
51 // CHECK#3 |
|
52 var c3=0; |
|
53 try{ |
|
54 throw "ex1"; |
|
55 } |
|
56 catch(er1){ |
|
57 if (er1!=="ex1") $ERROR('#3.1: Exception === "ex1". Actual: Exception ==='+er1); |
|
58 } |
|
59 finally{ |
|
60 try{ |
|
61 throw "ex2"; |
|
62 } |
|
63 catch(er1){ |
|
64 if (er1==="ex1") $ERROR('#3.2: Exception !=="ex1". Actual: catch previous catched exception'); |
|
65 if (er1!=="ex2") $ERROR('#3.3: Exception === "ex2". Actual: Exception ==='+er1); |
|
66 } |
|
67 finally{ |
|
68 c3=1; |
|
69 } |
|
70 } |
|
71 if (c3!==1) $ERROR('#3.4: "finally" block must be evaluated'); |
|
72 |
|
73 // CHECK#4 |
|
74 var c4=0; |
|
75 try{ |
|
76 try{ |
|
77 throw "ex1"; |
|
78 } |
|
79 catch(er1){ |
|
80 try{ |
|
81 throw "ex2"; |
|
82 } |
|
83 catch(er1){ |
|
84 if (er1==="ex1") $ERROR('#4.1: Exception !=="ex2". Actual: catch previous catched exception'); |
|
85 if (er1!=="ex2") $ERROR('#4.2: Exception === "ex2". Actual: Exception ==='+er1); |
|
86 } |
|
87 finally{ |
|
88 c4=2; |
|
89 throw "ex3"; |
|
90 } |
|
91 if (er1!=="ex1") $ERROR('#4.3: Exception === "ex2". Actual: Exception ==='+er1); |
|
92 if (er1==="ex2") $ERROR('#4.4: Exception !=="ex2". Actual: catch previous catched exception'); |
|
93 if (er1==="ex3") $ERROR('#4.5: Exception !=="ex3". Actual: Catch previous embedded exception'); |
|
94 } |
|
95 finally{ |
|
96 c4*=2; |
|
97 } |
|
98 } |
|
99 catch(er1){} |
|
100 if (c4!==4) $ERROR('#4.6: "finally" block must be evaluated'); |
|
101 |
|
102 // CHECK#5 |
|
103 var c5=0; |
|
104 try{ |
|
105 try{ |
|
106 throw "ex2"; |
|
107 } |
|
108 catch(er1){ |
|
109 if (er1!=="ex2") $ERROR('#5.1: Exception === "ex2". Actual: Exception ==='+er1); |
|
110 } |
|
111 finally{ |
|
112 throw "ex3"; |
|
113 } |
|
114 throw "ex1"; |
|
115 } |
|
116 catch(er1){ |
|
117 if (er1!=="ex3") $ERROR('#5.2: Exception === "ex3". Actual: Exception ==='+er1); |
|
118 if (er1==="ex2") $ERROR('#5.3: Exception !=="ex2". Actual: catch previous catched exception'); |
|
119 if (er1==="ex1") $ERROR('#5.4: Exception !=="ex1". Actual: catch previous embedded exception'); |
|
120 } |
|
121 finally{ |
|
122 c5=1; |
|
123 } |
|
124 if (c5!==1) $ERROR('#5.5: "finally" block must be evaluated'); |
|
125 |
|
126 // CHECK#6 |
|
127 var c6=0; |
|
128 try{ |
|
129 try{ |
|
130 throw "ex1"; |
|
131 } |
|
132 catch(er1){ |
|
133 if (er1!=="ex1") $ERROR('#6.1: Exception === "ex1". Actual: Exception ==='+er1); |
|
134 } |
|
135 finally{ |
|
136 c6=2; |
|
137 } |
|
138 } |
|
139 finally{ |
|
140 c6*=2; |
|
141 } |
|
142 if (c6!==4) $ERROR('#6.2: "finally" block must be evaluated'); |
|
143 |
|
144 // CHECK#7 |
|
145 var c7=0; |
|
146 try{ |
|
147 try{ |
|
148 throw "ex1"; |
|
149 } |
|
150 finally{ |
|
151 try{ |
|
152 c7=1; |
|
153 throw "ex2"; |
|
154 } |
|
155 catch(er1){ |
|
156 if (er1!=="ex2") $ERROR('#7.1: Exception === "ex2". Actual: Exception ==='+er1); |
|
157 if (er1==="ex1") $ERROR('#7.2: Exception !=="ex2". Actual: catch previous catched exception'); |
|
158 c7++; |
|
159 } |
|
160 finally{ |
|
161 c7*=2; |
|
162 } |
|
163 } |
|
164 } |
|
165 catch(er1){ |
|
166 if (er1!=="ex1") $ERROR('#7.3: Exception === "ex1". Actual: Exception ==='+er1); |
|
167 } |
|
168 if (c7!==4) $ERROR('#7.4: "finally" block must be evaluated'); |
|
169 |