|
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_T1.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") |
|
18 $ERROR('#1.1: Exception === "ex2". Actual: Exception ==='+ e ); |
|
19 throw "ex1"; |
|
20 } |
|
21 } |
|
22 catch(er1){ |
|
23 if (er1!=="ex1") $ERROR('#1.2: Exception === "ex1". Actual: '+er1); |
|
24 if (er1==="ex2") $ERROR('#1.3: Exception !== "ex2". Actual: catch previous embedded exception'); |
|
25 } |
|
26 |
|
27 // CHECK#2 |
|
28 try{ |
|
29 throw "ex1"; |
|
30 } |
|
31 catch(er1){ |
|
32 try{ |
|
33 throw "ex2"; |
|
34 } |
|
35 catch(er1){ |
|
36 if (er1==="ex1") $ERROR('#2.1: Exception !== "ex1". Actual: catch previous catching exception'); |
|
37 if (er1!=="ex2") $ERROR('#2.2: Exception === "ex2". Actual: Exception ==='+ er1 ); |
|
38 } |
|
39 if (er1!=="ex1") $ERROR('#2.3: Exception === "ex1". Actual: Exception ==='+ er1 ); |
|
40 if (er1==="ex2") $ERROR('#2.4: Exception !== "ex2". Actual: catch previous catching exception'); |
|
41 } |
|
42 |
|
43 // CHECK#3 |
|
44 try{ |
|
45 throw "ex1"; |
|
46 } |
|
47 catch(er1){ |
|
48 if (er1!=="ex1") $ERROR('#3.1: Exception ==="ex1". Actual: Exception ==='+ er1 ); |
|
49 } |
|
50 finally{ |
|
51 try{ |
|
52 throw "ex2"; |
|
53 } |
|
54 catch(er1){ |
|
55 if (er1==="ex1") $ERROR('#3.2: Exception !=="ex1". Actual: catch previous embedded exception'); |
|
56 if (er1!=="ex2") $ERROR('#3.3: Exception ==="ex2". Actual: Exception ==='+ er1 ); |
|
57 } |
|
58 } |
|
59 |
|
60 // CHECK#4 |
|
61 var c4=0; |
|
62 try{ |
|
63 throw "ex1"; |
|
64 } |
|
65 catch(er1){ |
|
66 try{ |
|
67 throw "ex2"; |
|
68 } |
|
69 catch(er1){ |
|
70 if (er1==="ex1") $ERROR('#4.1: Exception !=="ex1". Actual: catch previous catching exception'); |
|
71 if (er1!=="ex2") $ERROR('#4.2: Exception ==="ex2". Actual: Exception ==='+ er1 ); |
|
72 } |
|
73 if (er1!=="ex1") $ERROR('#4.3: Exception ==="ex1". Actual: Exception ==='+ er1 ); |
|
74 if (er1==="ex2") $ERROR('#4.4: Exception !=="ex2". Actual: Catch previous embedded exception'); |
|
75 } |
|
76 finally{ |
|
77 c4=1; |
|
78 } |
|
79 if (c4!==1) $ERROR('#4.5: "finally" block must be evaluated'); |
|
80 |
|
81 // CHECK#5 |
|
82 var c5=0; |
|
83 try{ |
|
84 try{ |
|
85 throw "ex2"; |
|
86 } |
|
87 catch(er1){ |
|
88 if (er1!=="ex2") $ERROR('#5.1: Exception ==="ex2". Actual: Exception ==='+ er1 ); |
|
89 } |
|
90 throw "ex1"; |
|
91 } |
|
92 catch(er1){ |
|
93 if (er1!=="ex1") $ERROR('#5.2: Exception ==="ex1". Actual: Exception ==='+ er1 ); |
|
94 if (er1==="ex2") $ERROR('#5.3: Exception !=="ex2". Actual: catch previous embedded exception'); |
|
95 } |
|
96 finally{ |
|
97 c5=1; |
|
98 } |
|
99 if (c5!==1) $ERROR('#5.4: "finally" block must be evaluated'); |
|
100 |
|
101 // CHECK#6 |
|
102 var c6=0; |
|
103 try{ |
|
104 try{ |
|
105 throw "ex1"; |
|
106 } |
|
107 catch(er1){ |
|
108 if (er1!=="ex1") $ERROR('#6.1: Exception ==="ex1". Actual: Exception ==='+ er1 ); |
|
109 } |
|
110 } |
|
111 finally{ |
|
112 c6=1; |
|
113 } |
|
114 if (c6!==1) $ERROR('#6.2: "finally" block must be evaluated'); |
|
115 |
|
116 // CHECK#7 |
|
117 var c7=0; |
|
118 try{ |
|
119 try{ |
|
120 throw "ex1"; |
|
121 } |
|
122 finally{ |
|
123 try{ |
|
124 c7=1; |
|
125 throw "ex2"; |
|
126 } |
|
127 catch(er1){ |
|
128 if (er1!=="ex2") $ERROR('#7.1: Exception ==="ex2". Actual: Exception ==='+ er1 ); |
|
129 if (er1==="ex1") $ERROR('#7.2: Exception !=="ex1". Actual: catch previous embedded exception'); |
|
130 c7++; |
|
131 } |
|
132 } |
|
133 } |
|
134 catch(er1){ |
|
135 if (er1!=="ex1") $ERROR('#7.3: Exception ==="ex1". Actual: Exception ==='+ er1 ); |
|
136 } |
|
137 if (c7!==2) $ERROR('#7.4: "finally" block must be evaluated'); |
|
138 |