Skip to content

Commit

Permalink
WIP attr macro (#316)
Browse files Browse the repository at this point in the history
* some progress on attribute macro

* first draft, tests still broken

* nix cleanup

* use real trybuild

* test for config parameter

* PR feedback - use formatted Display impl for snapshot test

* add hygiene test

* PR feedback

* pin to trybuild 1.0.0 for MSRV

* actually pin properly
  • Loading branch information
cameron1024 authored May 20, 2024
1 parent b449b1e commit c117b76
Show file tree
Hide file tree
Showing 28 changed files with 4,665 additions and 4 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ persistence-test.txt

# IntelliJ
.idea

/.direnv
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"proptest",
"proptest-derive",
"proptest-state-machine",
"proptest-macro",
]

exclude = ["proptest/test-persistence-location/*"]
129 changes: 129 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
description = "proptest development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rust-bin.nightly.latest.default

cargo-insta
];

TRYBUILD_CARGO_CMD = "test";
};
}
);
}
1 change: 0 additions & 1 deletion proptest-derive/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::ops::{Add, AddAssign};

use proc_macro2::{Span, TokenStream};
use quote::{ToTokens, TokenStreamExt};
use syn;
use syn::spanned::Spanned;

use crate::error::{Ctx, DeriveResult};
Expand Down
17 changes: 17 additions & 0 deletions proptest-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "proptest-macro"
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true

[dependencies]
syn = { version = "2", features = ["full"] }
quote = "1"
proc-macro2 = "1"
convert_case = "0.6"

[dev-dependencies]
insta = "1"
prettyplease = "0.2"
8 changes: 8 additions & 0 deletions proptest-macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use proc_macro::TokenStream;

mod property_test;

#[proc_macro_attribute]
pub fn property_test(attr: TokenStream, item: TokenStream) -> TokenStream {
property_test::property_test(attr.into(), item.into()).into()
}
Loading

0 comments on commit c117b76

Please sign in to comment.