• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16declare function print(arg:any):string;
17{
18  let a = []
19  let l = a.push(1)
20  print(l)
21  l = a.push(1, 2, 3, 4, 5)
22  print(l)
23
24  for (let i = 0; i < 100; i++) {
25    a.push(i)
26  }
27
28  let c = [1, 2, 3, 4]
29  a.push(...c)
30
31  print(a.length)
32
33  let b = []
34  b.push(1, 2, 3, 4)
35  b.push(1, 2, 3)
36  b.push(1, 2)
37  b.push(1)
38  b.push()
39  print(Object.values(b))
40  print(b.length)
41}
42
43{
44  let result;
45  let array = new Array();
46  let array_size = 100;
47
48  for (let i = 0; i < array_size; i++) {
49    array[i] = i;
50  }
51
52  result = array.sort((a, b) => {
53    return a - b
54  });
55
56  print(result);
57
58  result = array.sort();
59  print(result);
60}
61
62{
63  const o24 = {
64    "mmaxByteLength": 268435456,
65  };
66  const v25 = new SharedArrayBuffer(4, o24);
67  const v27 = new Uint32Array(v25);
68  v27[0] = 2051996997;
69  const v30 = v27.fill(o24, 4, 4);
70  v30[0] = -36814;
71  const v32 = new Float32Array(v25);
72  let v33 = v32[0];
73  print(v33);
74}
75
76{
77  const BASE_NAN_VALUE = NaN;
78  function simulateFloatConvert(value, isFloat32) {
79    const float64Value = isFloat32 ?
80      new Float64Array(Float64Array.from(Float32Array.of(value)).buffer)[0] : value;
81    return isNaN(float64Value) ? BASE_NAN_VALUE : float64Value;
82  }
83  print(simulateFloatConvert(NaN, false));
84}
85