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

mercurial