Complete genericClosure tests

This commit is contained in:
Guillaume Maudoux 2022-10-25 01:57:18 +02:00
parent e93bf69b44
commit d6f5734c63

View file

@ -43,16 +43,6 @@ namespace nix {
, type \
)
//TEST_F(ErrorTraceTest, genericClosure) {
//ASSERT_THROW(
//try {
//eval("builtins.genericClosure 1 1");
//} catch (BaseError & e) {
//ASSERT_EQ(PrintToString(e.info().msg), PrintToString(hintfmt("value is %s while a set was expected", "an integer")));
//throw;
//}, TypeError);
//}
TEST_F(ErrorTraceTest, genericClosure) { \
ASSERT_TRACE2("genericClosure 1",
TypeError,
@ -67,7 +57,9 @@ namespace nix {
TypeError,
hintfmt("value is %s while a list was expected", "an integer"),
hintfmt("while evaluating the 'startSet' attribute passed as argument to builtins.genericClosure"));
// Okay: "genericClosure { startSet = []; }"
ASSERT_TRACE2("genericClosure { startSet = [{ key = 1;}]; operator = true; }",
TypeError,
hintfmt("value is %s while a function was expected", "a Boolean"),
@ -91,6 +83,12 @@ namespace nix {
EvalError,
hintfmt("cannot compare %s with %s", "a string", "an integer"),
hintfmt("while comparing the `key` attributes of two genericClosure elements"));
ASSERT_TRACE2("genericClosure { startSet = [ true ]; operator = item: [{ key = ''a''; }]; }",
TypeError,
hintfmt("value is %s while a set was expected", "a Boolean"),
hintfmt("while evaluating one of the elements generated by (or initially passed to) builtins.genericClosure"));
}
} /* namespace nix */