diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2025-11-09 21:52:06 -0800 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2025-11-09 21:52:06 -0800 |
| commit | 190f85ff1ac23f952a7b4960638fee79495e249a (patch) | |
| tree | bb7616b31ea6ab0ef20e1b59536762d71ffbb2ae /tests/type-consistency/spec | |
| parent | 413eaa284e164143c5416cdce5a1de0f9f992409 (diff) | |
Diffstat (limited to 'tests/type-consistency/spec')
| -rw-r--r-- | tests/type-consistency/spec/index.ts | 4 | ||||
| -rw-r--r-- | tests/type-consistency/spec/mapReduceFilter.ts (renamed from tests/type-consistency/spec/mapReduce.ts) | 19 |
2 files changed, 21 insertions, 2 deletions
diff --git a/tests/type-consistency/spec/index.ts b/tests/type-consistency/spec/index.ts index 780c20c..c9b8c7a 100644 --- a/tests/type-consistency/spec/index.ts +++ b/tests/type-consistency/spec/index.ts @@ -2,7 +2,7 @@ import array from "./array"; import functions from "./function"; import types from "./types"; import tostring from "./tostring"; -import mapreduce from "./mapReduce"; +import mapreducefilter from "./mapReduceFilter"; import recursion from "./recursion"; -export default [array, functions, types, tostring, mapreduce, recursion]; +export default [array, functions, types, tostring, mapreducefilter, recursion]; diff --git a/tests/type-consistency/spec/mapReduce.ts b/tests/type-consistency/spec/mapReduceFilter.ts index b5077ff..4594e71 100644 --- a/tests/type-consistency/spec/mapReduce.ts +++ b/tests/type-consistency/spec/mapReduceFilter.ts @@ -31,4 +31,23 @@ export default createTestHarness({ { input: [], output: 0 }, { input: [50, 10, 0], output: 10 }, ], + }) + .createFunctionTest({ + name: "Filter: remove 0s", + program: "fn(a, filter(a, fn(n, ?(eq(n, 0), false, true))))", + cases: [ + { input: [1, 2, 3], output: [1, 2, 3] }, + { input: [1, 0, 10], output: [1, 10] }, + { input: [0, 0, 0], output: [] }, + { input: [0, 0, 3, 0, 5, 0, 7, 0], output: [3, 5, 7] }, + ], + }) + .createFunctionTest({ + name: "Filter: remove first element", + program: "fn(a, filter(a, fn(n, idx, ?(eq(idx, 0), false, true))))", + cases: [ + { input: [true, true, false], output: [true, false] }, + { input: [1, 0, 10], output: [0, 10] }, + { input: ["hi", ["test", "test2"]], output: [["test", "test2"]] }, + ], }); |
