mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FIX: Bug in schema module when testing a tuple against a non tuple shape.
This commit is contained in:
parent
0e41a40ab3
commit
68e9c1c119
@ -86,7 +86,7 @@ let shaped = module {
|
||||
float = simple_handler(mod.val, mod.shape),
|
||||
bool = simple_handler(mod.val, mod.shape),
|
||||
null = simple_handler(mod.val, mod.shape),
|
||||
tuple = reduce(tuple_handler, {shape=mod.shape, ok=false}, mod.val).ok,
|
||||
tuple = (mod.shape is "tuple") && reduce(tuple_handler, {shape=mod.shape, ok=false}, mod.val).ok,
|
||||
list = select mod.shape == [], true, {
|
||||
false = reduce(list_handler, {shape=mod.shape, ok=false}, mod.val).ok,
|
||||
},
|
||||
|
@ -6,6 +6,16 @@ assert t.ok{
|
||||
desc = "1 is an int",
|
||||
};
|
||||
|
||||
assert t.not_ok{
|
||||
test = schema.any{val=1, types=[1.0, {foo="bar"}]},
|
||||
desc = "1 is not a float or a tuple with a foo string field",
|
||||
};
|
||||
|
||||
assert t.ok{
|
||||
test = schema.any{val={foo="bar"}, types=[1.0, {foo=""}]},
|
||||
desc = "1 is not a float or a tuple with a foo string field",
|
||||
};
|
||||
|
||||
assert t.not_ok{
|
||||
test = schema.any{val=1, types=[1.0, ""]},
|
||||
desc = "1 is not a float or string",
|
||||
@ -120,3 +130,8 @@ assert t.ok{
|
||||
test = schema.shaped{val={list=[1, "foo"]}, shape={list=[]}},
|
||||
desc="inner list with valid types matches empty list shape",
|
||||
};
|
||||
|
||||
assert t.not_ok{
|
||||
test = schema.shaped{val={foo="bar"}, shaped=1.0},
|
||||
desc = "a tuple is not a float",
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user