Add edge bias feature to bias for testing edge cases. #369
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It works by randomly changing some generated values to be one of the random edge cases. The first tests are done with 100% edge cases, and then the chance goes down over the number of test cases until it's 0%.
The average amount of edge case tests can be controlled by edge_bias configuration option. It defaults to 0.25. (25% of generated values are edge cases over all the tests.)
In failure the edge bias is persisted to the persistence file along with the seed, so it should be reproducible.
So far it only does ints, floats and ranges.
I also got some validation for the system, because some of the existing tests started failing.
For example the time::Duration test failed because if both secs and nanos are MAX, the nanos will overflow into secs, and then secs will overflow and the function panics.
Note that I'm not sure if the fix I made is the best, since I just mod by a billion, so it biases the random distribution a bit. I don't know if this is undesireable.
float_samplers test subbsequent_splits_always_match_bounds also started failing (for f32 and f64 versions both) because it couldn't generate multiple intervals for values like
I fixed it by checking for intervals.count == 1, but I feel like that's not the best solution. From reading the other tests, it feels like the intervals are supposed to be able to be split, but in the end I didn't look fully into it.
I also think the tests should include nans and infinities as edge cases, but I didn't add those because it would cause a lot of things to fail, because they're made with the assumption that those are not generated. (Or expecting and asserting.)
Except for the strings, this should implement #82
I just started with Rust, so I hope there's nothing too stupid in there...