mirror of
https://github.com/NixOS/nix
synced 2025-07-02 13:31:48 +02:00
Here we're switching to combinators instead of dereference operator. It turns out the dereference operator was being executed upon test setup, meaning that we were only using a only single value for each of the executions of the property tests! Really not good. And on Windows, we instead get: operator* is not allowed in this contextff6af6fc68/src/gen/detail/GenerationHandler.cpp (L16C31-L16C71)
Now a few of the property tests fail, because we're generating cases which haven't been exercised before. (cherry picked from commit9a04f1e732
)
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#include <rapidcheck.h>
|
|
|
|
#include "tests/path.hh"
|
|
#include "tests/value/context.hh"
|
|
|
|
namespace rc {
|
|
using namespace nix;
|
|
|
|
Gen<NixStringContextElem::DrvDeep> Arbitrary<NixStringContextElem::DrvDeep>::arbitrary()
|
|
{
|
|
return gen::map(gen::arbitrary<StorePath>(), [](StorePath drvPath) {
|
|
return NixStringContextElem::DrvDeep{
|
|
.drvPath = drvPath,
|
|
};
|
|
});
|
|
}
|
|
|
|
Gen<NixStringContextElem> Arbitrary<NixStringContextElem>::arbitrary()
|
|
{
|
|
return gen::mapcat(
|
|
gen::inRange<uint8_t>(0, std::variant_size_v<NixStringContextElem::Raw>),
|
|
[](uint8_t n) -> Gen<NixStringContextElem> {
|
|
switch (n) {
|
|
case 0:
|
|
return gen::map(
|
|
gen::arbitrary<NixStringContextElem::Opaque>(), [](NixStringContextElem a) { return a; });
|
|
case 1:
|
|
return gen::map(
|
|
gen::arbitrary<NixStringContextElem::DrvDeep>(), [](NixStringContextElem a) { return a; });
|
|
case 2:
|
|
return gen::map(
|
|
gen::arbitrary<NixStringContextElem::Built>(), [](NixStringContextElem a) { return a; });
|
|
default:
|
|
assert(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|