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