ucg/std/tests/functional_test.ucg
Jeremy Wall 1b2aa4dfd1 REFACTOR: testing module cleanup.
Nesting was unnecessary and added 0 or negative value. So I removed
the nesting.
2019-04-09 20:43:42 -05:00

39 lines
751 B
Plaintext

let t = import "std/testing.ucg";
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=NULL}.or(func() => "foo").unwrap(),
right = "foo",
};
assert t.equal{
left = f.maybe{val="bar"}.or(func() => "foo").unwrap(),
right = "bar",
};
assert t.equal{
left = f.maybe{val={}}.do(op).unwrap(),
right = {foo="bar"},
};
assert t.equal{
left = f.identity("foo"),
right = "foo",
};