• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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(): void {
17  let arr1: FixedArray<Int> = [1,2,3,4,5];
18  let arr2: FixedArray<int> = [1,2,3,4,5];
19  let object_array: FixedArray<Object> = arr1 as FixedArray<Object>;
20  let obj: Object = arr1 as Object;
21
22// TypeError: Cannot access property of non-object or non-enum type
23// arr1.toString();
24// arr2.toString();
25// object_array.toString();
26
27  obj.toString();
28
29//  TypeError: Cannot access property of non-object or non-enum type
30//  arr1.$_hashCode();
31//  arr2.$_hashCode();
32//  object_array.$_hashCode();
33
34  obj.$_hashCode();
35
36  assertEQ(arr1, arr1)
37  assertEQ(arr1, object_array)
38  assertEQ(arr1, obj)
39  assertNE(arr1, arr2)
40
41// Cannot cast type 'int[]' to 'Object[]'
42//  let object_array2: Object[] = arr2 as Object[];
43//  assertEQ(obj.equals(arr2 as Object), false)
44
45  assertEQ(arr2, arr2)
46  assertNE(arr2, new int[5])
47}
48