summaryrefslogtreecommitdiff
path: root/tests/type-consistency/spec/tostring.ts
blob: 4fcb8037a2b395624eb65901171e59fe7e340499 (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
38
39
40
41
import path from "path";
import { createTestHarness } from "../harness";

export default createTestHarness({
  harnessName: "ToString",
  generatedPath: path.join(__dirname, "..", "generated"),
})
  .createFunctionTest({
    name: "Passes through strings literally",
    program: "fn(x, tostring(x))",
    cases: [
      { input: "hello", output: "hello" },
      { input: "1", output: "1" },
      { input: "[1,2,3]", output: "[1,2,3]" },
    ],
  })
  .createFunctionTest({
    name: "Is idempotent",
    program: "fn(x, tostring(tostring(x)))",
    cases: [
      { input: "hello", output: "hello" },
      { input: "1", output: "1" },
      { input: "[1,2,3]", output: "[1,2,3]" },
    ],
  })
  .createFunctionTest({
    name: "Handles primitives",
    program: "fn(x, tostring(x))",
    cases: [
      { input: 5, output: "5" },
      { input: true, output: "true" },
    ],
  })
  .createFunctionTest({
    name: "Handles arrays and nested arrays",
    program: "fn(x, tostring(x))",
    cases: [
      { input: [1, 2, 3], output: "[1, 2, 3]" },
      { input: [1, 2, [3, 4, 5]], output: "[1, 2, [3, 4, 5]]" },
    ],
  });