/* * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ enum Color { Red, Green, Blue = 0} assert(Color.Red ? false : true); assert(Color.Green ? true : false); assert(!Color.Green ? false : true); assert(Color.Blue ? false : true); while (Color.Red) { assert(false); } while (Color.Green) { break; } while (Color.Blue) { assert(false); } let i = 0; do {i++; if (i==2) break; } while (Color.Red); assert(i==1); i = 0; do {i++; if (i==2) break; } while (Color.Green); assert(i==2); i = 0; do {i++; if (i==2) break; } while (Color.Blue); assert(i==1); let stop = false; for (let i = 0; Color.Red; ++i) { stop = true; break; } assert (stop == false); stop = false; for (let i = 0; Color.Green; ++i) { stop = true; break; } assert (stop == true); stop = false; for (let i = 0; Color.Blue; ++i) { stop = true; break; } assert (stop == false); if (Color.Red) assert(false); if (Color.Green) assert(true); if (Color.Blue) assert(false);