js/src/tests/test262/ch12/12.14/S12.14_A11_T2.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 "for" statement
     6  *
     7  * @path ch12/12.14/S12.14_A11_T2.js
     8  * @description Try statement inside loop, where use continue loop
     9  */
    11 // CHECK#1
    12 var fin=0;
    13 for(var i=0;i<5;i++){
    14   try{
    15     i+=1;
    16     continue;
    17   }
    18   catch(er1){}
    19   finally{
    20     fin=1;
    21   }
    22   fin=-1;
    23 }
    24 if(fin!==1){
    25   $ERROR('#1: "finally" block must be evaluated at "try{continue} catch finally" construction');
    26 }
    28 // CHECK#2
    29 var c2=0,fin2=0;
    30 for(var i=0;i<5;i++){
    31   try{
    32     throw "ex1";
    33   }
    34   catch(er1){
    35     c2+=1;
    36     continue;
    37   }
    38   finally{
    39     fin2=1;
    40   }
    41   fin2=-1;
    42 }
    43 if(fin2!==1){
    44   $ERROR('#2.1: "finally" block must be evaluated');
    45 }
    46 if(c2!==5){
    47   $ERROR('#2.1: "try catch{continue} finally" must work correctly');
    48 }
    50 // CHECK#3
    51 var c3=0,fin3=0;
    52 for(var i=0;i<5;i++){
    53   try{
    54     throw "ex1";
    55   }
    56   catch(er1){
    57     c3+=1;
    58   }
    59   finally{
    60     fin3=1;
    61     continue;
    62   }
    63   fin3=0;
    64 }
    65 if(fin3!==1){
    66   $ERROR('#3.1: "finally" block must be evaluated');
    67 }
    68 if(c3!==5){
    69   $ERROR('#3.2: "try catch finally{continue}" must work correctly');
    70 }
    72 // CHECK#4
    73 var fin=0;
    74 for(var i=0;i<5;i++){
    75   try{
    76     i+=1;
    77     continue;
    78   }
    79   finally{
    80     fin=1;
    81   }
    82   fin=-1;
    83 };
    84 if(fin!==1){
    85   $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction');
    86 }
    88 // CHECK#5
    89 var c5=0;
    90 for(var c5=0;c5<10;){
    91   try{
    92     throw "ex1";
    93   }
    94   catch(er1){
    95     c5+=1;
    96     continue;
    97   }
    98   c5+=12;
    99 };
   100 if(c5!==10){
   101   $ERROR('#5: "try catch{continue} must work correctly');
   102 }
   104 // CHECK#6
   105 var c6=0,fin6=0;
   106 for(var c6=0;c6<10;){
   107   try{
   108     c6+=1;
   109     throw "ex1"
   110   }
   111   finally{
   112     fin6=1;
   113     continue;
   114   }
   115   fin6=-1;
   116 };
   117 if(fin6!==1){
   118   $ERROR('#6.1: "finally" block must be evaluated');
   119 }
   120 if(c6!==10){
   121   $ERROR('#6.2: "try finally{continue}" must work correctly');
   122 }

mercurial