From a38a1739e618f3e5755ba4784319536600f7f3c7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 3 Apr 2024 11:10:06 +0200 Subject: [PATCH] fix(shell-evaluator): fix exposed asyncRewrite fn for benchmarks (#1922) Painfully obvious bug in 0491491ce96b :) Renamed the benchmark test and fixed it to account for the (now very) different performance measurements after the fix. --- packages/cli-repl/src/smoke-tests.ts | 4 ++-- packages/shell-evaluator/src/shell-evaluator.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cli-repl/src/smoke-tests.ts b/packages/cli-repl/src/smoke-tests.ts index afe24638b..2d2938ad3 100644 --- a/packages/cli-repl/src/smoke-tests.ts +++ b/packages/cli-repl/src/smoke-tests.ts @@ -176,9 +176,9 @@ export async function runSmokeTests({ perfTestIterations: 0, }, { - name: 'async_rewrite', + name: 'async_rewrite_foreach', input: - 'for (let i = 0; i < 100; i++) __asyncRewrite(String([].forEach)); print("done")', + 'for (let i = 0; i < 100; i++) __asyncRewrite(String([].forEach).replace("function", "function forEach")); print("done")', output: /done/, includeStderr: false, testArgs: ['--exposeAsyncRewriter', '--nodb'], diff --git a/packages/shell-evaluator/src/shell-evaluator.ts b/packages/shell-evaluator/src/shell-evaluator.ts index 4bb479c98..75ac1966a 100644 --- a/packages/shell-evaluator/src/shell-evaluator.ts +++ b/packages/shell-evaluator/src/shell-evaluator.ts @@ -93,7 +93,8 @@ class ShellEvaluator { } if (this.exposeAsyncRewriter) { - (context as any).__asyncRewrite = () => this.asyncWriter.process(input); + (context as any).__asyncRewrite = (rewriteInput: string) => + this.asyncWriter.process(rewriteInput); } this.markTime?.(TimingCategories.AsyncRewrite, 'start async rewrite');