summaryrefslogtreecommitdiff
path: root/cli/tests/unit/timers_test.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-09-04 23:05:06 +0200
committerGitHub <noreply@github.com>2023-09-04 17:05:06 -0400
commit9e243d22f4ea9642e24415e5484f0f067f466ef5 (patch)
treef58d35fc9ac4e9fb72e14f5dab054a353b817836 /cli/tests/unit/timers_test.ts
parent2cc7c8432fc74b734e9d2b0c34c6a9ab434e5781 (diff)
Revert "refactor: rewrite ops that use 'deferred' to use 'op2(async(lazy))' (#20303) (#20370)
This reverts commit https://github.com/denoland/deno/commit/83426be6eead06c680ae527468aeaf8723543ff2. Includes a regression test.
Diffstat (limited to 'cli/tests/unit/timers_test.ts')
-rw-r--r--cli/tests/unit/timers_test.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/tests/unit/timers_test.ts b/cli/tests/unit/timers_test.ts
index 5c076ad09..6dedb04ed 100644
--- a/cli/tests/unit/timers_test.ts
+++ b/cli/tests/unit/timers_test.ts
@@ -756,3 +756,20 @@ Deno.test({
assertEquals(timeoutsFired.length, 300);
},
});
+
+// Regression test for https://github.com/denoland/deno/issues/20367
+Deno.test({
+ name: "regression for #20367",
+ fn: async () => {
+ const promise = deferred<number>();
+ const start = performance.now();
+ setTimeout(() => {
+ const end = performance.now();
+ promise.resolve(end - start);
+ }, 1000);
+ clearTimeout(setTimeout(() => {}, 1000));
+
+ const result = await promise;
+ assert(result >= 1000);
+ },
+});