• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-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
16import {launch} from "std/concurrency";
17import {Job} from "std/core";
18
19let flag = false
20
21function set_flag(): String {
22    flag = true
23    return "Paragliding is awesome!!\n"
24}
25
26export function main(): int {
27    let p = launch<String, () => String>(set_flag);
28    let result = p.Await();
29
30    if (!flag) {
31        console.print("Flag is not set!");
32        return 1;
33    } else {
34        console.print("First await result: " + result);
35        let result2 = p.Await();
36        console.print("Second await result: " + result2);
37        if (!(result === result2)) {
38            console.print("await results do not match!");
39            return 1;
40        }
41        if (!(result instanceof String)) {
42            console.print("await result is not String!");
43            return 1;
44        }
45    }
46    return 0;
47}
48