diff options
Diffstat (limited to 'tests')
| -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"]] }, + ], }); |
