From 51f1924f196761f041970b32456af49fc5d7b1ee Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 17 Sep 2022 15:08:17 -0400 Subject: test(tvix/eval): Test StringRepr::Smol as well The From impl for NixString only generates StringRepr::Heap strings, but we want to make sure we're testing StringRepr::Smol too Change-Id: I6d04b9cf12ef8462fe2788e0c6414b165f40311d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6629 Autosubmit: grfn Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/value/string.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { - any_with::(args).prop_map(Self::from).boxed() + prop_oneof![ + // Either generate `StringRepr::Heap`... + any_with::(args).prop_map(Self::from), + // ...or generate `StringRepr::Smol` (which `impl From<&str> for NixString` returns) + any_with::(args).prop_map(|s| Self::from(s.as_str())), + ] + .boxed() } } } -- cgit 1.4.1