File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ mod property_test;
35
35
/// of setting up the test harness and generating input values, allowing the user to focus
36
36
/// on writing the test logic.
37
37
///
38
- /// # Attributes
38
+ /// ## Attributes
39
39
///
40
40
/// The `property_test` macro can take an optional `config` attribute, which allows you to
41
41
/// customize the configuration of the `proptest` runner.
@@ -48,6 +48,22 @@ mod property_test;
48
48
/// assert_eq!(x, x);
49
49
/// }
50
50
/// ```
51
+ ///
52
+ /// ## Custom strategies
53
+ ///
54
+ /// By default, [`property_test`] will use the `Arbitrary` impl for parameters. However, you can
55
+ /// provide a custom `Strategy` with `#[strategy = <expr>]` on an argument:
56
+ ///
57
+ /// ```
58
+ /// #[property_test]
59
+ /// fn foo(#[strategy = "[0-9]*"] s: String) {
60
+ /// for c in s.chars() {
61
+ /// assert!(c.is_numeric());
62
+ /// }
63
+ /// }
64
+ /// ```
65
+ /// Multiple `#[strategy = <expr>]` attributes on an argument are not allowed.
66
+ ///
51
67
#[ proc_macro_attribute]
52
68
pub fn property_test ( attr : TokenStream , item : TokenStream ) -> TokenStream {
53
69
property_test:: property_test ( attr. into ( ) , item. into ( ) ) . into ( )
You can’t perform that action at this time.
0 commit comments