1/* 2 * Copyright (c) 2022-2025 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 str: String = "hello\nworld\n"; 18 assertEQ(str.charAt(2), c'l') 19 assertEQ(str.length, 12) 20 assertEQ(str.charAt(Double.toInt(str.length) - 1), c'\n') 21 22 let a: String = "abc"; 23 let b: String = "ace"; 24 let c: String = "abc"; 25 assertTrue(!a.equals(b)) 26 assertTrue(a.equals(c)) 27 assertTrue(!b.equals(c)) 28 29 let n2: int = 41; 30 let n3: long = 42; 31 let n4: float = 43.43f; 32 let n5: double = 44.44; 33 let n6: double = random(); 34 let n7: double = random() + 42; 35 assertTrue(n6 >= 0.0 && n6 <= 1.0) 36 assertTrue(n7 >= 42.0 && n7 <= 43.0) 37 38 let s1: String = "This "; 39 let s2: String = "is "; 40 let s3: String = "another "; 41 let s4: String = "string"; 42 let s5: String = "This is another string"; 43 assertTrue((s1 + s2 + s3 + s4).equals(s5)) 44} 45