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 */
15var clampedArray = new Uint8ClampedArray(10);
16
17function test() {
18  clampedArray[0] = 0.499;
19  print(0 == clampedArray[0]);
20  clampedArray[0] = 0.5;
21  print(0 == clampedArray[0]);
22  clampedArray[0] = 0.501;
23  print(1 == clampedArray[0]);
24  clampedArray[0] = 1.499;
25  print(1 == clampedArray[0]);
26  clampedArray[0] = 1.5;
27  print(2 == clampedArray[0]);
28  clampedArray[0] = 1.501;
29  print(2 == clampedArray[0]);
30  clampedArray[0] = 2.5;
31  print(2 == clampedArray[0]);
32  clampedArray[0] = 3.5;
33  print(4 == clampedArray[0]);
34  clampedArray[0] = 252.5;
35  print(252 == clampedArray[0]);
36  clampedArray[0] = 253.5;
37  print(254 == clampedArray[0]);
38  clampedArray[0] = 254.5;
39  print(254 == clampedArray[0]);
40  clampedArray[0] = 256.5;
41  print(255 == clampedArray[0]);
42  clampedArray[0] = -0.5;
43  print(0 == clampedArray[0]);
44  clampedArray[0] = -1.5;
45  print(0 == clampedArray[0]);
46  clampedArray[0] = 1000000000000;
47  print(255 == clampedArray[0]);
48  clampedArray[0] = -1000000000000;
49  print(0 == clampedArray[0]);
50};
51ArkTools.prepareFunctionForOptimization(test);
52test();
53test();
54ArkTools.optimizeFunctionOnNextCall(test);
55test();