14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#include "ecmascript/builtins/builtins_bigint.h" 174514f5e3Sopenharmony_ci 184514f5e3Sopenharmony_ci#include "ecmascript/global_env.h" 194514f5e3Sopenharmony_ci#include "ecmascript/js_bigint.h" 204514f5e3Sopenharmony_ci#include "ecmascript/js_primitive_ref.h" 214514f5e3Sopenharmony_ci#include "ecmascript/tests/test_helper.h" 224514f5e3Sopenharmony_ci 234514f5e3Sopenharmony_ciusing namespace panda::ecmascript; 244514f5e3Sopenharmony_ciusing namespace panda::ecmascript::builtins; 254514f5e3Sopenharmony_ci 264514f5e3Sopenharmony_cinamespace panda::test { 274514f5e3Sopenharmony_ciusing BigInt = ecmascript::BigInt; 284514f5e3Sopenharmony_ciclass BuiltinsBigIntTest : public BaseTestWithScope<true> { 294514f5e3Sopenharmony_ci}; 304514f5e3Sopenharmony_ci 314514f5e3Sopenharmony_cienum class AlgorithmType { 324514f5e3Sopenharmony_ci BIGINT_CONSTRUCTOR, 334514f5e3Sopenharmony_ci BIGINT_ASINTN, 344514f5e3Sopenharmony_ci BIGINT_ASUINTN, 354514f5e3Sopenharmony_ci BIGINT_TOLOCALSTR, 364514f5e3Sopenharmony_ci BIGINT_TOSTR, 374514f5e3Sopenharmony_ci BIGINT_VALUEOF 384514f5e3Sopenharmony_ci}; 394514f5e3Sopenharmony_ci 404514f5e3Sopenharmony_cistatic JSTaggedValue BigIntAlgorithm(JSThread *thread, std::vector<JSTaggedValue>& args, int32_t argLen, 414514f5e3Sopenharmony_ci AlgorithmType type, JSTaggedValue argThis = JSTaggedValue::Undefined()) 424514f5e3Sopenharmony_ci{ 434514f5e3Sopenharmony_ci auto ecmaRuntimeCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), argLen); 444514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetFunction(JSTaggedValue::Undefined()); 454514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetThis(argThis); 464514f5e3Sopenharmony_ci for (size_t i = 0; i < args.size(); i++) { 474514f5e3Sopenharmony_ci ecmaRuntimeCallInfo->SetCallArg(i, args[i]); 484514f5e3Sopenharmony_ci } 494514f5e3Sopenharmony_ci 504514f5e3Sopenharmony_ci auto prev = TestHelper::SetupFrame(thread, ecmaRuntimeCallInfo); 514514f5e3Sopenharmony_ci JSTaggedValue result; 524514f5e3Sopenharmony_ci switch (type) { 534514f5e3Sopenharmony_ci case AlgorithmType::BIGINT_CONSTRUCTOR: 544514f5e3Sopenharmony_ci result = BuiltinsBigInt::BigIntConstructor(ecmaRuntimeCallInfo); 554514f5e3Sopenharmony_ci break; 564514f5e3Sopenharmony_ci case AlgorithmType::BIGINT_ASINTN: 574514f5e3Sopenharmony_ci result = BuiltinsBigInt::AsIntN(ecmaRuntimeCallInfo); 584514f5e3Sopenharmony_ci break; 594514f5e3Sopenharmony_ci case AlgorithmType::BIGINT_ASUINTN: 604514f5e3Sopenharmony_ci result = BuiltinsBigInt::AsUintN(ecmaRuntimeCallInfo); 614514f5e3Sopenharmony_ci break; 624514f5e3Sopenharmony_ci case AlgorithmType::BIGINT_TOLOCALSTR: 634514f5e3Sopenharmony_ci result = BuiltinsBigInt::ToLocaleString(ecmaRuntimeCallInfo); 644514f5e3Sopenharmony_ci break; 654514f5e3Sopenharmony_ci case AlgorithmType::BIGINT_TOSTR: 664514f5e3Sopenharmony_ci result = BuiltinsBigInt::ToString(ecmaRuntimeCallInfo); 674514f5e3Sopenharmony_ci break; 684514f5e3Sopenharmony_ci case AlgorithmType::BIGINT_VALUEOF: 694514f5e3Sopenharmony_ci result = BuiltinsBigInt::ValueOf(ecmaRuntimeCallInfo); 704514f5e3Sopenharmony_ci break; 714514f5e3Sopenharmony_ci default: 724514f5e3Sopenharmony_ci break; 734514f5e3Sopenharmony_ci } 744514f5e3Sopenharmony_ci 754514f5e3Sopenharmony_ci TestHelper::TearDownFrame(thread, prev); 764514f5e3Sopenharmony_ci return result; 774514f5e3Sopenharmony_ci} 784514f5e3Sopenharmony_ci 794514f5e3Sopenharmony_ci// new BigInt(123) 804514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, BigIntConstructor_001) 814514f5e3Sopenharmony_ci{ 824514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(thread, JSTaggedValue(123)); 834514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 844514f5e3Sopenharmony_ci auto result = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 854514f5e3Sopenharmony_ci 864514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsBigInt()); 874514f5e3Sopenharmony_ci} 884514f5e3Sopenharmony_ci 894514f5e3Sopenharmony_ci// new BigInt("456") 904514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, BigIntConstructor_002) 914514f5e3Sopenharmony_ci{ 924514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 934514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("456")); 944514f5e3Sopenharmony_ci 954514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 964514f5e3Sopenharmony_ci auto result = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 974514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsBigInt()); 984514f5e3Sopenharmony_ci} 994514f5e3Sopenharmony_ci 1004514f5e3Sopenharmony_ci// AsIntN(64, (2 ^ 63 - 1)) 1014514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, AsIntN_001) 1024514f5e3Sopenharmony_ci{ 1034514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1044514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("9223372036854775807")); 1054514f5e3Sopenharmony_ci int bit = 64; // 64-bit 1064514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{JSTaggedValue(static_cast<int>(bit)), numericValue.GetTaggedValue()}; 1074514f5e3Sopenharmony_ci auto result = BigIntAlgorithm(thread, vals, 8, AlgorithmType::BIGINT_ASINTN); 1084514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsBigInt()); 1094514f5e3Sopenharmony_ci 1104514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result); 1114514f5e3Sopenharmony_ci JSHandle<EcmaString> resultStr = BigInt::ToString(thread, bigIntHandle); 1124514f5e3Sopenharmony_ci JSHandle<EcmaString> str = factory->NewFromASCII("9223372036854775807"); 1134514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, resultStr, str), 0); 1144514f5e3Sopenharmony_ci} 1154514f5e3Sopenharmony_ci 1164514f5e3Sopenharmony_ci// AsIntN(64, (2 ^ 63)) 1174514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, AsIntN_002) 1184514f5e3Sopenharmony_ci{ 1194514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1204514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("9223372036854775808")); 1214514f5e3Sopenharmony_ci int bit = 64; // 64-bit 1224514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{JSTaggedValue(static_cast<int>(bit)), numericValue.GetTaggedValue()}; 1234514f5e3Sopenharmony_ci auto result = BigIntAlgorithm(thread, vals, 8, AlgorithmType::BIGINT_ASINTN); 1244514f5e3Sopenharmony_ci 1254514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsBigInt()); 1264514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result); 1274514f5e3Sopenharmony_ci JSHandle<EcmaString> resultStr = BigInt::ToString(thread, bigIntHandle); 1284514f5e3Sopenharmony_ci JSHandle<EcmaString> str = factory->NewFromASCII("-9223372036854775808"); 1294514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, resultStr, str), 0); 1304514f5e3Sopenharmony_ci} 1314514f5e3Sopenharmony_ci 1324514f5e3Sopenharmony_ci// AsUintN(64, (2 ^ 64 - 1)) 1334514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, AsUintN_001) 1344514f5e3Sopenharmony_ci{ 1354514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1364514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("18446744073709551615")); 1374514f5e3Sopenharmony_ci int bit = 64; // 64-bit 1384514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{JSTaggedValue(static_cast<int>(bit)), numericValue.GetTaggedValue()}; 1394514f5e3Sopenharmony_ci auto result = BigIntAlgorithm(thread, vals, 8, AlgorithmType::BIGINT_ASUINTN); 1404514f5e3Sopenharmony_ci 1414514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsBigInt()); 1424514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result); 1434514f5e3Sopenharmony_ci JSHandle<EcmaString> resultStr = BigInt::ToString(thread, bigIntHandle); 1444514f5e3Sopenharmony_ci JSHandle<EcmaString> str = factory->NewFromASCII("18446744073709551615"); 1454514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, resultStr, str), 0); 1464514f5e3Sopenharmony_ci} 1474514f5e3Sopenharmony_ci 1484514f5e3Sopenharmony_ci// AsUintN(64, (2 ^ 64)) 1494514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, AsUintN_002) 1504514f5e3Sopenharmony_ci{ 1514514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1524514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("18446744073709551616")); 1534514f5e3Sopenharmony_ci int bit = 64; // 64-bit 1544514f5e3Sopenharmony_ci 1554514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{JSTaggedValue(static_cast<int>(bit)), numericValue.GetTaggedValue()}; 1564514f5e3Sopenharmony_ci auto result = BigIntAlgorithm(thread, vals, 8, AlgorithmType::BIGINT_ASUINTN); 1574514f5e3Sopenharmony_ci 1584514f5e3Sopenharmony_ci EXPECT_TRUE(result.IsBigInt()); 1594514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result); 1604514f5e3Sopenharmony_ci JSHandle<EcmaString> resultStr = BigInt::ToString(thread, bigIntHandle); 1614514f5e3Sopenharmony_ci JSHandle<EcmaString> str = factory->NewFromASCII("0"); 1624514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, resultStr, str), 0); 1634514f5e3Sopenharmony_ci} 1644514f5e3Sopenharmony_ci 1654514f5e3Sopenharmony_ci// using locale 1664514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ToLocaleString_001) 1674514f5e3Sopenharmony_ci{ 1684514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1694514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("123456789123456789")); 1704514f5e3Sopenharmony_ci 1714514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 1724514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 1734514f5e3Sopenharmony_ci 1744514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 1754514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> locale(factory->NewFromASCII("de-DE")); 1764514f5e3Sopenharmony_ci 1774514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{locale.GetTaggedValue(), JSTaggedValue::Undefined()}; 1784514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 8, AlgorithmType::BIGINT_TOLOCALSTR, bigIntHandle.GetTaggedValue()); 1794514f5e3Sopenharmony_ci 1804514f5e3Sopenharmony_ci EXPECT_TRUE(result2.IsString()); 1814514f5e3Sopenharmony_ci JSHandle<EcmaString> ecmaStrHandle(thread, result2); 1824514f5e3Sopenharmony_ci JSHandle<EcmaString> resultStr(factory->NewFromASCII("123.456.789.123.456.789")); 1834514f5e3Sopenharmony_ci EXPECT_EQ(EcmaStringAccessor::Compare(instance, ecmaStrHandle, resultStr), 0); 1844514f5e3Sopenharmony_ci} 1854514f5e3Sopenharmony_ci 1864514f5e3Sopenharmony_ci// using locale and options 1874514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ToLocaleString_002) 1884514f5e3Sopenharmony_ci{ 1894514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 1904514f5e3Sopenharmony_ci JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv(); 1914514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> objFun = env->GetObjectFunction(); 1924514f5e3Sopenharmony_ci JSHandle<JSObject> optionsObj = factory->NewJSObjectByConstructor(JSHandle<JSFunction>(objFun), objFun); 1934514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("123456789123456789")); 1944514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> formatStyle = thread->GlobalConstants()->GetHandledStyleString(); 1954514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> styleKey(factory->NewFromASCII("currency")); 1964514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> styleValue(factory->NewFromASCII("EUR")); 1974514f5e3Sopenharmony_ci 1984514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 1994514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 2004514f5e3Sopenharmony_ci 2014514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 2024514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> locale(factory->NewFromASCII("de-DE")); 2034514f5e3Sopenharmony_ci JSObject::SetProperty(thread, optionsObj, formatStyle, styleKey); 2044514f5e3Sopenharmony_ci JSObject::SetProperty(thread, optionsObj, styleKey, styleValue); 2054514f5e3Sopenharmony_ci 2064514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{locale.GetTaggedValue(), optionsObj.GetTaggedValue()}; 2074514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 8, AlgorithmType::BIGINT_TOLOCALSTR, bigIntHandle.GetTaggedValue()); 2084514f5e3Sopenharmony_ci 2094514f5e3Sopenharmony_ci EXPECT_TRUE(result2.IsString()); 2104514f5e3Sopenharmony_ci JSHandle<EcmaString> ecmaStrHandle(thread, result2); 2114514f5e3Sopenharmony_ci EXPECT_STREQ("123.456.789.123.456.789,00 €", EcmaStringAccessor(ecmaStrHandle).ToCString().c_str()); 2124514f5e3Sopenharmony_ci} 2134514f5e3Sopenharmony_ci 2144514f5e3Sopenharmony_ci// 17.ToStirng() 2154514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ToString_001) 2164514f5e3Sopenharmony_ci{ 2174514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 2184514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("17")); 2194514f5e3Sopenharmony_ci 2204514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 2214514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 2224514f5e3Sopenharmony_ci 2234514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 2244514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{JSTaggedValue::Undefined()}; 2254514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 6, AlgorithmType::BIGINT_TOSTR, bigIntHandle.GetTaggedValue()); 2264514f5e3Sopenharmony_ci 2274514f5e3Sopenharmony_ci EXPECT_TRUE(result2.IsString()); 2284514f5e3Sopenharmony_ci JSHandle<EcmaString> ecmaStrHandle(thread, result2); 2294514f5e3Sopenharmony_ci EXPECT_STREQ("17", EcmaStringAccessor(ecmaStrHandle).ToCString().c_str()); 2304514f5e3Sopenharmony_ci} 2314514f5e3Sopenharmony_ci 2324514f5e3Sopenharmony_ci// -0.ToStirng() 2334514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ToString_002) 2344514f5e3Sopenharmony_ci{ 2354514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 2364514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("-0")); 2374514f5e3Sopenharmony_ci 2384514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 2394514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 2404514f5e3Sopenharmony_ci 2414514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 2424514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{JSTaggedValue::Undefined()}; 2434514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 6, AlgorithmType::BIGINT_TOSTR, bigIntHandle.GetTaggedValue()); 2444514f5e3Sopenharmony_ci 2454514f5e3Sopenharmony_ci EXPECT_TRUE(result2.IsString()); 2464514f5e3Sopenharmony_ci JSHandle<EcmaString> ecmaStrHandle(thread, result2); 2474514f5e3Sopenharmony_ci EXPECT_STREQ("0", EcmaStringAccessor(ecmaStrHandle).ToCString().c_str()); 2484514f5e3Sopenharmony_ci} 2494514f5e3Sopenharmony_ci 2504514f5e3Sopenharmony_ci// -10.ToStirng(2) 2514514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ToString_003) 2524514f5e3Sopenharmony_ci{ 2534514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 2544514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("-10")); 2554514f5e3Sopenharmony_ci 2564514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 2574514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 2584514f5e3Sopenharmony_ci 2594514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 2604514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> radix(thread, JSTaggedValue(2)); 2614514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{radix.GetTaggedValue()}; 2624514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 6, AlgorithmType::BIGINT_TOSTR, bigIntHandle.GetTaggedValue()); 2634514f5e3Sopenharmony_ci 2644514f5e3Sopenharmony_ci EXPECT_TRUE(result2.IsString()); 2654514f5e3Sopenharmony_ci JSHandle<EcmaString> ecmaStrHandle(thread, result2); 2664514f5e3Sopenharmony_ci EXPECT_STREQ("-1010", EcmaStringAccessor(ecmaStrHandle).ToCString().c_str()); 2674514f5e3Sopenharmony_ci} 2684514f5e3Sopenharmony_ci 2694514f5e3Sopenharmony_ci// 254.ToStirng(16) 2704514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ToString_004) 2714514f5e3Sopenharmony_ci{ 2724514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 2734514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("254")); 2744514f5e3Sopenharmony_ci 2754514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 2764514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 2774514f5e3Sopenharmony_ci 2784514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 2794514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> radix(thread, JSTaggedValue(16)); 2804514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{radix.GetTaggedValue()}; 2814514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 6, AlgorithmType::BIGINT_TOSTR, bigIntHandle.GetTaggedValue()); 2824514f5e3Sopenharmony_ci 2834514f5e3Sopenharmony_ci EXPECT_TRUE(result2.IsString()); 2844514f5e3Sopenharmony_ci JSHandle<EcmaString> ecmaStrHandle(thread, result2); 2854514f5e3Sopenharmony_ci EXPECT_STREQ("fe", EcmaStringAccessor(ecmaStrHandle).ToCString().c_str()); 2864514f5e3Sopenharmony_ci} 2874514f5e3Sopenharmony_ci 2884514f5e3Sopenharmony_ci// BigInt.ValueOf 2894514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ValueOf_001) 2904514f5e3Sopenharmony_ci{ 2914514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 2924514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("-65536")); 2934514f5e3Sopenharmony_ci 2944514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 2954514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 2964514f5e3Sopenharmony_ci 2974514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 2984514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{}; 2994514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 4, AlgorithmType::BIGINT_VALUEOF, bigIntHandle.GetTaggedValue()); 3004514f5e3Sopenharmony_ci 3014514f5e3Sopenharmony_ci EXPECT_EQ(BigInt::SameValue(result1, result2), true); 3024514f5e3Sopenharmony_ci} 3034514f5e3Sopenharmony_ci 3044514f5e3Sopenharmony_ci// Object.ValueOf 3054514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, ValueOf_002) 3064514f5e3Sopenharmony_ci{ 3074514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 3084514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> numericValue(factory->NewFromASCII("65535")); 3094514f5e3Sopenharmony_ci 3104514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals{numericValue.GetTaggedValue()}; 3114514f5e3Sopenharmony_ci auto result1 = BigIntAlgorithm(thread, vals, 6, AlgorithmType::BIGINT_CONSTRUCTOR); 3124514f5e3Sopenharmony_ci 3134514f5e3Sopenharmony_ci JSHandle<BigInt> bigIntHandle(thread, result1); 3144514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> bigIntObj(bigIntHandle); 3154514f5e3Sopenharmony_ci std::vector<JSTaggedValue> vals2{}; 3164514f5e3Sopenharmony_ci 3174514f5e3Sopenharmony_ci JSHandle<JSPrimitiveRef> jsPrimitiveRef = factory->NewJSPrimitiveRef(PrimitiveType::PRIMITIVE_BIGINT, bigIntObj); 3184514f5e3Sopenharmony_ci auto result2 = BigIntAlgorithm(thread, vals2, 4, AlgorithmType::BIGINT_VALUEOF, jsPrimitiveRef.GetTaggedValue()); 3194514f5e3Sopenharmony_ci 3204514f5e3Sopenharmony_ci EXPECT_EQ(BigInt::SameValue(bigIntHandle.GetTaggedValue(), result2), true); 3214514f5e3Sopenharmony_ci} 3224514f5e3Sopenharmony_ci 3234514f5e3Sopenharmony_ci// testcases of NumberToBigint() 3244514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, NumberToBigint) 3254514f5e3Sopenharmony_ci{ 3264514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> number(thread, JSTaggedValue::Undefined()); 3274514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> bigint(thread, JSTaggedValue::Undefined()); 3284514f5e3Sopenharmony_ci 3294514f5e3Sopenharmony_ci number = JSHandle<JSTaggedValue>(thread, JSTaggedValue(base::MAX_VALUE)); 3304514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, number)); 3314514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3324514f5e3Sopenharmony_ci bool compareRes = JSTaggedValue::Equal(thread, number, bigint); 3334514f5e3Sopenharmony_ci ASSERT_TRUE(compareRes); 3344514f5e3Sopenharmony_ci 3354514f5e3Sopenharmony_ci number = JSHandle<JSTaggedValue>(thread, JSTaggedValue(-base::MAX_VALUE)); 3364514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, number)); 3374514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3384514f5e3Sopenharmony_ci compareRes = JSTaggedValue::Equal(thread, number, bigint); 3394514f5e3Sopenharmony_ci ASSERT_TRUE(JSHandle<BigInt>::Cast(bigint)->GetSign()); 3404514f5e3Sopenharmony_ci ASSERT_TRUE(compareRes); 3414514f5e3Sopenharmony_ci 3424514f5e3Sopenharmony_ci number = JSHandle<JSTaggedValue>(thread, JSTaggedValue(-0xffffffff)); 3434514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, number)); 3444514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3454514f5e3Sopenharmony_ci compareRes = JSTaggedValue::Equal(thread, number, bigint); 3464514f5e3Sopenharmony_ci ASSERT_TRUE(compareRes); 3474514f5e3Sopenharmony_ci 3484514f5e3Sopenharmony_ci number = JSHandle<JSTaggedValue>(thread, JSTaggedValue(0)); 3494514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, number)); 3504514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3514514f5e3Sopenharmony_ci compareRes = JSTaggedValue::Equal(thread, number, bigint); 3524514f5e3Sopenharmony_ci ASSERT_TRUE(compareRes); 3534514f5e3Sopenharmony_ci 3544514f5e3Sopenharmony_ci number = JSHandle<JSTaggedValue>(thread, JSTaggedValue(std::numeric_limits<double>::infinity())); 3554514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, number)); 3564514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsException()); 3574514f5e3Sopenharmony_ci thread->ClearException(); 3584514f5e3Sopenharmony_ci} 3594514f5e3Sopenharmony_ci 3604514f5e3Sopenharmony_ci// testcases of BigintToNumber() 3614514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, BigintToNumber) 3624514f5e3Sopenharmony_ci{ 3634514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 3644514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> bigint(thread, JSTaggedValue::Undefined()); 3654514f5e3Sopenharmony_ci JSTaggedNumber number(0); 3664514f5e3Sopenharmony_ci 3674514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> parma(factory->NewFromASCII("0xffff")); 3684514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, JSTaggedValue::ToBigInt(thread, parma)); 3694514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3704514f5e3Sopenharmony_ci number = BigInt::BigIntToNumber(JSHandle<BigInt>::Cast(bigint)); 3714514f5e3Sopenharmony_ci ASSERT_EQ(number.GetNumber(), static_cast<double>(0xffff)); 3724514f5e3Sopenharmony_ci 3734514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>( 3744514f5e3Sopenharmony_ci factory->NewFromASCII("0xfffffffffffff8000000000000000000000000000000000000000000000000000" 3754514f5e3Sopenharmony_ci "0000000000000000000000000000000000000000000000000000000000000000000" 3764514f5e3Sopenharmony_ci "0000000000000000000000000000000000000000000000000000000000000000000" 3774514f5e3Sopenharmony_ci "000000000000000000000000000000000000000000000000000000000")); 3784514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, JSTaggedValue::ToBigInt(thread, parma)); 3794514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3804514f5e3Sopenharmony_ci number = BigInt::BigIntToNumber(JSHandle<BigInt>::Cast(bigint)); 3814514f5e3Sopenharmony_ci ASSERT_EQ(number.GetNumber(), base::MAX_VALUE); 3824514f5e3Sopenharmony_ci 3834514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(thread, JSTaggedValue::False()); 3844514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, JSTaggedValue::ToBigInt(thread, parma)); 3854514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3864514f5e3Sopenharmony_ci ASSERT_TRUE(JSHandle<BigInt>::Cast(bigint)->IsZero()); 3874514f5e3Sopenharmony_ci number = BigInt::BigIntToNumber(JSHandle<BigInt>::Cast(bigint)); 3884514f5e3Sopenharmony_ci ASSERT_EQ(number.GetNumber(), 0.0); 3894514f5e3Sopenharmony_ci 3904514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(thread, JSTaggedValue(base::MAX_VALUE)); 3914514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, parma)); 3924514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3934514f5e3Sopenharmony_ci number = BigInt::BigIntToNumber(JSHandle<BigInt>::Cast(bigint)); 3944514f5e3Sopenharmony_ci ASSERT_EQ(number.GetNumber(), base::MAX_VALUE); 3954514f5e3Sopenharmony_ci 3964514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(thread, JSTaggedValue(-base::MAX_VALUE)); 3974514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, parma)); 3984514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 3994514f5e3Sopenharmony_ci number = BigInt::BigIntToNumber(JSHandle<BigInt>::Cast(bigint)); 4004514f5e3Sopenharmony_ci ASSERT_EQ(number.GetNumber(), -base::MAX_VALUE); 4014514f5e3Sopenharmony_ci 4024514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(thread, JSTaggedValue(-0xffffffff)); 4034514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, BigInt::NumberToBigInt(thread, parma)); 4044514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4054514f5e3Sopenharmony_ci number = BigInt::BigIntToNumber(JSHandle<BigInt>::Cast(bigint)); 4064514f5e3Sopenharmony_ci ASSERT_EQ(number.GetNumber(), -0xffffffff); 4074514f5e3Sopenharmony_ci} 4084514f5e3Sopenharmony_ci 4094514f5e3Sopenharmony_ci// testcases of StringToBigInt(EcmaString) 4104514f5e3Sopenharmony_ciHWTEST_F_L0(BuiltinsBigIntTest, StringToBigInt) 4114514f5e3Sopenharmony_ci{ 4124514f5e3Sopenharmony_ci ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); 4134514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> bigint; 4144514f5e3Sopenharmony_ci JSHandle<EcmaString> str; 4154514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> parma; 4164514f5e3Sopenharmony_ci 4174514f5e3Sopenharmony_ci // hex string 4184514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("0xffff")); 4194514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4204514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4214514f5e3Sopenharmony_ci str = BigInt::ToString(thread, JSHandle<BigInt>::Cast(bigint), BigInt::HEXADECIMAL); 4224514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("ffff")); 4234514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, str, JSHandle<EcmaString>(parma)), 0); 4244514f5e3Sopenharmony_ci 4254514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("0XFFFF")); 4264514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4274514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4284514f5e3Sopenharmony_ci str = BigInt::ToString(thread, JSHandle<BigInt>::Cast(bigint), BigInt::HEXADECIMAL); 4294514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("ffff")); 4304514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, str, JSHandle<EcmaString>(parma)), 0); 4314514f5e3Sopenharmony_ci 4324514f5e3Sopenharmony_ci // binary string 4334514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("0b11111111")); 4344514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4354514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4364514f5e3Sopenharmony_ci str = BigInt::ToString(thread, JSHandle<BigInt>::Cast(bigint), BigInt::BINARY); 4374514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("11111111")); 4384514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, str, JSHandle<EcmaString>(parma)), 0); 4394514f5e3Sopenharmony_ci 4404514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("0B11111111")); 4414514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4424514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4434514f5e3Sopenharmony_ci str = BigInt::ToString(thread, JSHandle<BigInt>::Cast(bigint), BigInt::BINARY); 4444514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("11111111")); 4454514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, str, JSHandle<EcmaString>(parma)), 0); 4464514f5e3Sopenharmony_ci 4474514f5e3Sopenharmony_ci // octal string 4484514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("0o123456")); 4494514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4504514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4514514f5e3Sopenharmony_ci str = BigInt::ToString(thread, JSHandle<BigInt>::Cast(bigint), BigInt::OCTAL); 4524514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("123456")); 4534514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, str, JSHandle<EcmaString>(parma)), 0); 4544514f5e3Sopenharmony_ci 4554514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("0O123456")); 4564514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4574514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4584514f5e3Sopenharmony_ci str = BigInt::ToString(thread, JSHandle<BigInt>::Cast(bigint), BigInt::OCTAL); 4594514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("123456")); 4604514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, str, JSHandle<EcmaString>(parma)), 0); 4614514f5e3Sopenharmony_ci 4624514f5e3Sopenharmony_ci // decimal string 4634514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("999999999")); 4644514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4654514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4664514f5e3Sopenharmony_ci str = BigInt::ToString(thread, JSHandle<BigInt>::Cast(bigint)); 4674514f5e3Sopenharmony_ci ASSERT_EQ(EcmaStringAccessor::Compare(instance, str, JSHandle<EcmaString>(parma)), 0); 4684514f5e3Sopenharmony_ci 4694514f5e3Sopenharmony_ci // string has space 4704514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII(" 123 ")); 4714514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4724514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4734514f5e3Sopenharmony_ci JSHandle<JSTaggedValue> number(thread, JSTaggedValue(static_cast<double>(123))); 4744514f5e3Sopenharmony_ci bool compareRes = JSTaggedValue::Equal(thread, bigint, number); 4754514f5e3Sopenharmony_ci ASSERT_TRUE(compareRes); 4764514f5e3Sopenharmony_ci 4774514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("123 ")); 4784514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4794514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4804514f5e3Sopenharmony_ci number = JSHandle<JSTaggedValue>(thread, JSTaggedValue(static_cast<double>(123))); 4814514f5e3Sopenharmony_ci compareRes = JSTaggedValue::Equal(thread, bigint, number); 4824514f5e3Sopenharmony_ci ASSERT_TRUE(compareRes); 4834514f5e3Sopenharmony_ci 4844514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII(" 123")); 4854514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4864514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4874514f5e3Sopenharmony_ci number = JSHandle<JSTaggedValue>(thread, JSTaggedValue(static_cast<double>(123))); 4884514f5e3Sopenharmony_ci compareRes = JSTaggedValue::Equal(thread, bigint, number); 4894514f5e3Sopenharmony_ci ASSERT_TRUE(compareRes); 4904514f5e3Sopenharmony_ci 4914514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII("")); 4924514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4934514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4944514f5e3Sopenharmony_ci ASSERT_TRUE(JSHandle<BigInt>::Cast(bigint)->IsZero()); 4954514f5e3Sopenharmony_ci 4964514f5e3Sopenharmony_ci parma = JSHandle<JSTaggedValue>(factory->NewFromASCII(" ")); 4974514f5e3Sopenharmony_ci bigint = JSHandle<JSTaggedValue>(thread, base::NumberHelper::StringToBigInt(thread, parma)); 4984514f5e3Sopenharmony_ci ASSERT_TRUE(bigint->IsBigInt()); 4994514f5e3Sopenharmony_ci ASSERT_TRUE(JSHandle<BigInt>::Cast(bigint)->IsZero()); 5004514f5e3Sopenharmony_ci} 5014514f5e3Sopenharmony_ci} // namespace panda::test 502