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 16 17assert (typeof f === "undefined"); 18 19function g() { return 6; } 20 21switch (g()) { 22case f(): 23 24 let g = 9; 25 26 assert (g === 9); 27 28 function f() { return 6; } 29 break; 30 31default: 32 assert (false); 33} 34 35assert (f() === 6); 36 37switch (g()) { 38case f() - 2: 39 40 let g = 9; 41 42 assert ((function() { return g + f(); })() === 17); 43 44 function f() { return 8; } 45 break; 46 47default: 48 assert (false); 49} 50 51assert (f() === 8); 52 53switch (g()) { 54case g() + 5: 55 { 56 let g = 4; 57 assert (g == 4); 58 } 59 break; 60 61default: 62 /* If the declaration is not "executed", it has no effect */ 63 function g() { return 1; } 64 assert (false); 65} 66 67assert (g() === 6); 68 69switch (g()) { 70case g() * 2: 71 { 72 let g = 4; 73 assert (g == 4); 74 eval(); 75 } 76 77 function g() { return 3; } 78 break; 79 80default: 81 assert (false); 82} 83 84assert (g() === 3); 85