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.

michael@0 1 // Copyright 2009 the Sputnik authors. All rights reserved.
michael@0 2 // This code is governed by the BSD license found in the LICENSE file.
michael@0 3
michael@0 4 /**
michael@0 5 * Using "try" with "catch" or "finally" statement within/without a "for-in" statement
michael@0 6 *
michael@0 7 * @path ch12/12.14/S12.14_A12_T4.js
michael@0 8 * @description Try statement inside loop, where combinate using break and continue
michael@0 9 */
michael@0 10
michael@0 11 var x;
michael@0 12 var mycars = new Array();
michael@0 13 mycars[0] = "Saab";
michael@0 14 mycars[1] = "Volvo";
michael@0 15 mycars[2] = "BMW";
michael@0 16
michael@0 17 // CHECK#1
michael@0 18 var c1=0,fin=0;
michael@0 19 for (x in mycars){
michael@0 20 try{
michael@0 21 c1+=1;
michael@0 22 break;
michael@0 23 }
michael@0 24 catch(er1){}
michael@0 25 finally{
michael@0 26 fin=1;
michael@0 27 continue;
michael@0 28 }
michael@0 29 fin=-1;
michael@0 30 c1+=2;
michael@0 31 }
michael@0 32 if(fin!==1){
michael@0 33 $ERROR('#1.1: "finally" block must be evaluated');
michael@0 34 }
michael@0 35 if(c1!==3){
michael@0 36 $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly');
michael@0 37 }
michael@0 38
michael@0 39 // CHECK#2
michael@0 40 var c2=0,fin2=0;
michael@0 41 for (x in mycars){
michael@0 42 try{
michael@0 43 throw "ex1";
michael@0 44 }
michael@0 45 catch(er1){
michael@0 46 c2+=1;
michael@0 47 break;
michael@0 48 }
michael@0 49 finally{
michael@0 50 fin2=1;
michael@0 51 continue;
michael@0 52 }
michael@0 53 c2+=2;
michael@0 54 fin2=-1;
michael@0 55 }
michael@0 56 if(fin2!==1){
michael@0 57 $ERROR('#2.1: "finally" block must be evaluated');
michael@0 58 }
michael@0 59 if(c2!==3){
michael@0 60 $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly');
michael@0 61 }
michael@0 62

mercurial