1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15/* with */ 16 17for (var i = 0; i < 10; i++) 18{ 19 with ({}) 20 { 21 break; 22 23 assert (false); 24 } 25} 26assert (i === 0); 27 28for (var i = 0; i < 10; i++) 29{ 30 with ({}) 31 { 32 continue; 33 34 assert (false); 35 } 36} 37assert (i === 10); 38 39/* try */ 40for (var i = 0; i < 10; i++) 41{ 42 try 43 { 44 break; 45 46 assert (false); 47 } 48 catch (e) 49 { 50 } 51} 52assert (i === 0); 53 54for (var i = 0; i < 10; i++) 55{ 56 try 57 { 58 continue; 59 60 assert (false); 61 } 62 catch (e) 63 { 64 } 65} 66assert (i === 10); 67 68/* catch */ 69for (var i = 0; i < 10; i++) 70{ 71 try 72 { 73 throw new TypeError (); 74 assert (false); 75 } 76 catch (e) 77 { 78 break; 79 assert (false); 80 } 81} 82assert (i === 0); 83 84for (var i = 0; i < 10; i++) 85{ 86 try 87 { 88 throw new TypeError (); 89 assert (false); 90 } 91 catch (e) 92 { 93 continue; 94 assert (false); 95 } 96} 97assert (i === 10); 98 99 100/* finally */ 101for (var i = 0; i < 10; i++) 102{ 103 try 104 { 105 throw new TypeError (); 106 assert (false); 107 } 108 catch (e) 109 { 110 } 111 finally 112 { 113 break; 114 assert (false); 115 } 116} 117assert (i === 0); 118 119for (var i = 0; i < 10; i++) 120{ 121 try 122 { 123 throw new TypeError (); 124 assert (false); 125 } 126 catch (e) 127 { 128 } 129 finally 130 { 131 continue; 132 assert (false); 133 } 134} 135assert (i === 10); 136 137 138/* with - switch */ 139 140str = ''; 141for (var i = 0; i < 10; i++) 142{ 143 with ({}) 144 { 145 switch (i) 146 { 147 case 0: 148 str += 'A'; 149 break; 150 default: 151 str += 'B'; 152 continue; 153 } 154 155 str += 'C'; 156 } 157} 158assert (str === 'ACBBBBBBBBB'); 159