mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
29 lines
564 B
Plaintext
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",
|
|
}; |