From 39a9cd4eb9c5fe3829160d39536877c61d5b267a Mon Sep 17 00:00:00 2001 From: Quinn Dougherty Date: Wed, 31 Aug 2022 10:31:32 +0800 Subject: [PATCH] a few unit tests --- packages/squiggle-lang/__tests__/E/A_test.res | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/squiggle-lang/__tests__/E/A_test.res diff --git a/packages/squiggle-lang/__tests__/E/A_test.res b/packages/squiggle-lang/__tests__/E/A_test.res new file mode 100644 index 00000000..c40dba7f --- /dev/null +++ b/packages/squiggle-lang/__tests__/E/A_test.res @@ -0,0 +1,21 @@ +open Jest +open TestHelpers + +describe("E.A.getByWithFn", () => { + makeTest("Empty list returns None", E.A.getByWithFn([], x => x + 1, x => mod(x, 2) == 0), None) + makeTest( + "Never predicate returns None", + E.A.getByWithFn([1, 2, 3, 4, 5, 6], x => x + 1, _ => false), + None, + ) + makeTest( + "function evaluates", + E.A.getByWithFn([1, 1, 1, 1, 1, 1, 1, 2, 1, 1], x => 3 * x, x => x > 4), + Some(6), + ) + makeTest( + "always predicate returns fn(fst(a))", + E.A.getByWithFn([0, 1, 2, 3, 4, 5, 6], x => 10 + x, _ => true), + Some(10), + ) +})