Comments (6)
the macro invocation looks like a closure
I guess we have different ways of looking at things; I saw it as a function-like macro that mimics a function taking a closure as an argument. (I was wondering why you used braces though; now that makes sense.)
I suppose we'll just have to see how it plays out over time now that it's been released in its current form.
from proptest.
To be frank, I'm quite confused about what you're looking for now. Your original PR called runner.run()
within the macro.
runner.test
Is this referring to some other test framework? If so, your example could just be written
runner.test("some test", || proptest!(|..| {
/* ... */
}));
from proptest.
Hey @AltSysrq
To be frank, I'm quite confused about what you're looking for now. Your original PR called runner.run() within the macro.
You are missing this part which was removed here. The PR had proptest!
return a closure which you have to capture and call yourself. After your change it no longer returns a closure, it just evaluates the test in place. Given your comment, I'm not sure this was intentional.
Is this referring to some other test framework? If so, your example could just be written.
Yes, the test framework I use captured the closure in order to execute it as part of a suite. Now there is a fair bit more bracket matching to be done because I have to wrap everything in closures manually.
from proptest.
The PR had
proptest!
return a closure
Yes. I discovered that when trying to document what that usage style did and was so suprised that it was returning a closure that I assumed it was an error.
I don't think returning a closure is a good fit for a general-purpose macro here. Users trying to use it in a normal context would need extra syntax to just invoke the closure immediately after (most likely) finding out the hard way that the macro did absolutely nothing without the extra ()
, whereas making closures around normal immediate code is something everyone does every day.
Unless there's something else I'm missing, it seems to me that the new form is enough of a building block to just make your own convenience macro.
macro_rules! ptc {
($($t:tt)*) => { || proptest!($($t)*) }
}
from proptest.
Ok!
I don't think returning a closure is a good fit for a general-purpose macro here.
I think the pertinent part here is that the macro invocation looks like a closure. And folks seeing it will likely expect it to behave like a closure. I believe it's considered good practice to try to mimic existing language items when building macros.
If we are after something that performs in-place execution, something that doesn't look like a closure is probably more suitable, like:
proptest!((...) {
})
Unless there's something else I'm missing, it seems to me that the new form is enough of a building block to just make your own convenience macro.
I already have. It's just a bummer that I have to :/.
from proptest.
Ok, let's let it settle for a while. Thanks for explaining your reasoning!
from proptest.
Related Issues (20)
- First-class support for async functions
- The type 'EasyCashIdentity.EntityLayer.Concrete.AppUser' cannot be used as type parameter
- rust-analyzer doesn't like the derive(Arbitrary) generated code for enums HOT 1
- Zero Examples of `impl Arbitrary` ? HOT 3
- Finite state machines HOT 1
- proptest_derive triggers non-local impl nightly warning HOT 1
- Update "shrinks to" comment on the same seed failures HOT 1
- Panic on empty ranges during strategy creation HOT 3
- Don't require `Arbitrary::Parameters` to implement `Default` HOT 4
- Recursive `arbitrary` calls HOT 3
- Change verbosity of shrink disabled and persisted failure messages HOT 3
- Provide access to state for (debug) printing transitions HOT 5
- feat: add option to interrupt test runner HOT 2
- derive macro for Arbitrary is hard to find HOT 4
- Attribute macro #[property_test] available in docs, but undocumented and behind undocumented feature HOT 1
- Lift MSRV to 1.70 to relax dependency on trybuild
- RangeInclusive of floats containing one element panics
- Improve logging for state machine testing
- The ` state_machine_echo_server` example does not compile HOT 2
- Proptest logging
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 proptest.