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