summaryrefslogtreecommitdiff
path: root/tests/type-consistency/spec/function.ts
blob: ffd069d3bb685674d5b7474d9affe7c4d778c571 (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
import path from "path";
import { createTestHarness } from "../harness";

export default createTestHarness({
  harnessName: "Function",
  generatedPath: path.join(__dirname, "..", "generated"),
})
  .createFunctionTest({
    name: "f(x) = x",
    program: "fn(x, x)",
    cases: [
      { input: "hello", output: "hello" },
      { input: 1, output: 1 },
      { input: [1, 2, 3], output: [1, 2, 3] },
      { input: true, output: true },
    ],
  })
  .createFunctionTest({
    name: "f(x) = x + 5",
    program: "fn(x, add(x,5))",
    cases: [
      { input: 0, output: 5 },
      { input: 5, output: 10 },
      { input: 500, output: 505 },
    ],
  });