1/* 2 * Copyright (c) 2021-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 a: byte = 2; 18 let b: short = 20000; 19 let c: int = 2000000; 20 let d: long = 200000000000; 21 let e: float = 2.2; 22 let f: double = 2.2222222222; 23 let g: double[] = [a, b, c, d, e, f]; 24 assert g[0] == 2; 25 assert g[1] == 20000; 26 assert g[2] == 2000000; 27 assert g[3] == 200000000000; 28 assert g[4] == (2.2 as float); 29 assert g[5] == 2.2222222222; 30 31 const h: byte = 2; 32 const i: short = 2; 33 const j: int = 2; 34 const k: long = 2; 35 const l: float = 2.0; 36 const m: double = 2.0; 37 const n: byte[] = [h, i, j, k, l, m]; 38 assert n[0] == 2; 39 assert n[1] == 2; 40 assert n[2] == 2; 41 assert n[3] == 2; 42 assert n[4] == 2; 43 assert n[5] == 2; 44 45 let o: Object[] = [1, 1.1, "testStr", new Int(2), d, k]; 46 assert (o[0] as Int) == 1; 47 assert (o[1] as Double) == 1.1; 48 assert (o[2] as String).equals("testStr"); 49 assert (o[3] as Int) == 2; 50 assert (o[4] as Long) == 200000000000; 51 assert (o[5] as Long) == 2; 52 53 let p: long[] = [new Int(3), new Short(2 as short), new Long(4)]; 54 assert p[0] == 3; 55 assert p[1] == 2; 56 assert p[2] == 4; 57} 58