mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Stack SetProperty Bugfix
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAZ99N Signed-off-by: jiachong <jiachong6@huawei.com> Change-Id: Id7bd0620829179c3bf49a29bbf44bcfcf129e4d8
This commit is contained in:
parent
8a2f165ee3
commit
f10d8aac7a
@ -213,7 +213,17 @@ bool JSAPIStack::SetProperty(JSThread *thread, const JSHandle<JSAPIStack> &obj,
|
||||
const JSHandle<JSTaggedValue> &value)
|
||||
{
|
||||
int length = obj->GetTop() + 1;
|
||||
int index = key->GetInt();
|
||||
JSHandle<JSTaggedValue> indexKey = key;
|
||||
if (indexKey->IsDouble()) {
|
||||
// Math.floor(1) will produce TaggedDouble, we need to cast into TaggedInt
|
||||
// For integer which is greater than INT32_MAX, it will remain TaggedDouble
|
||||
indexKey = JSHandle<JSTaggedValue>(thread, JSTaggedValue::TryCastDoubleToInt32(indexKey->GetDouble()));
|
||||
}
|
||||
if (!indexKey->IsInt()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = indexKey->GetInt();
|
||||
if (index < 0 || index >= length) {
|
||||
return false;
|
||||
}
|
||||
|
18
test/moduletest/stack/BUILD.gn
Normal file
18
test/moduletest/stack/BUILD.gn
Normal file
@ -0,0 +1,18 @@
|
||||
# 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.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("stack") {
|
||||
deps = []
|
||||
}
|
14
test/moduletest/stack/expect_output.txt
Normal file
14
test/moduletest/stack/expect_output.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# 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.
|
||||
|
||||
[object Stack]
|
27
test/moduletest/stack/stack.js
Normal file
27
test/moduletest/stack/stack.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @tc.name:stack
|
||||
* @tc.desc:test Stack
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIAZ99N
|
||||
*/
|
||||
let arkPrivate = globalThis.ArkPrivate;
|
||||
var Stack = arkPrivate.Load(arkPrivate.Stack);
|
||||
const v1 = new Stack();
|
||||
let v2 = Math.floor([1.1]);
|
||||
v1[v2] = 0;
|
||||
print(v1);
|
Loading…
Reference in New Issue
Block a user