Fix TypedArray.prototype.toLocaleString when Intl is available

Summary:
Similar to Array, TypedArray should use the Intl NumberFormatter when
it is available.

Reviewed By: jpporto

Differential Revision: D37894492

fbshipit-source-id: 4ce02e5cb3b72d20e70243ddc0353d5a273018ac
This commit is contained in:
Neil Dhar 2022-07-15 22:25:39 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 42fe3572f8
Коммит 211c2d1ed5
3 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -34,6 +34,7 @@ task prepareTests() {
include("test/intl402/String/**/*.js")
include("test/intl402/Number/**/*.js")
include("test/intl402/Array/**/*.js")
include("test/intl402/TypedArray/**/*.js")
include("test/intl402/Date/**/*.js")
include("test/intl402/Intl/**/*.js")
include("test/built-ins/String/prototype/toLocale**/*.js")

Просмотреть файл

@ -53,6 +53,7 @@ public class HermesIntlTest262 extends InstrumentationTestCase {
evalScriptFromAsset(rt, "test262/harness/compareArray.js");
evalScriptFromAsset(rt, "test262/harness/dateConstants.js");
evalScriptFromAsset(rt, "test262/harness/isConstructor.js");
evalScriptFromAsset(rt, "test262/harness/testTypedArray.js");
}
public void test262Intl() throws IOException {

Просмотреть файл

@ -1632,7 +1632,12 @@ typedArrayPrototypeToLocaleString(void *, Runtime &runtime, NativeArgs args) {
}
if (auto func = Handle<Callable>::dyn_vmcast(
runtime.makeHandle(std::move(*propRes)))) {
#ifdef HERMES_ENABLE_INTL
auto callRes = Callable::executeCall2(
func, runtime, elementObj, args.getArg(0), args.getArg(1));
#else
auto callRes = Callable::executeCall0(func, runtime, elementObj);
#endif
if (LLVM_UNLIKELY(callRes == ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}