| 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 "while" |
| 7 |
statement |
| 8 |
es5id: 12.14_A10_T2 |
| 9 |
description: Try statement inside loop, where use continue loop |
| 10 |
---*/ |
| 11 |
|
| 12 |
// CHECK#1 |
| 13 |
var c1=0,fin=0; |
| 14 |
while(c1<2){ |
| 15 |
try{ |
| 16 |
c1+=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 |
while(c2<2){ |
| 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: "finally" block must be evaluated at "try catch{continue} finally" construction'); |
| 46 |
} |
| 47 |
|
| 48 |
// CHECK#3 |
| 49 |
var c3=0,fin3=0; |
| 50 |
while(c3<2){ |
| 51 |
try{ |
| 52 |
throw "ex1"; |
| 53 |
} |
| 54 |
catch(er1){ |
| 55 |
c3+=1; |
| 56 |
} |
| 57 |
finally{ |
| 58 |
fin3=1; |
| 59 |
continue; |
| 60 |
} |
| 61 |
fin3=0; |
| 62 |
} |
| 63 |
if(fin3!==1){ |
| 64 |
throw new Test262Error('#3: "finally" block must be evaluated at "try catch finally{continue}" construction'); |
| 65 |
} |
| 66 |
|
| 67 |
// CHECK#4 |
| 68 |
var c4=0,fin4=0; |
| 69 |
while(c4<2){ |
| 70 |
try{ |
| 71 |
c4+=1; |
| 72 |
continue; |
| 73 |
} |
| 74 |
finally{ |
| 75 |
fin4=1; |
| 76 |
} |
| 77 |
fin4=-1; |
| 78 |
}; |
| 79 |
if(fin4!==1){ |
| 80 |
throw new Test262Error('#4: "finally" block must be evaluated at "try{continue} finally" construction'); |
| 81 |
} |
| 82 |
|
| 83 |
// CHECK#5 |
| 84 |
var c5=0; |
| 85 |
while(c5<2){ |
| 86 |
try{ |
| 87 |
throw "ex1"; |
| 88 |
} |
| 89 |
catch(er1){ |
| 90 |
c5+=1; |
| 91 |
continue; |
| 92 |
} |
| 93 |
} |
| 94 |
if(c5!==2){ |
| 95 |
throw new Test262Error('#5: "try catch{continue}" must work correctly'); |
| 96 |
} |
| 97 |
|
| 98 |
// CHECK#6 |
| 99 |
var c6=0,fin6=0; |
| 100 |
while(c6<2){ |
| 101 |
try{ |
| 102 |
c6+=1; |
| 103 |
throw "ex1" |
| 104 |
} |
| 105 |
finally{ |
| 106 |
fin6=1; |
| 107 |
continue; |
| 108 |
} |
| 109 |
fin6=-1; |
| 110 |
} |
| 111 |
if(fin6!==1){ |
| 112 |
throw new Test262Error('#6.1: "finally" block must be evaluated'); |
| 113 |
} |
| 114 |
if(c6!==2){ |
| 115 |
throw new Test262Error('#6.2: "try finally{continue}" must work correctly'); |
| 116 |
} |
| 117 |
|
| 118 |
reportCompare(0, 0); |