js/src/tests/test262/ch12/12.14/S12.14_A9_T3.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 * "try" with "catch" or "finally" statement within/without an "do while" statement
michael@0 6 *
michael@0 7 * @path ch12/12.14/S12.14_A9_T3.js
michael@0 8 * @description "try" statement within a loop, the statement contains "break" statement
michael@0 9 */
michael@0 10
michael@0 11 // CHECK#1
michael@0 12 var c1=0,fin=0;
michael@0 13 do{
michael@0 14 try{
michael@0 15 c1+=1;
michael@0 16 break;
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 c1+=2;
michael@0 24 }
michael@0 25 while(c1<2);
michael@0 26 if(fin!==1){
michael@0 27 $ERROR('#1.1: "finally" block must be evaluated');
michael@0 28 }
michael@0 29 if(c1!==1){
michael@0 30 $ERROR('#1.2: "try{break}catch finally" must work correctly');
michael@0 31 }
michael@0 32
michael@0 33 // CHECK#2
michael@0 34 var c2=0,fin2=0;
michael@0 35 do{
michael@0 36 try{
michael@0 37 throw "ex1";
michael@0 38 }
michael@0 39 catch(er1){
michael@0 40 c2+=1;
michael@0 41 break;
michael@0 42 }
michael@0 43 finally{
michael@0 44 fin2=1;
michael@0 45 }
michael@0 46 c2+=2;
michael@0 47 fin2=-1;
michael@0 48 }
michael@0 49 while(c2<2);
michael@0 50 if(fin2!==1){
michael@0 51 $ERROR('#2.1: "finally" block must be evaluated');
michael@0 52 }
michael@0 53 if(c2!==1){
michael@0 54 $ERROR('#2.2: "try catch{break} finally" must work correctly');
michael@0 55 }
michael@0 56
michael@0 57 // CHECK#3
michael@0 58 var c3=0,fin3=0;
michael@0 59 do{
michael@0 60 try{
michael@0 61 throw "ex1";
michael@0 62 }
michael@0 63 catch(er1){
michael@0 64 c3+=1;
michael@0 65 }
michael@0 66 finally{
michael@0 67 fin3=1;
michael@0 68 break;
michael@0 69 }
michael@0 70 c3+=2;
michael@0 71 fin3=0;
michael@0 72 }
michael@0 73 while(c3<2);
michael@0 74 if(fin3!==1){
michael@0 75 $ERROR('#3.1: "finally" block must be evaluated');
michael@0 76 }
michael@0 77 if(c3!==1){
michael@0 78 $ERROR('#3.2: "try catch finally{break}" must work correctly');
michael@0 79 }
michael@0 80
michael@0 81 // CHECK#4
michael@0 82 var c4=0,fin4=0;
michael@0 83 do{
michael@0 84 try{
michael@0 85 c4+=1;
michael@0 86 break;
michael@0 87 }
michael@0 88 finally{
michael@0 89 fin4=1;
michael@0 90 }
michael@0 91 fin4=-1;
michael@0 92 c4+=2;
michael@0 93 }
michael@0 94 while(c4<2);
michael@0 95 if(fin4!==1){
michael@0 96 $ERROR('#4.1: "finally" block must be evaluated');
michael@0 97 }
michael@0 98 if(c4!==1){
michael@0 99 $ERROR('#4.2: "try{break} finally" must work correctly');
michael@0 100 }
michael@0 101
michael@0 102 // CHECK#5
michael@0 103 var c5=0;
michael@0 104 do{
michael@0 105 try{
michael@0 106 throw "ex1";
michael@0 107 }
michael@0 108 catch(er1){
michael@0 109 break;
michael@0 110 }
michael@0 111 }
michael@0 112 while(c5<2);
michael@0 113 if(c5!==0){
michael@0 114 $ERROR('#5: "try catch{break}" must work correctly');
michael@0 115 }
michael@0 116
michael@0 117 // CHECK#6
michael@0 118 var c6=0;
michael@0 119 do{
michael@0 120 try{
michael@0 121 c6+=1;
michael@0 122 break;
michael@0 123 }
michael@0 124 catch(er1){}
michael@0 125 c6+=2;
michael@0 126 }
michael@0 127 while(c6<2);
michael@0 128 if(c6!==1){
michael@0 129 $ERROR('#6: "try{break} catch" must work correctly');
michael@0 130 }
michael@0 131
michael@0 132 // CHECK#7
michael@0 133 var c7=0,fin7=0;
michael@0 134 try{
michael@0 135 do{
michael@0 136 try{
michael@0 137 c7+=1;
michael@0 138 throw "ex1";
michael@0 139 }
michael@0 140 finally{
michael@0 141 fin7=1;
michael@0 142 break;
michael@0 143 }
michael@0 144 fin7=-1;
michael@0 145 c7+=2;
michael@0 146 }
michael@0 147 while(c7<2);
michael@0 148 }
michael@0 149 catch(ex1){
michael@0 150 c7=10;
michael@0 151 }
michael@0 152 if(fin7!==1){
michael@0 153 $ERROR('#7.1: "finally" block must be evaluated');
michael@0 154 }
michael@0 155 if(c7!==1){
michael@0 156 $ERROR('#7.2: try finally{break} error');
michael@0 157 }
michael@0 158

mercurial