js/src/tests/test262/ch12/12.14/S12.14_A10_T3.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.

     1 // Copyright 2009 the Sputnik authors.  All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * Using "try" with "catch" or "finally" statement within/without a "while" statement
     6  *
     7  * @path ch12/12.14/S12.14_A10_T3.js
     8  * @description Try statement inside loop, where use break
     9  */
    11 // CHECK#1
    12 var c1=0,fin=0;
    13 while(c1<2){
    14   try{
    15     c1+=1;
    16     break;
    17   }
    18   catch(er1){}
    19   finally{
    20     fin=1;
    21   }
    22   fin=-1;
    23   c1+=2;
    24 }
    25 if(fin!==1){
    26   $ERROR('#1.1: "finally" block must be evaluated');
    27 }
    28 if(c1!==1){
    29   $ERROR('#1.2: "try{break}catch finally" must work correctly');
    30 }
    32 // CHECK#2
    33 var c2=0,fin2=0;
    34 while(c2<2){
    35   try{
    36     throw "ex1";
    37   }
    38   catch(er1){
    39     c2+=1;
    40     break;
    41   }
    42   finally{
    43     fin2=1;
    44   }
    45   c2+=2;
    46   fin2=-1;
    47 }
    48 if(fin2!==1){
    49   $ERROR('#2.1: "finally" block must be evaluated');
    50 }
    51 if(c2!==1){
    52   $ERROR('#2.2: "try catch{break} finally" must work correctly');
    53 }
    55 // CHECK#3
    56 var c3=0,fin3=0;
    57 while(c3<2){
    58   try{
    59     throw "ex1";
    60   }
    61   catch(er1){
    62     c3+=1;
    63   }
    64   finally{
    65     fin3=1;
    66     break;
    67   }
    68   c3+=2;
    69   fin3=0;
    70 }
    71 if(fin3!==1){
    72   $ERROR('#3.1: "finally" block must be evaluated');
    73 }
    74 if(c3!==1){
    75   $ERROR('#3.2: "try catch finally{break}" must work correctly');
    76 }
    78 // CHECK#4
    79 var c4=0,fin4=0;
    80 while(c4<2){
    81   try{
    82     c4+=1;
    83     break;
    84   }
    85   finally{
    86     fin4=1;
    87   }
    88   fin4=-1;
    89   c4+=2;
    90 }
    91 if(fin4!==1){
    92   $ERROR('#4.1: "finally" block must be evaluated');
    93 }
    94 if(c4!==1){
    95   $ERROR('#4.2: "try{break} finally" must work correctly');
    96 }
    98 // CHECK#5
    99 var c5=0;
   100 while(c5<2){
   101   try{
   102     throw "ex1";
   103   }
   104   catch(er1){
   105     break;
   106   }
   107 }
   108 if(c5!==0){
   109   $ERROR('#5: "try catch{break}" must work correctly');
   110 }
   112 // CHECK#6
   113 var c6=0;
   114 while(c6<2){
   115   try{
   116     c6+=1;
   117     break;
   118   }
   119   catch(er1){}
   120   c6+=2;
   121 }
   122 if(c6!==1){
   123   $ERROR('#6: "try{break} catch" must work correctly');
   124 }
   126 // CHECK#7
   127 var c7=0,fin7=0;
   128 try{
   129   while(c7<2){
   130     try{
   131       c7+=1;
   132       throw "ex1";
   133     }
   134     finally{
   135       fin7=1;
   136       break;
   137     }
   138     fin7=-1;
   139     c7+=2;
   140   }
   141 }
   142 catch(ex1){
   143   c7=10;
   144 }
   145 if(fin7!==1){
   146   $ERROR('#7.1: "finally" block must be evaluated');
   147 }
   148 if(c7!==1){
   149   $ERROR('#7.2: "try finally{break}" must work correctly');
   150 }

mercurial