squiggle/packages/squiggle-lang/__tests__/E/A_test.res

22 lines
555 B
Plaintext
Raw Normal View History

2022-08-31 02:31:32 +00:00
open Jest
open TestHelpers
2022-09-01 02:56:12 +00:00
describe("E.A.getByFmap", () => {
makeTest("Empty list returns None", E.A.getByFmap([], x => x + 1, x => mod(x, 2) == 0), None)
2022-08-31 02:31:32 +00:00
makeTest(
"Never predicate returns None",
2022-09-01 02:56:12 +00:00
E.A.getByFmap([1, 2, 3, 4, 5, 6], x => x + 1, _ => false),
2022-08-31 02:31:32 +00:00
None,
)
makeTest(
"function evaluates",
2022-09-01 02:56:12 +00:00
E.A.getByFmap([1, 1, 1, 1, 1, 1, 1, 2, 1, 1], x => 3 * x, x => x > 4),
2022-08-31 02:31:32 +00:00
Some(6),
)
makeTest(
"always predicate returns fn(fst(a))",
2022-09-01 02:56:12 +00:00
E.A.getByFmap([0, 1, 2, 3, 4, 5, 6], x => 10 + x, _ => true),
2022-08-31 02:31:32 +00:00
Some(10),
)
})