summaryrefslogtreecommitdiff
path: root/tests/type-consistency/spec
diff options
context:
space:
mode:
Diffstat (limited to 'tests/type-consistency/spec')
-rw-r--r--tests/type-consistency/spec/array.ts17
-rw-r--r--tests/type-consistency/spec/function.ts26
-rw-r--r--tests/type-consistency/spec/index.ts4
3 files changed, 47 insertions, 0 deletions
diff --git a/tests/type-consistency/spec/array.ts b/tests/type-consistency/spec/array.ts
new file mode 100644
index 0000000..778a49f
--- /dev/null
+++ b/tests/type-consistency/spec/array.ts
@@ -0,0 +1,17 @@
+import path from "path";
+import { createTestHarness } from "../harness";
+
+export default createTestHarness({
+ harnessName: "Array",
+ generatedPath: path.join(__dirname, "..", "generated"),
+})
+ .createProgramTest({
+ name: "Number array",
+ program: "arr(1,2,3)",
+ expected: [[1, 2, 3]],
+ })
+ .createProgramTest({
+ name: "String array",
+ program: `arr("1","2","3")`,
+ expected: [["1", "2", "3"]],
+ });
diff --git a/tests/type-consistency/spec/function.ts b/tests/type-consistency/spec/function.ts
new file mode 100644
index 0000000..ffd069d
--- /dev/null
+++ b/tests/type-consistency/spec/function.ts
@@ -0,0 +1,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 },
+ ],
+ });
diff --git a/tests/type-consistency/spec/index.ts b/tests/type-consistency/spec/index.ts
new file mode 100644
index 0000000..9ef825f
--- /dev/null
+++ b/tests/type-consistency/spec/index.ts
@@ -0,0 +1,4 @@
+import array from "./array";
+import functions from "./function";
+
+export default [array, functions];