summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/coverage/complex_test.ts
blob: 1202289cb51a0d3a14afcc674d51c0f9ba933bb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { complex } from "./complex.ts";

Deno.test("complex", function () {
  complex("foo", "bar", "baz");
});

Deno.test("sub process with stdin", async () => {
  // ensure launching deno run with stdin doesn't affect coverage
  const code = "console.log('5')";
  const p = await Deno.run({
    cmd: [Deno.execPath(), "run", "-"],
    stdin: "piped",
    stdout: "piped",
  });
  const encoder = new TextEncoder();
  await p.stdin.write(encoder.encode(code));
  await p.stdin.close();
  const output = new TextDecoder().decode(await p.output());
  p.close();
  if (output.trim() !== "5") {
    throw new Error("Failed");
  }
});

Deno.test("sub process with deno eval", async () => {
  // ensure launching deno eval doesn't affect coverage
  const code = "console.log('5')";
  const p = await Deno.run({
    cmd: [Deno.execPath(), "eval", code],
    stdout: "piped",
  });
  const output = new TextDecoder().decode(await p.output());
  p.close();
  if (output.trim() !== "5") {
    throw new Error("Failed");
  }
});