mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
Nesting was unnecessary and added 0 or negative value. So I removed the nesting.
41 lines
884 B
Plaintext
41 lines
884 B
Plaintext
let tpl = import "std/tuples.ucg";
|
|
let t = (import "std/testing.ucg");
|
|
|
|
assert t.equal{
|
|
left = tpl.fields{tpl={foo=1, bar=2}},
|
|
right = ["foo", "bar"],
|
|
};
|
|
|
|
assert t.equal{
|
|
left = tpl.values{tpl={foo=1, bar=2}},
|
|
right = [1, 2],
|
|
};
|
|
|
|
assert t.equal{
|
|
left = tpl.iter{tpl={foo=1, bar=2}},
|
|
right = [["foo", 1], ["bar", 2]],
|
|
};
|
|
|
|
assert t.equal{
|
|
left = tpl.strip_nulls{tpl={foo="bar", bar=NULL}},
|
|
right = {foo="bar"},
|
|
};
|
|
|
|
assert t.ok{
|
|
test = tpl.has_fields{tpl={foo=1, bar=2}, fields=["foo", "bar"]},
|
|
desc = "tuple has fields has foo and bar fields",
|
|
};
|
|
|
|
assert t.not_ok{
|
|
test = tpl.has_fields{tpl={blah=1, bar=2}, fields=["foo", "bar"]},
|
|
desc = "tuple does not have fields foo and bar",
|
|
};
|
|
|
|
assert t.ok{
|
|
test = tpl.field_type{
|
|
tpl={foo=1},
|
|
field="foo",
|
|
type="int",
|
|
},
|
|
desc = "tuple has field of type int",
|
|
}; |