js/src/tests/test262/ch12/12.14/S12.14_A7_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_A7_T2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,152 @@
     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 + * Evaluating the nested productions TryStatement
     1.9 + *
    1.10 + * @path ch12/12.14/S12.14_A7_T2.js
    1.11 + * @description Checking if the production of nested TryStatement statements evaluates correct
    1.12 + */
    1.13 +
    1.14 +// CHECK#1
    1.15 +try{
    1.16 +  try{
    1.17 +    throw "ex2";
    1.18 +  }
    1.19 +  finally{
    1.20 +    throw "ex1";
    1.21 +  }
    1.22 +}
    1.23 +catch(er1){
    1.24 +  if (er1!=="ex1") $ERROR('#1.2: Exception === "ex1". Actual:  Exception ==='+er1 );
    1.25 +  if (er1==="ex2") $ERROR('#1.3: Exception !== "ex2". Actual: catch previous embedded exception');
    1.26 +}
    1.27 +
    1.28 +// CHECK#2
    1.29 +try{
    1.30 +  try{
    1.31 +    throw "ex1";
    1.32 +  }
    1.33 +  catch(er1){
    1.34 +    if (er1!=="ex1") $ERROR('#2.1: Exception === "ex1". Actual:  Exception ==='+er1 );
    1.35 +    try{
    1.36 +      throw "ex2";
    1.37 +    }
    1.38 +    finally{
    1.39 +      throw "ex3";
    1.40 +    }
    1.41 +    $ERROR('#2.2: throw "ex1" lead to throwing exception');
    1.42 +  }
    1.43 +}
    1.44 +catch(er1){
    1.45 +  if (er1!=="ex3") $ERROR('#2.3: Exception === "ex3". Actual:  Exception ==='+er1 );
    1.46 +}
    1.47 +
    1.48 +// CHECK#3
    1.49 +try{
    1.50 +  try{
    1.51 +    throw "ex1";
    1.52 +  }
    1.53 +  catch(er1){
    1.54 +    if (er1!=="ex1") $ERROR('#3.1: Exception === "ex1". Actual:  Exception ==='+er1 );
    1.55 +  }
    1.56 +  finally{
    1.57 +    try{
    1.58 +      throw "ex2";
    1.59 +    }
    1.60 +    finally{
    1.61 +      throw "ex3";
    1.62 +    }
    1.63 +  }	
    1.64 +}
    1.65 +catch(er1){
    1.66 +  if (er1!=="ex3") $ERROR('#3.2: Exception === "ex3". Actual:  Exception ==='+er1 );
    1.67 +}
    1.68 +
    1.69 +// CHECK#4
    1.70 +var c4=0;
    1.71 +try{
    1.72 +  try{
    1.73 +    throw "ex1";
    1.74 +  }
    1.75 +  catch(er1){
    1.76 +    if (er1!=="ex1") $ERROR('#4.1: Exception === "ex1". Actual:  Exception ==='+er1 );
    1.77 +    try{
    1.78 +      throw "ex2";
    1.79 +    }
    1.80 +    finally{
    1.81 +      throw "ex3";
    1.82 +    }
    1.83 +  }
    1.84 +  finally{
    1.85 +    c4=1;
    1.86 +  }
    1.87 +}
    1.88 +catch(er1){
    1.89 +  if (er1!=="ex3") $ERROR('#4.2: Exception === "ex3". Actual:  Exception ==='+er1 );
    1.90 +}
    1.91 +if (c4!==1) $ERROR('#4.3: "finally" block must be evaluated');
    1.92 +
    1.93 +// CHECK#5
    1.94 +var c5=0;
    1.95 +try{
    1.96 +  try{
    1.97 +    throw "ex2";
    1.98 +  }
    1.99 +  finally{
   1.100 +    throw "ex3";
   1.101 +  }
   1.102 +  throw "ex1";
   1.103 +}
   1.104 +catch(er1){
   1.105 +  if (er1!=="ex3") $ERROR('#5.1: Exception === "ex3". Actual:  Exception ==='+er1 );
   1.106 +  if (er1==="ex2") $ERROR('#5.2: Exception !== "ex2". Actual: catch previous embedded exception');
   1.107 +  if (er1==="ex1") $ERROR('#5.3: Exception !=="ex1". Actual: catch previous embedded exception');
   1.108 +}
   1.109 +finally{
   1.110 +  c5=1;
   1.111 +}
   1.112 +if (c5!==1) $ERROR('#5.4: "finally" block must be evaluated');
   1.113 +
   1.114 +// CHECK#6
   1.115 +var c6=0;
   1.116 +try{
   1.117 +  try{
   1.118 +    try{
   1.119 +      throw "ex1";
   1.120 +    }
   1.121 +    finally{
   1.122 +      throw "ex2";
   1.123 +    }
   1.124 +  }
   1.125 +  finally{
   1.126 +    c6=1;
   1.127 +  }
   1.128 +}
   1.129 +catch(er1){
   1.130 +  if (er1!=="ex2") $ERROR('#6.1: Exception === "ex2". Actual:  Exception ==='+er1 );
   1.131 +}
   1.132 +if (c6!==1) $ERROR('#6.2: "finally" block must be evaluated');
   1.133 +
   1.134 +// CHECK#7
   1.135 +var c7=0;
   1.136 +try{
   1.137 +  try{
   1.138 +    throw "ex1";
   1.139 +  }
   1.140 +  finally{
   1.141 +    try{
   1.142 +      c7=1;
   1.143 +      throw "ex2";
   1.144 +    }
   1.145 +    finally{
   1.146 +      c7++;
   1.147 +      throw "ex3";
   1.148 +    }
   1.149 +  }
   1.150 +}
   1.151 +catch(er1){
   1.152 +  if (er1!=="ex3") $ERROR('#7.1: Exception === "ex3". Actual:  Exception ==='+er1 );
   1.153 +}
   1.154 +if (c7!==2) $ERROR('#7.2: Embedded "try/finally" blocks must be evaluated');
   1.155 +

mercurial