Comments (10)
Compiler plugins can only be used on Rust nightlies. There are no immediate plans to change this. quickcheck_macros
is a crate that defines a compiler plugin.
quickcheck_macros
is an optional convenience. There is nothing useless about the main crate quickcheck
. There are plenty of examples here: https://github.com/BurntSushi/quickcheck/tree/master/examples
from quickcheck.
I disagree #[quickcheck] being an optional convenience: if you are mixing example-based and property-based tests in the same file the documentation makes it appear essential to use this annotation. All the examples you point at are of free standing executables not of inputs to the standard test runner, which seems to back up my argument.
Of course QuickCheck is not useless, but the integration of the current system with the standard Rust test runner does appear to be since it relies on running nightlies. Companies will not run nightlies, they are unlikely to run beta, they will be running stable.
From your comment the problem is with the main Rust team who do not allow compiler plugins to run on stable. If this is the case then clearly the problem is there and that is what needs to be addressed.
from quickcheck.
Here is an example in my link:
extern crate quickcheck;
use quickcheck::{TestResult, quickcheck};
fn reverse<T: Clone>(xs: &[T]) -> Vec<T> {
let mut rev = vec!();
for x in xs {
rev.insert(0, x.clone())
}
rev
}
fn main() {
fn prop(xs: Vec<isize>) -> TestResult {
if xs.len() != 1 {
return TestResult::discard()
}
TestResult::from_bool(xs == reverse(&*xs))
}
quickcheck(prop as fn(Vec<isize>) -> TestResult);
}
Here is the same example, but using #[test]
:
extern crate quickcheck;
use quickcheck::{TestResult, quickcheck};
fn reverse<T: Clone>(xs: &[T]) -> Vec<T> {
let mut rev = vec!();
for x in xs {
rev.insert(0, x.clone())
}
rev
}
#[test]
fn prop_reverse() {
fn prop(xs: Vec<isize>) -> TestResult {
if xs.len() != 1 {
return TestResult::discard()
}
TestResult::from_bool(xs == reverse(&*xs))
}
quickcheck(prop as fn(Vec<isize>) -> TestResult);
}
The #[quickcheck]
annotation removes some boiler plate. That's it. The transformation is straight forward.
From your comment the problem is with the main Rust team who do not allow compiler plugins to run on stable. If this is the case then clearly the problem is there and that is what needs to be addressed.
It is being addressed. But it's going to take time and lots of work. It's still early days, but you can probably get a good idea of progress/current state from this thread: https://internals.rust-lang.org/t/the-future-of-syntax-extensions-and-macros/2889/34
from quickcheck.
To be clear, I use quickcheck in almost every single one of my published crates. I don't think I've ever used the #[quickcheck]
annotation because I want to run things on Rust stable.
from quickcheck.
I was clearly overthinking – or maybe that should be underthinking – this. Apologies. This now puts me on the right road.
That thread is interesting. Benchmarking definitely is a topic for me.
I suspect an article on quickcheck in Rust would go down very well indeed in CVu or Overload (the journals of ACCU). http://accu.org
from quickcheck.
I was sad to lose the macro annotation, but have made do, e.g., in https://github.com/FranklinChen/type-directed-tdd-rust
Eek, just noticed my README is rather out of date.
from quickcheck.
I think I should (so will) take this one to the forum: all the example use a function as parameter, does this imply you cannot use a closure?
from quickcheck.
@russel I'm hesitant to say "cannot," but I can say, "I haven't figured out how yet." The pertinent issue is #56. I used to think I couldn't do it because of this bug in rustc
, but it seems that it's not actually a bug.
from quickcheck.
@BurntSushi If you are having difficulties, I am unlikely to fair better. Doing some compile time code generation with macros looks like the only way to solve the closure thing for me. I posted on the forum, but it sounds as the answer is already known to be "not at the moment".
from quickcheck.
@russel Possibly, although fresh eyes definitely couldn't hurt!
from quickcheck.
Related Issues (20)
- Gen from seed HOT 8
- Cannot use Rng methods on `Gen` when implementing `Arbitrary` HOT 5
- Identity checking HOT 3
- Stack overflow in quickcheck case shrinking HOT 3
- example case sort TEST FAILED HOT 1
- QuickChecking Const Generic Code HOT 5
- Implement Arbitrary for AsMut<[T: Arbitrary]> HOT 2
- Infinite Repetition/Never Ending Test with `f32` and `f64`. HOT 17
- Q: Idiomatic way to specify the length of an arbitrary vector HOT 7
- <newbie> How to generate a number within a range HOT 2
- Negating an integer leads to stack overflow HOT 2
- upgrade notes would be nice. HOT 1
- debug_reprs taking up 41% of test runtime HOT 2
- warning: panic message is not a string literal HOT 1
- Rng Size for Vec Arbitrary cannot be 0
- Impl Clone for Gen
- Implement something like choose_weighted for `Gen`
- Is this still maintained? HOT 1
- Is quickcheck still maintained? HOT 1
- How to combine quickcheck 1+ with fake? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quickcheck.