Skip to content

Commit

Permalink
cargo check
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron1024 committed Jul 12, 2024
1 parent 942c389 commit 78547c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 4 additions & 2 deletions proptest-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod property_test;
/// Using the `property_test` macro:
///
/// ```
/// # use proptest_macro::property_test;
/// #[property_test]
/// fn foo(x: i32) {
/// assert_eq!(x, x);
Expand All @@ -19,7 +20,7 @@ mod property_test;
///
/// is roughly equivalent to:
///
/// ```
/// ```ignore
/// proptest! {
/// #[test]
/// fn foo(x in any::<i32>()) {
Expand All @@ -42,7 +43,7 @@ mod property_test;
///
/// E.g. running 100 cases:
///
/// ```rust
/// ```rust,ignore
/// #[property_test(config = "ProptestConfig { cases: 100, .. ProptestConfig::default() }")]
/// fn foo(x: i32) {
/// assert_eq!(x, x);
Expand All @@ -55,6 +56,7 @@ mod property_test;
/// 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() {
Expand Down
7 changes: 2 additions & 5 deletions proptest-macro/src/property_test/codegen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{parse_str, spanned::Spanned, Attribute, Ident, ItemFn};
use syn::{parse_quote, spanned::Spanned, Attribute, Ident, ItemFn};

use super::{
options::Options,
Expand Down Expand Up @@ -85,11 +85,8 @@ fn nth_field_name(span: impl Spanned, index: usize) -> Ident {
Ident::new(&format!("field{index}"), span.span())
}

/// I couldn't find a better way to get just the `#[test]` attribute since [`syn::Attribute`]
/// doesn't implement `Parse`
fn test_attr() -> Attribute {
let mut f: ItemFn = parse_str("#[test] fn foo() {}").unwrap();
f.attrs.pop().unwrap()
parse_quote! { #[test] }
}

#[cfg(test)]
Expand Down

0 comments on commit 78547c2

Please sign in to comment.