1425bb815Sopenharmony_ci// Copyright JS Foundation and other contributors, http://js.foundation 2425bb815Sopenharmony_ci// 3425bb815Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci// you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci// You may obtain a copy of the License at 6425bb815Sopenharmony_ci// 7425bb815Sopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci// 9425bb815Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci// See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci// limitations under the License. 14425bb815Sopenharmony_ci 15425bb815Sopenharmony_civar a = 1; 16425bb815Sopenharmony_ci 17425bb815Sopenharmony_ciswitch (a) { 18425bb815Sopenharmony_ci case 1: 19425bb815Sopenharmony_ci case 2: 20425bb815Sopenharmony_ci break; 21425bb815Sopenharmony_ci case 3: 22425bb815Sopenharmony_ci assert (0); 23425bb815Sopenharmony_ci} 24425bb815Sopenharmony_ci 25425bb815Sopenharmony_ciswitch (a) { 26425bb815Sopenharmony_ci case 1: 27425bb815Sopenharmony_ci break; 28425bb815Sopenharmony_ci case 2: 29425bb815Sopenharmony_ci case 3: 30425bb815Sopenharmony_ci assert (0); 31425bb815Sopenharmony_ci} 32425bb815Sopenharmony_ci 33425bb815Sopenharmony_ciswitch (a) { 34425bb815Sopenharmony_ci default: 35425bb815Sopenharmony_ci assert (0); 36425bb815Sopenharmony_ci case 1: 37425bb815Sopenharmony_ci break; 38425bb815Sopenharmony_ci case 2: 39425bb815Sopenharmony_ci case 3: 40425bb815Sopenharmony_ci assert (0); 41425bb815Sopenharmony_ci} 42425bb815Sopenharmony_ci 43425bb815Sopenharmony_ciswitch (a) { 44425bb815Sopenharmony_ci default: 45425bb815Sopenharmony_ci break; 46425bb815Sopenharmony_ci case 2: 47425bb815Sopenharmony_ci case 3: 48425bb815Sopenharmony_ci assert (0); 49425bb815Sopenharmony_ci} 50425bb815Sopenharmony_ci 51425bb815Sopenharmony_ciswitch (a) { 52425bb815Sopenharmony_ci case 3: 53425bb815Sopenharmony_ci assert (0); 54425bb815Sopenharmony_ci default: 55425bb815Sopenharmony_ci assert (0); 56425bb815Sopenharmony_ci case 1: 57425bb815Sopenharmony_ci} 58425bb815Sopenharmony_ci 59425bb815Sopenharmony_ciexecuted_case = ''; 60425bb815Sopenharmony_ciswitch (a) { 61425bb815Sopenharmony_ci default: 62425bb815Sopenharmony_ci executed_case = 'default'; 63425bb815Sopenharmony_ci break; 64425bb815Sopenharmony_ci case 2: 65425bb815Sopenharmony_ci executed_case = 'case 2'; 66425bb815Sopenharmony_ci break; 67425bb815Sopenharmony_ci} 68425bb815Sopenharmony_ciassert (executed_case === 'default'); 69425bb815Sopenharmony_ci 70425bb815Sopenharmony_civar counter = 0; 71425bb815Sopenharmony_ci 72425bb815Sopenharmony_ciswitch ("var") { 73425bb815Sopenharmony_ci case "var": 74425bb815Sopenharmony_ci counter++; 75425bb815Sopenharmony_ci case "var1": 76425bb815Sopenharmony_ci counter++; 77425bb815Sopenharmony_ci case "var2": 78425bb815Sopenharmony_ci counter++; 79425bb815Sopenharmony_ci default: 80425bb815Sopenharmony_ci counter++; 81425bb815Sopenharmony_ci} 82425bb815Sopenharmony_ci 83425bb815Sopenharmony_ciassert (counter === 4); 84425bb815Sopenharmony_ci 85425bb815Sopenharmony_civar flow = ''; 86425bb815Sopenharmony_ci 87425bb815Sopenharmony_ciswitch ("var") { 88425bb815Sopenharmony_ci case "var": 89425bb815Sopenharmony_ci flow += '1'; 90425bb815Sopenharmony_ci case "var1": 91425bb815Sopenharmony_ci flow += '2'; 92425bb815Sopenharmony_ci case "var2": 93425bb815Sopenharmony_ci flow += '3'; 94425bb815Sopenharmony_ci switch (flow) { 95425bb815Sopenharmony_ci case '123': 96425bb815Sopenharmony_ci flow += 'a'; 97425bb815Sopenharmony_ci break; 98425bb815Sopenharmony_ci default: 99425bb815Sopenharmony_ci flow += 'b'; 100425bb815Sopenharmony_ci } 101425bb815Sopenharmony_ci default: 102425bb815Sopenharmony_ci flow += '4'; 103425bb815Sopenharmony_ci} 104425bb815Sopenharmony_ci 105425bb815Sopenharmony_ciassert (flow === '123a4'); 106425bb815Sopenharmony_ci 107425bb815Sopenharmony_ciswitch (0) { case 0: for (;false;); case 1: } 108425bb815Sopenharmony_ciswitch (0) { case 0: while (false); case 1: } 109