mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
Fix JSTaggedValue::Equal Bug
Fix JSTaggedValue::Equal() according to ECMA 262. Issue: #I71K7H Signed-off-by: lichenshuai <lichenshuai@huawei.com> Change-Id: Ib3b8aff72bf0a6bb9d1b687fd4a9bfba0307f527
This commit is contained in:
parent
e8759479a3
commit
1898e054fc
@ -190,11 +190,12 @@ void CrashCallback(char *buf __attribute__((unused)), size_t len __attribute__((
|
||||
FrameIterator frame(reinterpret_cast<JSTaggedType *>(fp));
|
||||
bool isBuiltinStub = (frame.GetFrameType() == FrameType::OPTIMIZED_FRAME);
|
||||
Method *method = frame.CheckAndGetMethod();
|
||||
while (method == nullptr && !frame.Done()) {
|
||||
while (method == nullptr) {
|
||||
frame.Advance();
|
||||
if (!frame.Done()) {
|
||||
method = frame.CheckAndGetMethod();
|
||||
if (frame.Done()) {
|
||||
break;
|
||||
}
|
||||
method = frame.CheckAndGetMethod();
|
||||
}
|
||||
std::string faultInfo;
|
||||
if (method != nullptr) {
|
||||
|
@ -192,8 +192,8 @@ bool JSTaggedValue::Equal(JSThread *thread, const JSHandle<JSTaggedValue> &x, co
|
||||
if (y->IsSymbol()) {
|
||||
return x.GetTaggedValue() == y.GetTaggedValue();
|
||||
}
|
||||
if (y->IsBigInt()) {
|
||||
return Equal(thread, y, x);
|
||||
if (y->IsBigInt() || y->IsString()) {
|
||||
return false;
|
||||
}
|
||||
if (y->IsHeapObject()) {
|
||||
JSHandle<JSTaggedValue> yPrimitive(thread, ToPrimitive(thread, y));
|
||||
|
@ -1203,6 +1203,9 @@ HWTEST_F_L0(JSTaggedValueTest, Equal)
|
||||
ASSERT_TRUE(JSTaggedValue::Equal(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue::True()), char1Point0));
|
||||
ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue::True()), char0));
|
||||
ASSERT_FALSE(JSTaggedValue::Equal(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue::False()), char1));
|
||||
|
||||
JSHandle<JSTaggedValue> testSymbol(thread->GetEcmaVM()->GetFactory()->NewPublicSymbolWithChar("test"));
|
||||
ASSERT_FALSE(JSTaggedValue::Equal(thread, testSymbol, test));
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSTaggedValueTest, StrictEqual)
|
||||
|
@ -37,6 +37,7 @@ group("ark_js_moduletest") {
|
||||
"dynamicimport",
|
||||
"dyninstruction",
|
||||
"ecmastringtable",
|
||||
"equal",
|
||||
"forawaitof",
|
||||
"forin",
|
||||
"fortest",
|
||||
@ -129,6 +130,7 @@ group("ark_asm_test") {
|
||||
"dynamicimport",
|
||||
"dyninstruction",
|
||||
"ecmastringtable",
|
||||
"equal",
|
||||
"forin",
|
||||
"fortest",
|
||||
"generator",
|
||||
|
18
test/moduletest/equal/BUILD.gn
Normal file
18
test/moduletest/equal/BUILD.gn
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2023 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.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("equal") {
|
||||
deps = []
|
||||
}
|
27
test/moduletest/equal/equal.js
Normal file
27
test/moduletest/equal/equal.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @tc.name:equal
|
||||
* @tc.desc:test equal
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5NO8G
|
||||
*/
|
||||
var arr = [null, undefined, 0, "", 0n, false, Symbol(0), []];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
for (let j = 0; j < arr.length; j++){
|
||||
print(arr[i] == arr[j]);
|
||||
}
|
||||
}
|
77
test/moduletest/equal/expect_output.txt
Normal file
77
test/moduletest/equal/expect_output.txt
Normal file
@ -0,0 +1,77 @@
|
||||
# Copyright (c) 2023 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.
|
||||
|
||||
true
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
Loading…
Reference in New Issue
Block a user