From 230277b86f55c168c4cc7c6f5a94e7b894c0dc14 Mon Sep 17 00:00:00 2001 From: Lily Skye Date: Thu, 23 Nov 2023 12:31:40 -0700 Subject: [PATCH] add test for the repl (would have caught gc bug fixed in previous commit) --- src/targets/repl.test.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/targets/repl.test.ts diff --git a/src/targets/repl.test.ts b/src/targets/repl.test.ts new file mode 100644 index 0000000..76c58bf --- /dev/null +++ b/src/targets/repl.test.ts @@ -0,0 +1,32 @@ +import { spawn } from "first-base"; +import { binaryPath } from "../test-helpers"; +import { sleep } from "a-mimir"; + +describe("repl", () => { + test("basic run", async () => { + const run = spawn(binaryPath); + await run.outputContains("> "); + run.write("2 + 2\n"); + await run.outputContains("4"); + // TODO: it's annoying that you have to hit Ctrl+C more than once + { + run.kill("SIGINT"); + await sleep.async(10); + run.kill("SIGINT"); + } + await run.completion; + expect(run.result).toMatchInlineSnapshot(` + { + "code": 0, + "error": false, + "stderr": "", + "stdout": "> 2 + 2 + 4 + > + (Press Ctrl-C again to quit) + > + ", + } + `); + }); +});