ucg/std/tests/functional_test.ucg

29 lines
564 B
Plaintext

let t = import "std/testing.ucg".asserts{};
let f = import "std/functional.ucg";
let op = func (arg) => arg{foo="bar"};
assert t.equal{
left = f.maybe{val=NULL}.do(op).unwrap(),
right = NULL,
};
assert t.ok{
test = f.maybe{val=NULL}.is_null(),
desc = "maybe is null",
};
assert t.ok{
test = f.maybe{val=NULL}.do(op).is_null(),
desc = "maybe is still null after an operation",
};
assert t.equal{
left = f.maybe{val={}}.do(op).unwrap(),
right = {foo="bar"},
};
assert t.equal{
left = f.identity("foo"),
right = "foo",
};