mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user