S12.14_A11_T2.js (2081B)
1 // Copyright 2009 the Sputnik authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 info: | 6 Using "try" with "catch" or "finally" statement within/without a "for" 7 statement 8 es5id: 12.14_A11_T2 9 description: Try statement inside loop, where use continue loop 10 ---*/ 11 12 // CHECK#1 13 var fin=0; 14 for(var i=0;i<5;i++){ 15 try{ 16 i+=1; 17 continue; 18 } 19 catch(er1){} 20 finally{ 21 fin=1; 22 } 23 fin=-1; 24 } 25 if(fin!==1){ 26 throw new Test262Error('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); 27 } 28 29 // CHECK#2 30 var c2=0,fin2=0; 31 for(var i=0;i<5;i++){ 32 try{ 33 throw "ex1"; 34 } 35 catch(er1){ 36 c2+=1; 37 continue; 38 } 39 finally{ 40 fin2=1; 41 } 42 fin2=-1; 43 } 44 if(fin2!==1){ 45 throw new Test262Error('#2.1: "finally" block must be evaluated'); 46 } 47 if(c2!==5){ 48 throw new Test262Error('#2.1: "try catch{continue} finally" must work correctly'); 49 } 50 51 // CHECK#3 52 var c3=0,fin3=0; 53 for(var i=0;i<5;i++){ 54 try{ 55 throw "ex1"; 56 } 57 catch(er1){ 58 c3+=1; 59 } 60 finally{ 61 fin3=1; 62 continue; 63 } 64 fin3=0; 65 } 66 if(fin3!==1){ 67 throw new Test262Error('#3.1: "finally" block must be evaluated'); 68 } 69 if(c3!==5){ 70 throw new Test262Error('#3.2: "try catch finally{continue}" must work correctly'); 71 } 72 73 // CHECK#4 74 var fin=0; 75 for(var i=0;i<5;i++){ 76 try{ 77 i+=1; 78 continue; 79 } 80 finally{ 81 fin=1; 82 } 83 fin=-1; 84 }; 85 if(fin!==1){ 86 throw new Test262Error('#4: "finally" block must be evaluated at "try{continue} finally" construction'); 87 } 88 89 // CHECK#5 90 var c5=0; 91 for(var c5=0;c5<10;){ 92 try{ 93 throw "ex1"; 94 } 95 catch(er1){ 96 c5+=1; 97 continue; 98 } 99 c5+=12; 100 }; 101 if(c5!==10){ 102 throw new Test262Error('#5: "try catch{continue} must work correctly'); 103 } 104 105 // CHECK#6 106 var c6=0,fin6=0; 107 for(var c6=0;c6<10;){ 108 try{ 109 c6+=1; 110 throw "ex1" 111 } 112 finally{ 113 fin6=1; 114 continue; 115 } 116 fin6=-1; 117 }; 118 if(fin6!==1){ 119 throw new Test262Error('#6.1: "finally" block must be evaluated'); 120 } 121 if(c6!==10){ 122 throw new Test262Error('#6.2: "try finally{continue}" must work correctly'); 123 } 124 125 reportCompare(0, 0);