1/* 2 * Copyright (c) 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 foo1(z: long|undefined) { 17 let x = z ?? 10000000000; 18 return x; 19} 20 21function foo2(z: int|undefined) { 22 let x = z ?? 10000000; 23 return x; 24} 25 26function foo3(z: short|undefined) { 27 let x = z ?? 10000; 28 return x; 29} 30 31function foo4(z: byte|undefined) { 32 let x = z ?? 100; 33 return x; 34} 35 36function foo5(z: float|undefined) { 37 let x = z ?? 100000; 38 return x; 39} 40 41function foo6(z: float|undefined) { 42 let x = z ?? 100000.0f; 43 return x; 44} 45 46function foo7(z: double|undefined) { 47 let x = z ?? 10000000; 48 return x; 49} 50 51function foo8(z: double|undefined) { 52 let x = z ?? 10000000.0f; 53 return x; 54} 55 56function foo9(z: double|undefined) { 57 let x = z ?? 10000000.0; 58 return x; 59} 60 61 62function main() { 63 assertEQ(foo1(undefined), 10000000000); 64 assertEQ(foo2(undefined), 10000000); 65 assertEQ(foo3(undefined), 10000); 66 assertEQ(foo4(undefined), 100); 67 assertEQ(foo5(undefined), 100000.0f); 68 assertEQ(foo6(undefined), 100000.0f); 69 assertEQ(foo7(undefined), 10000000.0); 70 assertEQ(foo8(undefined), 10000000.0); 71 assertEQ(foo9(undefined), 10000000.0); 72} 73