|
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 * The production TryStatement: "try Block Catch Finally" |
|
6 * |
|
7 * @path ch12/12.14/S12.14_A6.js |
|
8 * @description Executing sequence of "try" statements, using counters with varying values within |
|
9 */ |
|
10 |
|
11 // CHECK#1 |
|
12 var c1=0; |
|
13 try { |
|
14 c1+=1; |
|
15 y; |
|
16 $ERROR('#1.1: "y" lead to throwing exception'); |
|
17 } |
|
18 catch (e) { |
|
19 c1*=2; |
|
20 } |
|
21 if (c1!==2){ |
|
22 $ERROR('#1.2: Sequence evaluation of commands try/catch is 1. try, 2. catch'); |
|
23 } |
|
24 |
|
25 // CHECK#2 |
|
26 var c2=0; |
|
27 try{ |
|
28 c2+=1; |
|
29 } |
|
30 finally{ |
|
31 c2*=2; |
|
32 } |
|
33 if (c2!==2){ |
|
34 $ERROR('#2: Sequence evaluation of commands try/finally is 1. try, 2. finally'); |
|
35 } |
|
36 |
|
37 // CHECK#3 |
|
38 var c3=0; |
|
39 try{ |
|
40 c3=1; |
|
41 z; |
|
42 } |
|
43 catch(err){ |
|
44 c3*=2; |
|
45 } |
|
46 finally{ |
|
47 c3+=1; |
|
48 } |
|
49 if (c3!==3){ |
|
50 $ERROR('#3: Sequence evaluation of commands try/catch/finally(with exception) is 1. try, 2. catch, 3. finally'); |
|
51 } |
|
52 |
|
53 // CHECK#4 |
|
54 var c4=0; |
|
55 try{ |
|
56 c4=1; |
|
57 } |
|
58 catch(err){ |
|
59 c4*=3; |
|
60 } |
|
61 finally{ |
|
62 c4+=1; |
|
63 } |
|
64 if (c4!==2){ |
|
65 $ERROR('#4: Sequence evaluation of commands try/catch/finally(without exception) is 1. try, 2. finally'); |
|
66 } |
|
67 |