]>
git.proxmox.com Git - cargo.git/blob - vendor/proptest/src/arbitrary/_alloc/ops.rs
2 // Copyright 2017, 2018 The proptest developers
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 //! Arbitrary implementations for `std::ops`.
12 use crate::std_facade
::Arc
;
15 use crate::arbitrary
::*;
16 use crate::strategy
::statics
::static_map
;
17 use crate::strategy
::*;
19 arbitrary
!(RangeFull
; ..);
20 wrap_ctor
!(RangeFrom
, |a
| a
..);
21 wrap_ctor
!(RangeTo
, |a
| ..a
);
23 wrap_ctor
!(RangeToInclusive
, |a
| ..=a
);
26 [A
: PartialOrd
+ Arbitrary
] RangeInclusive
<A
>,
27 SMapped
<(A
, A
), Self>, product_type
![A
::Parameters
, A
::Parameters
];
28 args
=> static_map(any_with
::<(A
, A
)>(args
),
29 |(a
, b
)| if b
< a { b..=a }
else { a..=b }
)
32 lift1
!([PartialOrd
] RangeInclusive
<A
>; base
=> {
33 let base
= Arc
::new(base
);
34 (base
.clone(), base
).prop_map(|(a
, b
)| if b
< a { b..=a }
else { a..=b }
)
38 [A
: PartialOrd
+ Arbitrary
] Range
<A
>,
39 SMapped
<(A
, A
), Self>, product_type
![A
::Parameters
, A
::Parameters
];
40 args
=> static_map(any_with
::<(A
, A
)>(args
),
41 |(a
, b
)| if b
< a { b..a }
else { a..b }
)
44 lift1
!([PartialOrd
] Range
<A
>; base
=> {
45 let base
= Arc
::new(base
);
46 (base
.clone(), base
).prop_map(|(a
, b
)| if b
< a { b..a }
else { a..b }
)
49 #[cfg(feature = "unstable")]
51 [Y
: Arbitrary
, R
: Arbitrary
] GeneratorState
<Y
, R
>,
52 LazyTupleUnion
<(WA
<SMapped
<Y
, Self>>, WA
<SMapped
<R
, Self>>)>,
53 product_type
![Y
::Parameters
, R
::Parameters
];
55 let product_unpack
![y
, r
] = args
;
57 static_map(any_with
::<Y
>(y
), GeneratorState
::Yielded
),
58 static_map(any_with
::<R
>(r
), GeneratorState
::Complete
)
63 #[cfg(feature = "unstable")]
66 #[cfg(feature = "unstable")]
67 impl<A
: fmt
::Debug
+ '
static, B
: fmt
::Debug
+ '
static>
68 functor
::ArbitraryF2
<A
, B
> for GeneratorState
<A
, B
>
72 fn lift2_with
<AS
, BS
>(
75 _args
: Self::Parameters
,
76 ) -> BoxedStrategy
<Self>
78 AS
: Strategy
<Value
= A
> + '
static,
79 BS
: Strategy
<Value
= B
> + '
static,
82 fst
.prop_map(GeneratorState
::Yielded
),
83 snd
.prop_map(GeneratorState
::Complete
)
92 range_full
=> RangeFull
,
93 range_from
=> RangeFrom
<usize>,
94 range_to
=> RangeTo
<usize>,
95 range
=> Range
<usize>,
96 range_inclusive
=> RangeInclusive
<usize>,
97 range_to_inclusive
=> RangeToInclusive
<usize>
100 #[cfg(feature = "unstable")]
102 generator_state
=> GeneratorState
<u32, u64>