mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 11:36:03 +01:00
tests: add error tests for builtins.genericClosure
Covers error conditions for: - Invalid argument types (not an attrset) - Missing required attributes (startSet, operator) - Type mismatches (startSet/operator not correct type) - Element validation (elements not attrsets, missing key attribute) - Key comparison errors (incompatible types, uncomparable types) - Operator return value validation (not a list)
This commit is contained in:
parent
34c77ffe38
commit
ca787bc3e0
20 changed files with 141 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-element-missing-key.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [ { nokey = 1; } ];
|
||||
|
||||
… in one of the attrsets generated by (or initially passed to) builtins.genericClosure
|
||||
|
||||
error: attribute 'key' missing
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { nokey = 1; } ];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-element-not-attrset.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [ "not an attrset" ];
|
||||
|
||||
… while evaluating one of the elements generated by (or initially passed to) builtins.genericClosure
|
||||
|
||||
error: expected a set but found a string: "not an attrset"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ "not an attrset" ];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-keys-incompatible-types.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [
|
||||
|
||||
… while comparing the `key` attributes of two genericClosure elements
|
||||
|
||||
error: cannot compare a string with an integer
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [
|
||||
{ key = 1; }
|
||||
{ key = "string"; }
|
||||
];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-keys-uncomparable.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [
|
||||
|
||||
… while comparing the `key` attributes of two genericClosure elements
|
||||
|
||||
error: cannot compare a set with a set; values of that type are incomparable
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [
|
||||
{ key = { }; }
|
||||
{ key = { }; }
|
||||
];
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-missing-operator.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [ { key = 1; } ];
|
||||
|
||||
… in the attrset passed as argument to builtins.genericClosure
|
||||
|
||||
error: attribute 'operator' missing
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { key = 1; } ];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-missing-startSet.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| operator = x: [ ];
|
||||
|
||||
… in the attrset passed as argument to builtins.genericClosure
|
||||
|
||||
error: attribute 'startSet' missing
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
builtins.genericClosure {
|
||||
operator = x: [ ];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-not-attrset.nix:1:1:
|
||||
1| builtins.genericClosure "not an attrset"
|
||||
| ^
|
||||
2|
|
||||
|
||||
… while evaluating the first argument passed to builtins.genericClosure
|
||||
|
||||
error: expected a set but found a string: "not an attrset"
|
||||
|
|
@ -0,0 +1 @@
|
|||
builtins.genericClosure "not an attrset"
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-operator-not-function.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [ { key = 1; } ];
|
||||
|
||||
… while evaluating the 'operator' attribute passed as argument to builtins.genericClosure
|
||||
|
||||
error: expected a function but found a string: "not a function"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { key = 1; } ];
|
||||
operator = "not a function";
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-operator-not-list.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = [ { key = 1; } ];
|
||||
|
||||
… while evaluating the return value of the `operator` passed to builtins.genericClosure
|
||||
|
||||
error: expected a list but found a string: "not a list"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = [ { key = 1; } ];
|
||||
operator = x: "not a list";
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error:
|
||||
… while calling the 'genericClosure' builtin
|
||||
at /pwd/lang/eval-fail-genericClosure-startSet-not-list.nix:1:1:
|
||||
1| builtins.genericClosure {
|
||||
| ^
|
||||
2| startSet = "not a list";
|
||||
|
||||
… while evaluating the 'startSet' attribute passed as argument to builtins.genericClosure
|
||||
|
||||
error: expected a list but found a string: "not a list"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
builtins.genericClosure {
|
||||
startSet = "not a list";
|
||||
operator = x: [ ];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue