From e6fe7b1687cfb59518393a9d615ada04bee51a5e Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 17 Sep 2022 13:52:48 -0400 Subject: test(tvix/eval): impl Arbitrary for NixString Change-Id: I3fe2d410c789429493a1278d571ca8fe74c2a69d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6625 Autosubmit: grfn Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/src/value/string.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs index 058c7f87dd..9ac8869935 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 = ::Parameters; + + type Strategy = BoxedStrategy; + + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { + any_with::(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; -- cgit 1.4.1