test(tvix/eval): impl Arbitrary for NixString
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>
This commit is contained in:
parent
84def7ef19
commit
e6fe7b1687
1 changed files with 17 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue