diff options
Diffstat (limited to 'tvix/eval/src/value/string.rs')
-rw-r--r-- | tvix/eval/src/value/string.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs index 9ac8869935f2..20564653433d 100644 --- a/tvix/eval/src/value/string.rs +++ b/tvix/eval/src/value/string.rs @@ -62,6 +62,7 @@ impl Hash for NixString { mod arbitrary { use super::*; use proptest::prelude::{any_with, Arbitrary}; + use proptest::prop_oneof; use proptest::strategy::{BoxedStrategy, Strategy}; impl Arbitrary for NixString { @@ -70,7 +71,13 @@ mod arbitrary { type Strategy = BoxedStrategy<Self>; fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { - any_with::<String>(args).prop_map(Self::from).boxed() + prop_oneof![ + // Either generate `StringRepr::Heap`... + any_with::<String>(args).prop_map(Self::from), + // ...or generate `StringRepr::Smol` (which `impl From<&str> for NixString` returns) + any_with::<String>(args).prop_map(|s| Self::from(s.as_str())), + ] + .boxed() } } } |