mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
modules/test: allow specifying expectation value type
This commit is contained in:
parent
c2e172b0d3
commit
24e3b11b23
1 changed files with 17 additions and 1 deletions
|
@ -39,7 +39,14 @@ let
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
value = lib.mkOption {
|
value = lib.mkOption {
|
||||||
type = lib.types.anything;
|
type =
|
||||||
|
if config.expect == null then
|
||||||
|
lib.types.unspecified
|
||||||
|
// {
|
||||||
|
description = "defined by `expect`";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
namedPredicate.valueType;
|
||||||
description = ''
|
description = ''
|
||||||
If defined, will be used together with `expect` to define `predicate`.
|
If defined, will be used together with `expect` to define `predicate`.
|
||||||
'';
|
'';
|
||||||
|
@ -137,6 +144,12 @@ in
|
||||||
Expectation message supplier, matching `(value) -> String` or `(value) -> [(message)] -> String`.
|
Expectation message supplier, matching `(value) -> String` or `(value) -> [(message)] -> String`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
valueType = lib.mkOption {
|
||||||
|
type = lib.types.optionType;
|
||||||
|
description = ''
|
||||||
|
The type to use for `value` when this expectation is used.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -196,14 +209,17 @@ in
|
||||||
count = {
|
count = {
|
||||||
predicate = v: l: builtins.length l == v;
|
predicate = v: l: builtins.length l == v;
|
||||||
message = v: l: "Expected length to be ${toString v} but found ${toString (builtins.length l)}.";
|
message = v: l: "Expected length to be ${toString v} but found ${toString (builtins.length l)}.";
|
||||||
|
valueType = lib.types.ints.unsigned;
|
||||||
};
|
};
|
||||||
any = {
|
any = {
|
||||||
predicate = v: builtins.any (lib.hasInfix v);
|
predicate = v: builtins.any (lib.hasInfix v);
|
||||||
message = v: "Expected ${lib.toJSON v} infix to be present.";
|
message = v: "Expected ${lib.toJSON v} infix to be present.";
|
||||||
|
valueType = lib.types.str;
|
||||||
};
|
};
|
||||||
anyExact = {
|
anyExact = {
|
||||||
predicate = builtins.elem;
|
predicate = builtins.elem;
|
||||||
message = v: "Expected ${lib.toJSON v} to be present.";
|
message = v: "Expected ${lib.toJSON v} to be present.";
|
||||||
|
valueType = lib.types.str;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue