diff options
author | Griffin Smith <root@gws.fyi> | 2022-09-17T17·52-0400 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2022-09-17T19·04+0000 |
commit | e6fe7b1687cfb59518393a9d615ada04bee51a5e (patch) | |
tree | e6516a70e61e652a17fa04ab2c0a29f1e0158b4d /tvix | |
parent | 84def7ef19a04b01fee6f06a1147e9ff9c3454fb (diff) |
test(tvix/eval): impl Arbitrary for NixString r/4892
Change-Id: I3fe2d410c789429493a1278d571ca8fe74c2a69d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6625 Autosubmit: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/eval/src/value/string.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs index 058c7f87dda8..9ac8869935f2 100644 --- a/tvix/eval/src/value/string.rs +++ b/tvix/eval/src/value/string.rs @@ -58,6 +58,23 @@ impl Hash for NixString { } } +#[cfg(feature = "arbitrary")] +mod arbitrary { + use super::*; + use proptest::prelude::{any_with, Arbitrary}; + use proptest::strategy::{BoxedStrategy, Strategy}; + + impl Arbitrary for NixString { + type Parameters = <String as Arbitrary>::Parameters; + + type Strategy = BoxedStrategy<Self>; + + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { + any_with::<String>(args).prop_map(Self::from).boxed() + } + } +} + impl NixString { pub const NAME: Self = NixString(StringRepr::Smol(SmolStr::new_inline("name"))); pub const NAME_REF: &'static Self = &Self::NAME; |