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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A19_T2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,102 @@
     1.4 +// Copyright 2009 the Sputnik authors.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * Catching system exceptions of different types with try statement
     1.9 + *
    1.10 + * @path ch12/12.14/S12.14_A19_T2.js
    1.11 + * @description Testing try/catch/finally syntax construction
    1.12 + */
    1.13 +
    1.14 +var fin=0;
    1.15 +// CHECK#1
    1.16 +try{
    1.17 +  throw (Error("hello"));
    1.18 +}
    1.19 +catch(e){
    1.20 +  if (e.toString()!=="Error: hello") $ERROR('#1.1: Exception.toString()==="Error: hello". Actual: Exception is '+e);
    1.21 +}
    1.22 +finally{
    1.23 +  fin=1;
    1.24 +}
    1.25 +if (fin!==1) $ERROR('#1.2: "finally" block must be evaluated'); 
    1.26 +
    1.27 +// CHECK#2
    1.28 +fin=0;
    1.29 +try{
    1.30 +  throw (new Error("hello"));
    1.31 +}
    1.32 +catch(e){
    1.33 +  if (e.toString()!=="Error: hello") $ERROR('#2.1: Exception.toString()==="Error: hello". Actual: Exception is '+e);
    1.34 +}
    1.35 +finally{
    1.36 +  fin=1;
    1.37 +}
    1.38 +if (fin!==1) $ERROR('#2.2: "finally" block must be evaluated'); 
    1.39 +
    1.40 +// CHECK#3
    1.41 +fin=0;
    1.42 +var c3=0;
    1.43 +try{
    1.44 +  throw EvalError(1);
    1.45 +}
    1.46 +catch(e){
    1.47 +  if (e.toString()!=="EvalError: 1") $ERROR('#3.1: Exception.toString()==="EvalError: 1". Actual: Exception is '+e);
    1.48 +}
    1.49 +finally{
    1.50 +  fin=1;
    1.51 +}
    1.52 +if (fin!==1) $ERROR('#3.2: "finally" block must be evaluated'); 
    1.53 +
    1.54 +// CHECK#4
    1.55 +fin=0;
    1.56 +try{
    1.57 +  throw RangeError(1);
    1.58 +}
    1.59 +catch(e){
    1.60 +  if (e.toString()!=="RangeError: 1") $ERROR('#4.1: Exception.toString()==="RangeError: 1". Actual: Exception is '+e);
    1.61 +}
    1.62 +finally{
    1.63 +  fin=1;
    1.64 +}
    1.65 +if (fin!==1) $ERROR('#4.2: "finally" block must be evaluated'); 
    1.66 +
    1.67 +// CHECK#5
    1.68 +fin=0;
    1.69 +try{
    1.70 +  throw ReferenceError(1);
    1.71 +}
    1.72 +catch(e){
    1.73 +  if (e.toString()!=="ReferenceError: 1") $ERROR('#5.1: Exception.toString()==="ReferenceError: 1". Actual: Exception is '+e);
    1.74 +}
    1.75 +finally{
    1.76 +  fin=1;
    1.77 +}
    1.78 +if (fin!==1) $ERROR('#5.2: "finally" block must be evaluated'); 
    1.79 +
    1.80 +// CHECK#6
    1.81 +fin=0;
    1.82 +try{
    1.83 +  throw TypeError(1);
    1.84 +}
    1.85 +catch(e){
    1.86 +  if (e.toString()!=="TypeError: 1") $ERROR('#6.1: Exception.toString()==="TypeError: 1". Actual: Exception is '+e);
    1.87 +}
    1.88 +finally{
    1.89 +  fin=1;
    1.90 +}
    1.91 +if (fin!==1) $ERROR('#6.2: "finally" block must be evaluated'); 
    1.92 +
    1.93 +// CHECK#7
    1.94 +fin=0;
    1.95 +try{
    1.96 +  throw URIError("message", "fileName", "1"); 
    1.97 +}
    1.98 +catch(e){
    1.99 +  if (e.toString()!=="URIError: message") $ERROR('#7.1: Exception.toString()==="URIError: message". Actual: Exception is '+e);
   1.100 +}
   1.101 +finally{
   1.102 +  fin=1;
   1.103 +}
   1.104 +if (fin!==1) $ERROR('#7.2: "finally" block must be evaluated'); 
   1.105 +

mercurial