2021-02-24 09:27:51 -05:00
|
|
|
import { complex } from "./complex.ts";
|
2021-01-29 14:45:22 -05:00
|
|
|
|
|
|
|
Deno.test("complex", function () {
|
|
|
|
complex("foo", "bar", "baz");
|
|
|
|
});
|
2022-08-12 15:21:17 -04:00
|
|
|
|
|
|
|
Deno.test("sub process with stdin", async () => {
|
|
|
|
// ensure launching deno run with stdin doesn't affect coverage
|
|
|
|
const code = "console.log('5')";
|
2024-09-04 18:45:55 -04:00
|
|
|
const command = new Deno.Command(Deno.execPath(), {
|
|
|
|
args: ["run", "-"],
|
2022-08-12 15:21:17 -04:00
|
|
|
stdin: "piped",
|
|
|
|
stdout: "piped",
|
|
|
|
});
|
2024-09-04 18:45:55 -04:00
|
|
|
await using child = command.spawn();
|
|
|
|
await ReadableStream.from([code])
|
|
|
|
.pipeThrough(new TextEncoderStream())
|
|
|
|
.pipeTo(child.stdin);
|
|
|
|
const { stdout } = await child.output();
|
|
|
|
const output = new TextDecoder().decode(stdout);
|
2022-08-12 15:21:17 -04:00
|
|
|
if (output.trim() !== "5") {
|
|
|
|
throw new Error("Failed");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-09-04 18:45:55 -04:00
|
|
|
Deno.test("sub process with deno eval", () => {
|
2022-08-12 15:21:17 -04:00
|
|
|
// ensure launching deno eval doesn't affect coverage
|
|
|
|
const code = "console.log('5')";
|
2024-09-04 18:45:55 -04:00
|
|
|
const { stdout } = new Deno.Command(Deno.execPath(), {
|
|
|
|
args: ["eval", code],
|
|
|
|
}).outputSync();
|
|
|
|
const output = new TextDecoder().decode(stdout);
|
2022-08-12 15:21:17 -04:00
|
|
|
if (output.trim() !== "5") {
|
|
|
|
throw new Error("Failed");
|
|
|
|
}
|
|
|
|
});
|