This commit is contained in:
190n
2025-07-11 15:23:29 -07:00
committed by Meghan Denny
parent a872dca136
commit ad0a83b63c
3 changed files with 19 additions and 5 deletions

View File

@@ -181,7 +181,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsAsyncFunction,
GET_FIRST_VALUE
auto* function = jsDynamicCast<JSFunction*>(value);
if (!function)
if (!function || function->isHostFunction())
return JSValue::encode(jsBoolean(false));
auto* executable = function->jsExecutable();
@@ -207,7 +207,7 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsGeneratorFunction,
{
GET_FIRST_VALUE
auto* function = jsDynamicCast<JSFunction*>(value);
if (!function)
if (!function || function->isHostFunction())
return JSValue::encode(jsBoolean(false));
auto* executable = function->jsExecutable();

View File

@@ -253,7 +253,14 @@ test("isAsyncFunction", () => {
expect(types.isAsyncFunction(fn)).toBeTrue();
}
for (let fn of [function normal() {}, function* generatorFn() {}]) {
for (let fn of [
function normal() {},
function* generatorFn() {},
function bound() {}.bind(),
Bun.sleep, // host function
Promise.resolve, // builtin function
async function asyncBound() {}.bind(), // node also returns false
]) {
expect(types.isAsyncFunction(fn)).toBeFalse();
}
});
@@ -262,7 +269,15 @@ test("isGeneratorFunction", () => {
expect(types.isGeneratorFunction(fn)).toBeTrue();
}
for (let fn of [function normal() {}, async function asyncFn() {}]) {
for (let fn of [
function normal() {},
async function asyncFn() {},
function bound() {}.bind(),
Bun.sleep, // host function
Promise.resolve, // builtin function
function* boundGenerator() {}.bind(), // node also returns false
async function* boundAsyncGenerator() {}.bind(), // node also returns false
]) {
expect(types.isGeneratorFunction(fn)).toBeFalse();
}
});

View File

@@ -371,7 +371,6 @@ test/js/node/util/custom-inspect.test.js
test/js/node/util/mime-api.test.ts
test/js/node/util/node-inspect-tests/parallel/util-inspect.test.js
test/js/node/util/parse_args/default-args.test.mjs
test/js/node/util/test-util-types.test.js
test/js/node/util/util-callbackify.test.js
test/js/node/util/util-promisify.test.js
test/js/node/util/util.test.js