• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-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 c2 : char = c'\u0002';
18  let c5 : char = c'\u0005';
19  let c7 : char = c'\u0007';
20
21  assertEQ(c'\u0002' + c'\u0005', c'\u0007')
22  assertEQ(c2 + c5, c7)
23
24  assertEQ(c'\u0007' - c'\u0005', c'\u0002')
25  assertEQ(c7 - c5, c2)
26
27  assertTrue(c'\u0002' < c'\u0005')
28  assertTrue(c2 < c5)
29
30  // u0002 -> 00000002 , -00000002 == FFFFFFFE == -2;
31  assertEQ(-c'\u0002', -2)
32  assertEQ(-c2, -2)
33
34  // u0002 -> 00000002 , ~00000002 == FFFFFFFD == -3;
35  assertEQ(~c'\u0002', -3)
36  assertEQ(~c2, -3)
37
38  assertEQ(c'\u0005' / c'\u0002', 2)
39  assertEQ(c5 / c2, 2)
40
41  assertEQ(c'\u0005' % c'\u0002', 1)
42  assertEQ(c5 % c2, 1)
43
44  assertEQ(c'\u0005' << c'\u0002', 20)
45  assertEQ(c5 << c2, 20)
46
47  let arr : char[] = new char[1];
48  arr[0] = c2;
49  assertTrue(c2 == arr[0] && arr[0] == c2)
50
51  return;
52}
53