js/src/tests/test262/ch12/12.14/S12.14_A19_T2.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial