1/* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 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 16function main() : void { 17 let cond: boolean = true; 18 19 // Check conditional expression 20 let a: String = "foo"; 21 let b: String = "bar"; 22 let c: String = cond ? a : b; 23 assert(c == "foo"); 24 25 // Check assert statement 26 assert(cond); 27 28 // Check if statement 29 if (cond) { 30 assert(c == "foo"); 31 } 32 33 // Check for statement 34 let i = 0; 35 for (i; cond;) { 36 i += 3; 37 break; 38 } 39 assert(i == 3); 40 41 // Check while statement 42 let while_cond = true 43 while (while_cond) { 44 while_cond = !cond; 45 } 46 assert (while_cond == false); 47 48 // Check do-while statement 49 do { 50 assert (while_cond == false); 51 } while (while_cond); 52} 53