1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use TokenStream;
/// The `property_test` procedural macro simplifies the creation of property-based tests
/// using the `proptest` crate. This macro provides a more concise syntax for writing tests
/// that automatically generate test cases based on properties.
///
/// # Example
///
/// Using the `property_test` macro:
///
/// ```
/// # use proptest_macro::property_test;
/// #[property_test]
/// fn foo(x: i32) {
/// assert_eq!(x, x);
/// }
/// ```
///
/// is roughly equivalent to:
///
/// ```ignore
/// proptest! {
/// #[test]
/// fn foo(x in any::<i32>()) {
/// assert_eq!(x, x);
/// }
/// }
/// ```
///
/// # Details
///
/// The `property_test` macro is used to define property-based tests, where the parameters
/// of the test function are automatically generated by `proptest`. The macro takes care
/// of setting up the test harness and generating input values, allowing the user to focus
/// on writing the test logic.
///
/// ## Attributes
///
/// The `property_test` macro can take an optional `config` attribute, which allows you to
/// customize the configuration of the `proptest` runner.
///
/// E.g. running 100 cases:
///
/// ```rust,ignore
/// #[property_test(config = "ProptestConfig { cases: 100, .. ProptestConfig::default() }")]
/// fn foo(x: i32) {
/// assert_eq!(x, x);
/// }
/// ```
///
/// ## Custom strategies
///
/// By default, [`property_test`] will use the `Arbitrary` impl for parameters. However, you can
/// provide a custom `Strategy` with `#[strategy = <expr>]` on an argument:
///
/// ```
/// # use proptest_macro::property_test;
/// #[property_test]
/// fn foo(#[strategy = "[0-9]*"] s: String) {
/// for c in s.chars() {
/// assert!(c.is_numeric());
/// }
/// }
/// ```
/// Multiple `#[strategy = <expr>]` attributes on an argument are not allowed.
///