aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-30 00:19:39 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-30 00:19:39 -0700
commitf24ca3900400bb41faefb42f426651d5d7e7c2e6 (patch)
tree1d75dcbd5921a66b2bbbc4d685ddca01e3196ae0 /test
parente3dc5b6b4ce2c10d1e9c61fec2e86409e4ce48b0 (diff)
downloadbun-f24ca3900400bb41faefb42f426651d5d7e7c2e6.tar.gz
bun-f24ca3900400bb41faefb42f426651d5d7e7c2e6.tar.zst
bun-f24ca3900400bb41faefb42f426651d5d7e7c2e6.zip
Fix bug in `util/types`.{isGeneratorFunction,isAsyncFunction}
Diffstat (limited to 'test')
-rw-r--r--test/js/node/util/test-util-types.test.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/js/node/util/test-util-types.test.js b/test/js/node/util/test-util-types.test.js
index a75b9eac0..cb8fa594a 100644
--- a/test/js/node/util/test-util-types.test.js
+++ b/test/js/node/util/test-util-types.test.js
@@ -24,9 +24,8 @@ for (const [value, _method] of [
[Object(BigInt(0)), "isBigIntObject"],
[new Error(), "isNativeError"],
[new RegExp()],
- [async function () {}, "isAsyncFunction"],
- [function* () {}, "isGeneratorFunction"],
[(function* () {})(), "isGeneratorObject"],
+ [(async function* () {})(), "isGeneratorObject"],
[Promise.resolve()],
[new Map()],
[new Set()],
@@ -248,3 +247,22 @@ test("isBoxedPrimitive", () => {
}
}
// */
+
+test("isAsyncFunction", () => {
+ for (let fn of [async function asyncFn() {}, async function* asyncGeneratorFn() {}]) {
+ expect(types.isAsyncFunction(fn)).toBeTrue();
+ }
+
+ for (let fn of [function normal() {}, function* generatorFn() {}]) {
+ expect(types.isAsyncFunction(fn)).toBeFalse();
+ }
+});
+test("isGeneratorFunction", () => {
+ for (let fn of [function* generator() {}, async function* asyncGenerator() {}]) {
+ expect(types.isGeneratorFunction(fn)).toBeTrue();
+ }
+
+ for (let fn of [function normal() {}, async function asyncFn() {}]) {
+ expect(types.isGeneratorFunction(fn)).toBeFalse();
+ }
+});