js/src/tests/test262/ch12/12.14/S12.14_A12_T3.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial