libexpr: Replace Value::mkPath with constructor calls

The pseudo-constructor `Value::mkPath` would previously be called on an
default-constructed (under-initialized) `Value` to create a properly
initialized `Value` that represents a path. This change
removes mkPath and constructs path `Value`s directly.

Change-Id: I9021de1ff59490828f9fec6866e083996a6a6964
This commit is contained in:
skye
2026-02-23 09:37:40 -05:00
parent d07bbb109e
commit e8f161ead1
6 changed files with 24 additions and 27 deletions
+1 -2
View File
@@ -61,8 +61,7 @@ namespace nix {
// C++ exception with description "error: operation 'addToStoreFromDump' is
// not supported by store 'dummy'" thrown in the test body.
TEST_F(JSONValueTest, DISABLED_Path) {
Value v;
v.mkPath("test");
Value v = {NewValueAs::path, "test"};
ASSERT_EQ(getJSONValue(v), "\"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x\"");
}
} /* namespace nix */
+2 -4
View File
@@ -45,8 +45,7 @@ TEST_F(ValuePrintingTests, tString)
TEST_F(ValuePrintingTests, tPath)
{
Value vPath;
vPath.mkPath("/foo");
Value vPath = {NewValueAs::path, "/foo"};
test(vPath, "/foo");
}
@@ -382,8 +381,7 @@ TEST_F(ValuePrintingTests, ansiColorsStringElided)
TEST_F(ValuePrintingTests, ansiColorsPath)
{
Value v;
v.mkPath(CanonPath("puppy"));
Value v = {NewValueAs::path, CanonPath("puppy")};
test(v,
ANSI_GREEN "/puppy" ANSI_NORMAL,