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 main(){ 17 await test(); 18 19} 20 21async function test() { 22 let p = Promise.resolve(6); 23 assertEQ(await p, 6); 24 assertEQ(await p * 2, 12); 25 assertEQ(await p / 2, 3); 26 assertEQ(await p % 3, 0); 27 assertEQ(await p + 1, 7); 28 assertEQ(await p - 2, 4); 29 assertEQ(await p === 6, true); 30 assertEQ(await p != 4, true); 31 assertEQ(1 << await p, 64); 32 assertEQ(await p > 3, true); 33 assertEQ(await p < 3, false); 34 assertEQ(await p == 6, true); 35 assertEQ(await p != 1, true); 36 assertEQ(await p & 3, 2); 37 assertEQ(await p ^ 2, 4); 38 assertEQ(await p | 1, 7); 39 40 let b = Promise.resolve(false); 41 assertEQ(await b || true, true); 42 let n = Promise.resolve(null); 43 assertEQ(await n ?? 42, 42); 44 let r = await p > 3 ? "yes" : "no"; 45 assertEQ(r, "yes"); 46 let x = await p; 47 assertEQ(x, 6); 48}