S12.14_A9_T2.js (1977B)
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 "try" with "catch" or "finally" statement within/without an "do while" 7 statement 8 es5id: 12.14_A9_T2 9 description: > 10 "try" statement within a loop, the statement contains "continue" 11 statement 12 ---*/ 13 14 // CHECK#1 15 var c1=0,fin=0; 16 do{ 17 try{ 18 c1+=1; 19 continue; 20 } 21 catch(er1){} 22 finally{ 23 fin=1; 24 } 25 fin=-1; 26 } 27 while(c1<2); 28 if(fin!==1){ 29 throw new Test262Error('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); 30 } 31 32 // CHECK#2 33 var c2=0,fin2=0; 34 do{ 35 try{ 36 throw "ex1"; 37 } 38 catch(er1){ 39 c2+=1; 40 continue; 41 } 42 finally{ 43 fin2=1; 44 } 45 fin2=-1; 46 } 47 while(c2<2); 48 if(fin2!==1){ 49 throw new Test262Error('#2: "finally" block must be evaluated at "try catch{continue} finally" construction'); 50 } 51 52 // CHECK#3 53 var c3=0,fin3=0; 54 do{ 55 try{ 56 throw "ex1"; 57 } 58 catch(er1){ 59 c3+=1; 60 } 61 finally{ 62 fin3=1; 63 continue; 64 } 65 fin3=0; 66 } 67 while(c3<2); 68 if(fin3!==1){ 69 throw new Test262Error('#3: "finally" block must be evaluated at "try catch finally{continue}" construction'); 70 } 71 72 // CHECK#4 73 var c4=0,fin4=0; 74 do{ 75 try{ 76 c4+=1; 77 continue; 78 } 79 finally{ 80 fin4=1; 81 } 82 fin4=-1; 83 } 84 while(c4<2); 85 if(fin4!==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 do{ 92 try{ 93 throw "ex1"; 94 } 95 catch(er1){ 96 c5+=1; 97 continue; 98 } 99 } 100 while(c5<2); 101 if(c5!==2){ 102 throw new Test262Error('#5: "try catch{continue}" must work correctly'); 103 } 104 105 // CHECK#6 106 var c6=0,fin6=0; 107 do{ 108 try{ 109 c6+=1; 110 throw "ex1" 111 } 112 finally{ 113 fin6=1; 114 continue; 115 } 116 fin6=-1; 117 } 118 while(c6<2); 119 if(fin6!==1){ 120 throw new Test262Error('#6.1: "finally" block must be evaluated'); 121 } 122 if(c6!==2){ 123 throw new Test262Error('#6.2: "try finally{continue}" must work correctly'); 124 } 125 126 reportCompare(0, 0);