js/src/tests/test262/ch12/12.14/S12.14_A12_T4.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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_T4.js
     8  * @description Try statement inside loop, where combinate using break and continue
     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 c1=0,fin=0;
    19 for (x in mycars){
    20   try{
    21     c1+=1;
    22     break;
    23   }
    24   catch(er1){}
    25   finally{
    26     fin=1;
    27     continue;
    28   }
    29   fin=-1;
    30   c1+=2;
    31 }
    32 if(fin!==1){
    33   $ERROR('#1.1: "finally" block must be evaluated');
    34 }
    35 if(c1!==3){
    36   $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly');
    37 }
    39 // CHECK#2
    40 var c2=0,fin2=0;
    41 for (x in mycars){
    42   try{
    43     throw "ex1";
    44   }
    45   catch(er1){
    46     c2+=1;
    47     break;
    48   }
    49   finally{
    50   	fin2=1;
    51   	continue;
    52   }
    53   c2+=2;
    54   fin2=-1;
    55 }
    56 if(fin2!==1){
    57   $ERROR('#2.1: "finally" block must be evaluated');
    58 }
    59 if(c2!==3){
    60   $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly');
    61 }

mercurial