js/src/tests/test262/ch12/12.14/S12.14_A7_T3.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_T3.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,169 @@
     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_T3.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 +  catch(er2){
    1.20 +    if (er2!=="ex2") $ERROR('#1.1: Exception === "ex2". Actual:  Exception ==='+er2);
    1.21 +    throw "ex1";
    1.22 +  }
    1.23 +  finally{
    1.24 +    throw "ex3";
    1.25 +  }
    1.26 +}
    1.27 +catch(er1){
    1.28 +  if (er1!=="ex3") $ERROR('#1.2: Exception === "ex3". Actual:  Exception ==='+er1);
    1.29 +  if (er1==="ex2") $ERROR('#1.3: Exception !=="ex2". Actual: catch previous catched exception');
    1.30 +  if (er1==="ex1") $ERROR('#1.4: Exception !=="ex1". Actual: catch previous embedded exception');
    1.31 +}
    1.32 +
    1.33 +// CHECK#2
    1.34 +var c2=0;
    1.35 +try{
    1.36 +  throw "ex1";
    1.37 +}
    1.38 +catch(er1){
    1.39 +  try{
    1.40 +    throw "ex2";
    1.41 +  }
    1.42 +  catch(er1){
    1.43 +    if (er1==="ex1") $ERROR('#2.1: Exception !=="ex1". Actual: catch previous catched exception');
    1.44 +    if (er1!=="ex2") $ERROR('#2.2: Exception === "ex2". Actual:  Exception ==='+er1);
    1.45 +  }
    1.46 +  finally{
    1.47 +    c2=1;
    1.48 +  }
    1.49 +  if (er1!=="ex1") $ERROR('#2.3: Exception === "ex1". Actual:  Exception ==='+er1);
    1.50 +  if (er1==="ex2") $ERROR('#2.4: Exception !== "ex2". Actual: catch previous embedded exception');
    1.51 +}
    1.52 +if (c2!==1)	$ERROR('#2.5: "finally" block must be evaluated');
    1.53 +
    1.54 +// CHECK#3
    1.55 +var c3=0;
    1.56 +try{
    1.57 +  throw "ex1";
    1.58 +}
    1.59 +catch(er1){
    1.60 +  if (er1!=="ex1") $ERROR('#3.1: Exception === "ex1". Actual:  Exception ==='+er1);
    1.61 +}
    1.62 +finally{
    1.63 +  try{
    1.64 +    throw "ex2";
    1.65 +  }
    1.66 +  catch(er1){
    1.67 +    if (er1==="ex1") $ERROR('#3.2: Exception !=="ex1". Actual: catch previous catched exception');
    1.68 +    if (er1!=="ex2") $ERROR('#3.3: Exception === "ex2". Actual:  Exception ==='+er1);
    1.69 +  }
    1.70 +  finally{
    1.71 +    c3=1;
    1.72 +  }
    1.73 +}
    1.74 +if (c3!==1)	$ERROR('#3.4: "finally" block must be evaluated');
    1.75 +
    1.76 +// CHECK#4
    1.77 +var c4=0;
    1.78 +try{
    1.79 +  try{
    1.80 +    throw "ex1";
    1.81 +  }
    1.82 +  catch(er1){
    1.83 +    try{
    1.84 +      throw "ex2";
    1.85 +    }
    1.86 +    catch(er1){
    1.87 +      if (er1==="ex1") $ERROR('#4.1: Exception !=="ex2". Actual: catch previous catched exception');
    1.88 +      if (er1!=="ex2") $ERROR('#4.2: Exception === "ex2". Actual:  Exception ==='+er1);
    1.89 +    }
    1.90 +    finally{
    1.91 +      c4=2;
    1.92 +      throw "ex3";
    1.93 +    }
    1.94 +    if (er1!=="ex1") $ERROR('#4.3: Exception === "ex2". Actual:  Exception ==='+er1);
    1.95 +    if (er1==="ex2") $ERROR('#4.4: Exception !=="ex2". Actual: catch previous catched exception');
    1.96 +    if (er1==="ex3") $ERROR('#4.5: Exception !=="ex3". Actual: Catch previous embedded exception');
    1.97 +  }
    1.98 +  finally{
    1.99 +    c4*=2;
   1.100 +  }
   1.101 +}
   1.102 +catch(er1){}
   1.103 +if (c4!==4) $ERROR('#4.6: "finally" block must be evaluated');
   1.104 +
   1.105 +// CHECK#5
   1.106 +var c5=0;
   1.107 +try{
   1.108 +  try{
   1.109 +    throw "ex2";
   1.110 +  }
   1.111 +  catch(er1){
   1.112 +    if (er1!=="ex2") $ERROR('#5.1: Exception === "ex2". Actual:  Exception ==='+er1);
   1.113 +  }
   1.114 +  finally{
   1.115 +    throw "ex3";
   1.116 +  }
   1.117 +  throw "ex1";
   1.118 +}
   1.119 +catch(er1){
   1.120 +  if (er1!=="ex3") $ERROR('#5.2: Exception === "ex3". Actual:  Exception ==='+er1);
   1.121 +  if (er1==="ex2") $ERROR('#5.3: Exception !=="ex2". Actual: catch previous catched exception');
   1.122 +  if (er1==="ex1") $ERROR('#5.4: Exception !=="ex1". Actual: catch previous embedded exception');
   1.123 +}
   1.124 +finally{
   1.125 +  c5=1;
   1.126 +}
   1.127 +if (c5!==1) $ERROR('#5.5: "finally" block must be evaluated');
   1.128 +
   1.129 +// CHECK#6
   1.130 +var c6=0;
   1.131 +try{
   1.132 +  try{
   1.133 +    throw "ex1";
   1.134 +  }
   1.135 +  catch(er1){
   1.136 +    if (er1!=="ex1") $ERROR('#6.1: Exception === "ex1". Actual:  Exception ==='+er1);
   1.137 +  }
   1.138 +  finally{
   1.139 +    c6=2;
   1.140 +  }
   1.141 +}
   1.142 +finally{
   1.143 +  c6*=2;
   1.144 +}
   1.145 +if (c6!==4) $ERROR('#6.2: "finally" block must be evaluated');
   1.146 +
   1.147 +// CHECK#7
   1.148 +var c7=0;
   1.149 +try{
   1.150 +  try{
   1.151 +    throw "ex1";
   1.152 +  }
   1.153 +  finally{
   1.154 +    try{
   1.155 +      c7=1;
   1.156 +      throw "ex2";
   1.157 +    }
   1.158 +    catch(er1){
   1.159 +      if (er1!=="ex2") $ERROR('#7.1: Exception === "ex2". Actual:  Exception ==='+er1);
   1.160 +      if (er1==="ex1") $ERROR('#7.2: Exception !=="ex2". Actual: catch previous catched exception');
   1.161 +      c7++;
   1.162 +    }
   1.163 +    finally{
   1.164 +      c7*=2;
   1.165 +    }
   1.166 +  }
   1.167 +}
   1.168 +catch(er1){
   1.169 +  if (er1!=="ex1") $ERROR('#7.3: Exception === "ex1". Actual:  Exception ==='+er1);
   1.170 +}
   1.171 +if (c7!==4) $ERROR('#7.4: "finally" block must be evaluated');
   1.172 +

mercurial