fix bug for UnwrapNumberFormatUseOrdinaryHasInstance.js

Signed-off-by: liujia178 <liujia178@huawei.com>
This commit is contained in:
liujia178 2024-04-15 17:18:43 +08:00
parent 72addd1a02
commit 51d07b319e
3 changed files with 10 additions and 9 deletions

View File

@ -66,14 +66,16 @@ JSTaggedValue BuiltinsNumberFormat::NumberFormatConstructor(EcmaRuntimeCallInfo
// a. Perform ? DefinePropertyOrThrow(this, %Intl%.[[FallbackSymbol]], PropertyDescriptor{
// [[Value]]: numberFormat, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }).
// b. Return this.
bool isInstanceOf = JSObject::InstanceOf(thread, thisValue, env->GetNumberFormatFunction());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (newTarget->IsUndefined() && thisValue->IsJSObject() && isInstanceOf) {
PropertyDescriptor descriptor(thread, JSHandle<JSTaggedValue>::Cast(numberFormat), false, false, false);
JSHandle<JSTaggedValue> key(thread, JSHandle<JSIntl>::Cast(env->GetIntlFunction())->GetFallbackSymbol());
JSTaggedValue::DefinePropertyOrThrow(thread, thisValue, key, descriptor);
if (newTarget->IsUndefined() && thisValue->IsJSObject()) {
bool isInstanceOf = JSObject::InstanceOf(thread, thisValue, env->GetNumberFormatFunction());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
return thisValue.GetTaggedValue();
if (isInstanceOf) {
PropertyDescriptor descriptor(thread, JSHandle<JSTaggedValue>::Cast(numberFormat), false, false, false);
JSHandle<JSTaggedValue> key(thread, JSHandle<JSIntl>::Cast(env->GetIntlFunction())->GetFallbackSymbol());
JSTaggedValue::DefinePropertyOrThrow(thread, thisValue, key, descriptor);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
return thisValue.GetTaggedValue();
}
}
// 6. Return numberFormat.

View File

@ -877,7 +877,7 @@ JSHandle<JSTaggedValue> JSNumberFormat::UnwrapNumberFormat(JSThread *thread, con
// 2. If nf does not have an [[InitializedNumberFormat]] internal slot and ?
// InstanceofOperator(nf, %NumberFormat%) is true, then Let nf be ? Get(nf, %Intl%.[[FallbackSymbol]]).
JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
bool hasInstance = JSObject::InstanceOf(thread, nf, env->GetNumberFormatFunction());
bool hasInstance = JSFunction::OrdinaryHasInstance(thread, env->GetNumberFormatFunction(), nf);
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSHandle<JSTaggedValue>(thread, JSTaggedValue::Undefined()));
bool isJSNumberFormat = nf->IsJSNumberFormat();

View File

@ -1663,7 +1663,6 @@
"intl/number-format/rounding-increment-v3.js",
"intl/number-format/format-range-string.js",
"intl/number-format/format-string.js",
"intl/number-format/UnwrapNumberFormatUseOrdinaryHasInstance.js",
"intl/number-format/rounding-increment-resolved-match-v3.js",
"intl/number-format/format-range-numbering-system.js",
"intl/number-format/check-digit-ranges.js",