diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/libexpr-support/tests/libexpr.hh | 3 | ||||
-rw-r--r-- | tests/unit/libexpr/value/print.cc | 25 |
2 files changed, 12 insertions, 16 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..cdbc8f8f9 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»"); } @@ -112,10 +113,8 @@ TEST_F(ValuePrintingTests, vLambda) }; PosTable::Origin origin = state.positions.addOrigin(std::monostate(), 1); auto posIdx = state.positions.add(origin, 0); - auto body = ExprInt(0); - auto formals = Formals {}; - ExprLambda eLambda(posIdx, createSymbol("a"), &formals, &body); + ExprLambda eLambda(posIdx, createSymbol("a"), std::make_unique<Formals>(), std::make_unique<ExprInt>(0)); Value vLambda; vLambda.mkLambda(&env, &eLambda); @@ -514,14 +513,13 @@ TEST_F(ValuePrintingTests, ansiColorsDerivationError) TEST_F(ValuePrintingTests, ansiColorsAssert) { - ExprVar eFalse(state.symbols.create("false")); - eFalse.bindVars(state, state.staticBaseEnv); - ExprInt eInt(1); - - ExprAssert expr(noPos, &eFalse, &eInt); + ExprAssert expr(noPos, + std::make_unique<ExprVar>(state.symbols.create("false")), + std::make_unique<ExprInt>(1)); + expr.bindVars(state, state.staticBaseEnv); Value v; - state.mkThunk_(v, &expr); + state.mkThunk_(v, expr); test(v, ANSI_RED "«error: assertion 'false' failed»" ANSI_NORMAL, @@ -560,10 +558,8 @@ TEST_F(ValuePrintingTests, ansiColorsLambda) }; PosTable::Origin origin = state.positions.addOrigin(std::monostate(), 1); auto posIdx = state.positions.add(origin, 0); - auto body = ExprInt(0); - auto formals = Formals {}; - ExprLambda eLambda(posIdx, createSymbol("a"), &formals, &body); + ExprLambda eLambda(posIdx, createSymbol("a"), std::make_unique<Formals>(), std::make_unique<ExprInt>(0)); Value vLambda; vLambda.mkLambda(&env, &eLambda); @@ -621,7 +617,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, |