1/* 2 * Copyright (c) 2022-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 16let count: int = 0; 17 18function foo(a: int): char { 19 count++; 20 let x: char = c'd'; 21 return x; 22} 23 24function concatenate_float(prefix: String, number: float, suffix: String) : String { 25 return (prefix + number + suffix); 26} 27 28function concatenate_compile_time() : void { 29 let x: String = 5 + "10"; 30 assert x == "510"; 31 32 let y = 5 + "10"; 33 assert y == "510"; 34} 35 36function main(): void { 37 count = 0; 38 let a: String = "abc"; 39 a += foo(123); 40 41 assert a == "abcd"; 42 assert count == 1; 43 44 let const_str: String = 'str' + c'a'; 45 assert const_str == "stra"; 46 47 assert concatenate_float('x', 1.0 as float, "y") == "x1y"; 48 49 concatenate_compile_time(); 50} 51