• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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
16/*
17 * @tc.name:sendabletypedarray
18 * @tc.desc:test sendabletypedarray
19 * @tc.type: FUNC
20 * @tc.require: issue#I9EBOZ
21 */
22
23// @ts-nocheck
24declare function print(str: any): string;
25declare function isSendable(obj: lang.ISendable | Object): boolean;
26
27let a = 0;
28function f(b) {
29  a += b;
30}
31for (let i = 0; i < 10000; i++) {
32  f(0);
33}
34
35class SClass {
36  str: string | undefined;
37  constructor(s: string) {
38    "use sendable"
39    this.str = s;
40    print(ArkTools.isTreeString(s));
41    print(ArkTools.isTreeString(this.str));
42    print(s === this.str);
43  }
44}
45
46let s1 = "aaaaaaaaaaaaaaaaaaaaaa";
47let s2 = "bbbbbbbbbbbbbbbbbbbbbb";
48let s = s1 + s2;
49
50let obj = new SClass(s);
51for (let i = 0; i < 2; i++) {
52  obj.str = s;
53  print(ArkTools.isTreeString(s));
54  print(ArkTools.isTreeString(obj.str));
55  print(s === obj.str);
56}
57s = "abc";
58for (let i = 0; i < 2; i++) {
59  obj.str = s;
60  print(s === obj.str);
61}