quickcheck_macros-1.0.0/.cargo_vcs_info.json0000644000000001120000000000000145010ustar { "git": { "sha1": "9dfcf7fe27e41f04da3e143a332af41350c564c6" } } quickcheck_macros-1.0.0/COPYING000064400000000000000000000001760000000000000143140ustar 00000000000000This project is dual-licensed under the Unlicense and MIT licenses. You may use this code under the terms of either license. quickcheck_macros-1.0.0/Cargo.lock0000644000000206210000000000000124630ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] name = "aho-corasick" version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cfg-if" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "env_logger" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "getrandom" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.82 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ppv-lite86" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quickcheck" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quickcheck_macros" version = "1.0.0" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.82 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_chacha" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thread_local" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "unicode-xid" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum aho-corasick 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" "checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" "checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" "checksum env_logger 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e" "checksum getrandom 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.82 (registry+https://github.com/rust-lang/crates.io-index)" = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" "checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" "checksum memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" "checksum ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" "checksum proc-macro2 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" "checksum quickcheck 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70c7509d6bdc8297b37f3bc369ca249bfe53cecc6b085b82ba538e4fb4e8f8e6" "checksum quote 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" "checksum rand 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c24fcd450d3fa2b592732565aa4f17a27a61c65ece4726353e000939b0edee34" "checksum rand_chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" "checksum rand_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" "checksum regex 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" "checksum regex-syntax 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" "checksum syn 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)" = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" "checksum thread_local 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" "checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" "checksum wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" quickcheck_macros-1.0.0/Cargo.toml0000644000000023150000000000000125060ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "quickcheck_macros" version = "1.0.0" authors = ["Andrew Gallant "] autotests = false description = "A macro attribute for quickcheck." homepage = "https://github.com/BurntSushi/quickcheck" documentation = "https://docs.rs/quickcheck" readme = "../README.md" keywords = ["testing", "quickcheck", "property", "shrinking", "fuzz"] license = "Unlicense/MIT" repository = "https://github.com/BurntSushi/quickcheck" [lib] name = "quickcheck_macros" path = "src/lib.rs" proc-macro = true [dependencies.proc-macro2] version = "1.0" [dependencies.quote] version = "1.0" [dependencies.syn] version = "1.0" features = ["full"] [dev-dependencies.quickcheck] version = "1.0.0" quickcheck_macros-1.0.0/Cargo.toml.orig000064400000000000000000000012670000000000000161520ustar 00000000000000[package] name = "quickcheck_macros" version = "1.0.0" #:version authors = ["Andrew Gallant "] description = "A macro attribute for quickcheck." documentation = "https://docs.rs/quickcheck" homepage = "https://github.com/BurntSushi/quickcheck" repository = "https://github.com/BurntSushi/quickcheck" readme = "../README.md" keywords = ["testing", "quickcheck", "property", "shrinking", "fuzz"] license = "Unlicense/MIT" autotests = false [lib] name = "quickcheck_macros" path = "src/lib.rs" proc-macro = true [dependencies] proc-macro2 = "1.0" quote = "1.0" syn = { version = "1.0", features = ["full"] } [dev-dependencies] quickcheck = { path = "..", version = "1.0.0" } quickcheck_macros-1.0.0/LICENSE-MIT000064400000000000000000000020710000000000000147110ustar 00000000000000The MIT License (MIT) Copyright (c) 2015 Andrew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. quickcheck_macros-1.0.0/UNLICENSE000064400000000000000000000022730000000000000145310ustar 00000000000000This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to quickcheck_macros-1.0.0/examples/attribute.rs000064400000000000000000000005650000000000000174520ustar 00000000000000#![allow(dead_code)] extern crate quickcheck; extern crate quickcheck_macros; use quickcheck_macros::quickcheck; fn reverse(xs: &[T]) -> Vec { let mut rev = vec![]; for x in xs { rev.insert(0, x.clone()) } rev } #[quickcheck] fn double_reversal_is_identity(xs: Vec) -> bool { xs == reverse(&reverse(&xs)) } fn main() {} quickcheck_macros-1.0.0/src/lib.rs000064400000000000000000000052330000000000000151630ustar 00000000000000extern crate proc_macro; extern crate proc_macro2; extern crate quote; extern crate syn; use std::mem; use proc_macro::TokenStream; use quote::quote; use syn::{ parse::{Parse, Parser}, parse_quote, spanned::Spanned, }; #[proc_macro_attribute] pub fn quickcheck(_args: TokenStream, input: TokenStream) -> TokenStream { let output = match syn::Item::parse.parse(input.clone()) { Ok(syn::Item::Fn(mut item_fn)) => { let mut inputs = syn::punctuated::Punctuated::new(); let mut errors = Vec::new(); item_fn.sig.inputs.iter().for_each(|input| match *input { syn::FnArg::Typed(syn::PatType { ref ty, .. }) => { inputs.push(parse_quote!(_: #ty)); } _ => errors.push(syn::parse::Error::new( input.span(), "unsupported kind of function argument", )), }); if errors.is_empty() { let attrs = mem::replace(&mut item_fn.attrs, Vec::new()); let name = &item_fn.sig.ident; let fn_type = syn::TypeBareFn { lifetimes: None, unsafety: item_fn.sig.unsafety.clone(), abi: item_fn.sig.abi.clone(), fn_token: ::default(), paren_token: syn::token::Paren::default(), inputs, variadic: item_fn.sig.variadic.clone(), output: item_fn.sig.output.clone(), }; quote! { #[test] #(#attrs)* fn #name() { #item_fn ::quickcheck::quickcheck(#name as #fn_type) } } } else { errors .iter() .map(syn::parse::Error::to_compile_error) .collect() } } Ok(syn::Item::Static(mut item_static)) => { let attrs = mem::replace(&mut item_static.attrs, Vec::new()); let name = &item_static.ident; quote! { #[test] #(#attrs)* fn #name() { #item_static ::quickcheck::quickcheck(#name) } } } _ => { let span = proc_macro2::TokenStream::from(input).span(); let msg = "#[quickcheck] is only supported on statics and functions"; syn::parse::Error::new(span, msg).to_compile_error() } }; output.into() } quickcheck_macros-1.0.0/tests/macro.rs000064400000000000000000000012550000000000000160710ustar 00000000000000#![allow(non_upper_case_globals)] extern crate quickcheck; extern crate quickcheck_macros; use quickcheck::TestResult; use quickcheck_macros::quickcheck; #[quickcheck] fn min(x: isize, y: isize) -> TestResult { if x < y { TestResult::discard() } else { TestResult::from_bool(::std::cmp::min(x, y) == y) } } #[quickcheck] #[should_panic] fn fail_fn() -> bool { false } #[quickcheck] static static_bool: bool = true; #[quickcheck] #[should_panic] static fail_static_bool: bool = false; // If static_bool wasn't turned into a test function, then this should // result in a compiler error. #[test] fn static_bool_test_is_function() { static_bool() }