From d6f5734c630f893e8695bd37ca2b0dbf2bb24daa Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Tue, 25 Oct 2022 01:57:18 +0200 Subject: [PATCH] Complete genericClosure tests --- src/libexpr/tests/error_traces.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libexpr/tests/error_traces.cc b/src/libexpr/tests/error_traces.cc index 6905dd561..8741ecdd2 100644 --- a/src/libexpr/tests/error_traces.cc +++ b/src/libexpr/tests/error_traces.cc @@ -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 */