mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
!2010 Fix Number ParseInt
Merge pull request !2010 from chenqi/FixParseInt
This commit is contained in:
commit
23fd87344b
@ -210,8 +210,7 @@ JSTaggedValue BuiltinsNumber::ParseInt(EcmaRuntimeCallInfo *argv)
|
||||
}
|
||||
|
||||
JSTaggedValue result = NumberHelper::StringToDoubleWithRadix(str.begin(), str.end(), radix);
|
||||
int32_t resTmp = NumberHelper::DoubleInRangeInt32(result.GetNumber());
|
||||
return JSTaggedValue(resTmp);
|
||||
return JSTaggedValue::TryCastDoubleToInt32(result.GetNumber());
|
||||
}
|
||||
|
||||
// prototype
|
||||
|
@ -20,7 +20,7 @@ group("ark_js_moduletest") {
|
||||
"async:asyncAction",
|
||||
"bindfunction:bindfunctionAction",
|
||||
"bitwiseop:bitwiseopAction",
|
||||
"builtinsir:builtinsirAction",
|
||||
"builtins:builtinsAction",
|
||||
"callframe:callframeAction",
|
||||
"calltype:calltypeAction",
|
||||
"class:classAction",
|
||||
@ -73,7 +73,7 @@ group("ark_asm_test") {
|
||||
"async:asyncAsmAction",
|
||||
"bindfunction:bindfunctionAsmAction",
|
||||
"bitwiseop:bitwiseopAsmAction",
|
||||
"builtinsir:builtinsirAsmAction",
|
||||
"builtins:builtinsAsmAction",
|
||||
"callframe:callframeAsmAction",
|
||||
"calltype:calltypeAsmAction",
|
||||
"class:classAsmAction",
|
||||
|
@ -16,3 +16,18 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
host_moduletest_action("builtinsir") {
|
||||
deps = []
|
||||
}
|
||||
|
||||
host_moduletest_action("builtinsnumber") {
|
||||
deps = []
|
||||
}
|
||||
|
||||
host_moduletest_action("builtins") {
|
||||
extra_modules = [
|
||||
"builtinsir",
|
||||
"builtinsnumber",
|
||||
]
|
||||
deps = [
|
||||
":gen_builtinsir_abc",
|
||||
":gen_builtinsnumber_abc",
|
||||
]
|
||||
}
|
17
test/moduletest/builtins/builtins.js
Normal file
17
test/moduletest/builtins/builtins.js
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
var string = "builtins test start"
|
||||
print(string)
|
@ -13,9 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
print("builtins ir start");
|
||||
var str1 = "wpydejkl";
|
||||
print(str1.charCodeAt(1.231));
|
||||
print(str1.charCodeAt(undefined));
|
||||
print(str1.charCodeAt(new Date()));
|
||||
print(str1.charCodeAt(14));
|
||||
print(str1.charCodeAt(3));
|
||||
print(str1.charCodeAt(3));
|
||||
print("builtins ir end");
|
19
test/moduletest/builtins/builtinsnumber.js
Normal file
19
test/moduletest/builtins/builtinsnumber.js
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
let result = Number.parseInt("16947500000");
|
||||
print("builtins number start");
|
||||
print("parseInt result = " + result);
|
||||
print("builtins number end");
|
@ -11,8 +11,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
builtins test start
|
||||
builtins ir start
|
||||
112
|
||||
119
|
||||
NaN
|
||||
NaN
|
||||
100
|
||||
builtins ir end
|
||||
builtins number start
|
||||
parseInt result = 16947500000
|
||||
builtins number end
|
Loading…
Reference in New Issue
Block a user