• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024-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    let src: string | undefined = undefined;
18    let s = "_str_";
19    let udef = undefined;
20    let a :string = "A_";
21    let n : string | undefined | null = null;
22
23    let dst: string = "" + src;
24    let dst_s : string = src + "";
25    let a_dst :string = a + dst;
26    let n_dst : string = n + a_dst;
27    let dst_a : string = dst + a;
28
29
30
31    assertEQ(dst, "undefined")
32    assertEQ(dst_s, "undefined")
33    assertEQ(a_dst, "A_undefined")
34    assertEQ(dst_a, "undefinedA_")
35    assertEQ(n_dst, "nullA_undefined")
36    assertEQ(udef + s, "undefined_str_")
37    assertEQ(s + udef, "_str_undefined")
38    assertEQ(a + n, "A_null")
39    assertEQ(a + s, "A__str_")
40    assertEQ(a + s + udef, "A__str_undefined")
41    assertEQ(a + udef + a, "A_undefinedA_")
42    assertEQ(udef + s + n, "undefined_str_null")
43
44    let p1 = 1
45    let p2 = 2
46    let p3 = "*"
47
48    let res = p1+p2+p3;
49    assertEQ(res, "3*")
50}
51