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(): int { 17 let z: NullishType = new Number(1); 18 let z1 = undefined; 19 let z2 = null; 20 let z3: Object = new String("0"); 21 let z4: Object = new Number(1); 22 let x = new String(z) 23 let x1 = new String(z1) 24 let x2 = new String(z2) 25 let x3 = new String(z3) 26 let x4 = new String(z4) 27 let x5 = new String(null) 28 let x6 = new String(undefined) 29 let actual: String[] = [new String(z), new String(z1), new String(z2), new String(z3), new String(z4), new String(null), new String(undefined)] 30 let expected: String[] = ["1", "undefined", "null", "0", "1", "null", "undefined"] 31 for (let i = 0; i < expected.length; i++) { 32 if (actual[i] != expected[i]) { 33 console.log("Failed: actual is \"" + actual[i] + "\" expected is \"" + expected[i] + "\"") 34 return 1; 35 } 36 } 37 return 0; 38} 39