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.

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

mercurial