Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edge bias feature to bias for testing edge cases. #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ajantti
Copy link

@ajantti ajantti commented Sep 6, 2023

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

minimal failing input: (low, high) = (
    1.7976931348623155e308,
    1.7976931348623157e308,
), index = Index(
    0,
)

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...

* 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.
* In failure the edge bias is persisted to the persistence file along
  with the seed, so it should be reproducible.
* Also fix time::Duration test because the edge bias system found a
  problem in it. (Might need more modifications.)
* Fix float_samplers test subsequent_splits_always_match_bounds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant