Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * Catching system exceptions of different types with try statement
6 *
7 * @path ch12/12.14/S12.14_A19_T2.js
8 * @description Testing try/catch/finally syntax construction
9 */
11 var fin=0;
12 // CHECK#1
13 try{
14 throw (Error("hello"));
15 }
16 catch(e){
17 if (e.toString()!=="Error: hello") $ERROR('#1.1: Exception.toString()==="Error: hello". Actual: Exception is '+e);
18 }
19 finally{
20 fin=1;
21 }
22 if (fin!==1) $ERROR('#1.2: "finally" block must be evaluated');
24 // CHECK#2
25 fin=0;
26 try{
27 throw (new Error("hello"));
28 }
29 catch(e){
30 if (e.toString()!=="Error: hello") $ERROR('#2.1: Exception.toString()==="Error: hello". Actual: Exception is '+e);
31 }
32 finally{
33 fin=1;
34 }
35 if (fin!==1) $ERROR('#2.2: "finally" block must be evaluated');
37 // CHECK#3
38 fin=0;
39 var c3=0;
40 try{
41 throw EvalError(1);
42 }
43 catch(e){
44 if (e.toString()!=="EvalError: 1") $ERROR('#3.1: Exception.toString()==="EvalError: 1". Actual: Exception is '+e);
45 }
46 finally{
47 fin=1;
48 }
49 if (fin!==1) $ERROR('#3.2: "finally" block must be evaluated');
51 // CHECK#4
52 fin=0;
53 try{
54 throw RangeError(1);
55 }
56 catch(e){
57 if (e.toString()!=="RangeError: 1") $ERROR('#4.1: Exception.toString()==="RangeError: 1". Actual: Exception is '+e);
58 }
59 finally{
60 fin=1;
61 }
62 if (fin!==1) $ERROR('#4.2: "finally" block must be evaluated');
64 // CHECK#5
65 fin=0;
66 try{
67 throw ReferenceError(1);
68 }
69 catch(e){
70 if (e.toString()!=="ReferenceError: 1") $ERROR('#5.1: Exception.toString()==="ReferenceError: 1". Actual: Exception is '+e);
71 }
72 finally{
73 fin=1;
74 }
75 if (fin!==1) $ERROR('#5.2: "finally" block must be evaluated');
77 // CHECK#6
78 fin=0;
79 try{
80 throw TypeError(1);
81 }
82 catch(e){
83 if (e.toString()!=="TypeError: 1") $ERROR('#6.1: Exception.toString()==="TypeError: 1". Actual: Exception is '+e);
84 }
85 finally{
86 fin=1;
87 }
88 if (fin!==1) $ERROR('#6.2: "finally" block must be evaluated');
90 // CHECK#7
91 fin=0;
92 try{
93 throw URIError("message", "fileName", "1");
94 }
95 catch(e){
96 if (e.toString()!=="URIError: message") $ERROR('#7.1: Exception.toString()==="URIError: message". Actual: Exception is '+e);
97 }
98 finally{
99 fin=1;
100 }
101 if (fin!==1) $ERROR('#7.2: "finally" block must be evaluated');