!2010 Fix Number ParseInt

Merge pull request !2010 from chenqi/FixParseInt
This commit is contained in:
openharmony_ci 2022-08-10 02:59:52 +00:00 committed by Gitee
commit 23fd87344b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 63 additions and 5 deletions

View File

@ -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

View File

@ -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",

View File

@ -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",
]
}

View 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)

View File

@ -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");

View 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");

View File

@ -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