Comments (9)
I just hit a related case
Fixed in 0.8.6, along with some other issues with subsequence
.
The original issue this report is about no longer happens as of 0.8.6 since Range
is now used as the internal representation (in exchange for simply not allowing usize::MAX
to be an included value at all).
from proptest.
I doubt anyone is actually using this or will do so in the near future since proptest doesn't ever return this type on its own, so it would require someone else to decide to use SizeRange
themselves and then go back into a range. I agree it should be removed eventually, but I'm inclined to wait for the next breaking changes train.
from proptest.
I agree it should be removed eventually, but I'm inclined to wait for the next breaking changes train.
Yeah; I agree with everything you said and this :)
I would suggest that we start with a more elaborate labeling system in this repo with milestones and more labels, which will be more important as proptest grows in importance in the ecosystem (which I'm hoping it will, because I think it is the state of the art wrt. Rust and testing). Something like:
- E-easy
- E-medium
- E-hard
- E-help-wanted
- P-high
- P-low
- breaking-change
and so on...
Here's some inspiration:
- https://github.com/dtolnay/syn/labels
- https://github.com/rust-random/rand/labels
- https://github.com/SergioBenitez/Rocket/labels
from proptest.
I just hit a related case, subsequence(s, 0)
panics subtracted with overflow
do to:
/// Given `low .. high`, then a size range `[low, high)` is the result.
impl From<Range<usize>> for SizeRange {
fn from(r: Range<usize>) -> Self { size_range(r.start..=r.end - 1) }
}
(note that the 0
is generated from a separate part of the strategy, not a hardcoded value I could easily change.)
from proptest.
Seems I implemented that incorrectly; should be:
/// Given `low .. high`, then a size range `[low, high)` is the result.
impl From<Range<usize>> for SizeRange {
fn from(r: Range<usize>) -> Self {
let end = if r.end == 0 { 0 } else { r.end - 1 };
size_range(r.start..=end)
}
}
This can only occur if you provide forall x: usize. (x..0)
.
EDIT: actually... probably not; this would change the semantics given 0..0
.
You can't translate that to 0..=0
which would happen if we changed the implementation to that.
EDIT: To actually represent the concept of an empty range in RangeInclusive
I think you'd need to define this as (x+1)..x
. Maybe SizeRange
should be defined as struct SizeRange(Option<RangeInclusive<usize>>)
instead...?
EDIT: but if you do that... you can't convert SizeRange
to RangeInclusive<usize>
anymore... sigh :/
from proptest.
Or you can use saturating_sub
, in fact that could be a good mitigation or this entire thing.
from proptest.
@Eh2406 if you do r.start..=r.end.saturating_sub(1)
then you may still reach cases like 0..0
becoming 0..=0
which is now 1 element more.
from proptest.
(I'm going to keep this open for the moment since there are some other unaddressed talking points still.)
from proptest.
Removed the impl
s in question in 0.9.0.
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.