aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-06-16 23:10:09 +0200
committereldritch horrors <pennae@lix.systems>2024-06-17 19:46:44 +0000
commitad5366c2ad43216ac9a61ccb1477ff9859d1a75c (patch)
treee986b1f0e9510641279bba164b36bae9a96be6be /tests/unit
parentb8f49a8eaf619df6d228f2e0f9814c4a5fa4aec5 (diff)
libexpr: pass Exprs as references, not pointers
almost all places where Exprs are passed as pointers expect the pointers to be non-null. pass them as references to encode this constraint in the type system as well (and also communicate that Exprs must not be freed). Change-Id: Ia98f166fec3c23151f906e13acb4a0954a5980a2
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/libexpr-support/tests/libexpr.hh3
-rw-r--r--tests/unit/libexpr/value/print.cc8
2 files changed, 6 insertions, 5 deletions
diff --git a/tests/unit/libexpr-support/tests/libexpr.hh b/tests/unit/libexpr-support/tests/libexpr.hh
index 4055784ca..b820e3fab 100644
--- a/tests/unit/libexpr-support/tests/libexpr.hh
+++ b/tests/unit/libexpr-support/tests/libexpr.hh
@@ -28,8 +28,7 @@ namespace nix {
}
Value eval(std::string input, bool forceValue = true) {
Value v;
- Expr * e = state.parseExprFromString(input, state.rootPath(CanonPath::root));
- assert(e);
+ Expr & e = state.parseExprFromString(input, state.rootPath(CanonPath::root));
state.eval(e, v);
if (forceValue)
state.forceValue(v, noPos);
diff --git a/tests/unit/libexpr/value/print.cc b/tests/unit/libexpr/value/print.cc
index d2d699a64..feabc07c1 100644
--- a/tests/unit/libexpr/value/print.cc
+++ b/tests/unit/libexpr/value/print.cc
@@ -91,7 +91,8 @@ TEST_F(ValuePrintingTests, tList)
TEST_F(ValuePrintingTests, vThunk)
{
Value vThunk;
- vThunk.mkThunk(nullptr, nullptr);
+ ExprInt e(0);
+ vThunk.mkThunk(nullptr, e);
test(vThunk, "«thunk»");
}
@@ -521,7 +522,7 @@ TEST_F(ValuePrintingTests, ansiColorsAssert)
ExprAssert expr(noPos, &eFalse, &eInt);
Value v;
- state.mkThunk_(v, &expr);
+ state.mkThunk_(v, expr);
test(v,
ANSI_RED "«error: assertion 'false' failed»" ANSI_NORMAL,
@@ -621,7 +622,8 @@ TEST_F(ValuePrintingTests, ansiColorsPrimOpApp)
TEST_F(ValuePrintingTests, ansiColorsThunk)
{
Value v;
- v.mkThunk(nullptr, nullptr);
+ ExprInt e(0);
+ v.mkThunk(nullptr, e);
test(v,
ANSI_MAGENTA "«thunk»" ANSI_NORMAL,