test(tvix/eval): Test StringRepr::Smol as well
The From<String> 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 <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
This commit is contained in:
parent
e6fe7b1687
commit
51f1924f19
1 changed files with 8 additions and 1 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue