js/src/tests/test262/ch12/12.14/S12.14_A10_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_A10_T3.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,151 @@
     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 + * Using "try" with "catch" or "finally" statement within/without a "while" statement
     1.9 + *
    1.10 + * @path ch12/12.14/S12.14_A10_T3.js
    1.11 + * @description Try statement inside loop, where use break
    1.12 + */
    1.13 +
    1.14 +// CHECK#1
    1.15 +var c1=0,fin=0;
    1.16 +while(c1<2){
    1.17 +  try{
    1.18 +    c1+=1;
    1.19 +    break;
    1.20 +  }
    1.21 +  catch(er1){}
    1.22 +  finally{
    1.23 +    fin=1;
    1.24 +  }
    1.25 +  fin=-1;
    1.26 +  c1+=2;
    1.27 +}
    1.28 +if(fin!==1){
    1.29 +  $ERROR('#1.1: "finally" block must be evaluated');
    1.30 +}
    1.31 +if(c1!==1){
    1.32 +  $ERROR('#1.2: "try{break}catch finally" must work correctly');
    1.33 +}
    1.34 +
    1.35 +// CHECK#2
    1.36 +var c2=0,fin2=0;
    1.37 +while(c2<2){
    1.38 +  try{
    1.39 +    throw "ex1";
    1.40 +  }
    1.41 +  catch(er1){
    1.42 +    c2+=1;
    1.43 +    break;
    1.44 +  }
    1.45 +  finally{
    1.46 +    fin2=1;
    1.47 +  }
    1.48 +  c2+=2;
    1.49 +  fin2=-1;
    1.50 +}
    1.51 +if(fin2!==1){
    1.52 +  $ERROR('#2.1: "finally" block must be evaluated');
    1.53 +}
    1.54 +if(c2!==1){
    1.55 +  $ERROR('#2.2: "try catch{break} finally" must work correctly');
    1.56 +}
    1.57 +
    1.58 +// CHECK#3
    1.59 +var c3=0,fin3=0;
    1.60 +while(c3<2){
    1.61 +  try{
    1.62 +    throw "ex1";
    1.63 +  }
    1.64 +  catch(er1){
    1.65 +    c3+=1;
    1.66 +  }
    1.67 +  finally{
    1.68 +    fin3=1;
    1.69 +    break;
    1.70 +  }
    1.71 +  c3+=2;
    1.72 +  fin3=0;
    1.73 +}
    1.74 +if(fin3!==1){
    1.75 +  $ERROR('#3.1: "finally" block must be evaluated');
    1.76 +}
    1.77 +if(c3!==1){
    1.78 +  $ERROR('#3.2: "try catch finally{break}" must work correctly');
    1.79 +}
    1.80 +
    1.81 +// CHECK#4
    1.82 +var c4=0,fin4=0;
    1.83 +while(c4<2){
    1.84 +  try{
    1.85 +    c4+=1;
    1.86 +    break;
    1.87 +  }
    1.88 +  finally{
    1.89 +    fin4=1;
    1.90 +  }
    1.91 +  fin4=-1;
    1.92 +  c4+=2;
    1.93 +}
    1.94 +if(fin4!==1){
    1.95 +  $ERROR('#4.1: "finally" block must be evaluated');
    1.96 +}
    1.97 +if(c4!==1){
    1.98 +  $ERROR('#4.2: "try{break} finally" must work correctly');
    1.99 +}
   1.100 +
   1.101 +// CHECK#5
   1.102 +var c5=0;
   1.103 +while(c5<2){
   1.104 +  try{
   1.105 +    throw "ex1";
   1.106 +  }
   1.107 +  catch(er1){
   1.108 +    break;
   1.109 +  }
   1.110 +}
   1.111 +if(c5!==0){
   1.112 +  $ERROR('#5: "try catch{break}" must work correctly');
   1.113 +}
   1.114 +
   1.115 +// CHECK#6
   1.116 +var c6=0;
   1.117 +while(c6<2){
   1.118 +  try{
   1.119 +    c6+=1;
   1.120 +    break;
   1.121 +  }
   1.122 +  catch(er1){}
   1.123 +  c6+=2;
   1.124 +}
   1.125 +if(c6!==1){
   1.126 +  $ERROR('#6: "try{break} catch" must work correctly');
   1.127 +}
   1.128 +
   1.129 +// CHECK#7
   1.130 +var c7=0,fin7=0;
   1.131 +try{
   1.132 +  while(c7<2){
   1.133 +    try{
   1.134 +      c7+=1;
   1.135 +      throw "ex1";
   1.136 +    }
   1.137 +    finally{
   1.138 +      fin7=1;
   1.139 +      break;
   1.140 +    }
   1.141 +    fin7=-1;
   1.142 +    c7+=2;
   1.143 +  }
   1.144 +}
   1.145 +catch(ex1){
   1.146 +  c7=10;
   1.147 +}
   1.148 +if(fin7!==1){
   1.149 +  $ERROR('#7.1: "finally" block must be evaluated');
   1.150 +}
   1.151 +if(c7!==1){
   1.152 +  $ERROR('#7.2: "try finally{break}" must work correctly');
   1.153 +}
   1.154 +

mercurial