* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function test1() {
try {
var base = null;
var prop = {
toString: function () {
print("toString");
throw "111";
},
};
base[prop];
} catch (e) {
print("error");
}
}
function test2() {
print(Number.NaN != Number.NaN);
}
function _test() {
this.x = 0.1;
}
function test3() {
var a = new _test();
print(a.x);
}
function test4() {
print(1 / (-1 % 1));
print(1 / (-1 % -1));
print(1 / (-3 % 1));
print(1 / (-3 % -1));
print(1 / (-3 % 3));
print(1 / (-3 % -3));
print(1 / (-3.3 % 3.3));
print(1 / (-3.3 % -3.3));
}
function test5() {
var a = {};
a._toString = function (value) {
if (value === 0 && 1 / value === -Infinity) {
return "-0";
}
return String(value);
};
var x;
x = -1;
print(a._toString((x %= -1)));
}
function test6() {
var a = [0];
a.length = 3;
Object.prototype[2] = 2;
print(a[2]);
}
function test7() {
var onheap = new Uint8Array(1)
var onheap2 = new Uint8Array(1)
var notOnHeap = new Uint8Array(512 * 8 + 1)
onheap[0] = 1
notOnHeap[0] = 2
onheap2[0] = 3
print(ArkTools.isOnHeap(onheap));
print(ArkTools.isOnHeap(notOnHeap));
print(ArkTools.isOnHeap(onheap2));
print(onheap[0])
print(notOnHeap[0])
onheap.buffer
print(ArkTools.isOnHeap(onheap));
print(onheap[0])
onheap2.x = 2
onheap2.buffer
print(ArkTools.isOnHeap(onheap2));
print(onheap2.x)
print(onheap2[0])
}
test1()
test2()
test3()
test4()
test5()
test6()
test7()