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 15var a = 1; 16 17switch (a) { 18 case 1: 19 case 2: 20 break; 21 case 3: 22 assert (0); 23} 24 25switch (a) { 26 case 1: 27 break; 28 case 2: 29 case 3: 30 assert (0); 31} 32 33switch (a) { 34 default: 35 assert (0); 36 case 1: 37 break; 38 case 2: 39 case 3: 40 assert (0); 41} 42 43switch (a) { 44 default: 45 break; 46 case 2: 47 case 3: 48 assert (0); 49} 50 51switch (a) { 52 case 3: 53 assert (0); 54 default: 55 assert (0); 56 case 1: 57} 58 59executed_case = ''; 60switch (a) { 61 default: 62 executed_case = 'default'; 63 break; 64 case 2: 65 executed_case = 'case 2'; 66 break; 67} 68assert (executed_case === 'default'); 69 70var counter = 0; 71 72switch ("var") { 73 case "var": 74 counter++; 75 case "var1": 76 counter++; 77 case "var2": 78 counter++; 79 default: 80 counter++; 81} 82 83assert (counter === 4); 84 85var flow = ''; 86 87switch ("var") { 88 case "var": 89 flow += '1'; 90 case "var1": 91 flow += '2'; 92 case "var2": 93 flow += '3'; 94 switch (flow) { 95 case '123': 96 flow += 'a'; 97 break; 98 default: 99 flow += 'b'; 100 } 101 default: 102 flow += '4'; 103} 104 105assert (flow === '123a4'); 106 107switch (0) { case 0: for (;false;); case 1: } 108switch (0) { case 0: while (false); case 1: } 109