First attempt at a Supposition.jl-based test #736
+30
−1
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.
Started during the Hackathon at JuliaCon Paris under the guidance of @Kolaru, here is my first attempt at adding a test using Supposition.jl (c.p. #733).
To start simple, the goal was to convert an existing test with a hardcoded numerical value to one using randomly generated values from Supposition.jl instead.
For no particular reason, we picked
IntervalArithmetic.jl/test/interval_tests/numeric.jl
Line 175 in 544c000
which tests that for a degenerate interval with equal start and endpoints of type
Rational
, both the one and two argument syntax yield the same interval.There were a few unforeseen complications, which I tried my best to find a solution for:
Int
s, and the case0//0
is explicitly thrown out as an invalid test case.1//0
and-1//0
(correspondingInf
/-Inf
), which will yield an ill-formed interval (see also isempty_interval return false on empty ill intervals #734). However, similar to the discussion in How to automatically find counterexample Seelengrab/Supposition.jl#62 (comment), it is unlikely that a0
is generated in the denominator for anInt64
, so I had to use anInt8
generator instead. As an alternative, one might instead add these cases explicitly to the regular tests.OverflowError
would appear, especially when usingInt8
. The issue can be reproduced bySo I believe that upon construction of a Rational resulting in an overall negative value, a minus sign in the denominator is transferred to the numerator instead, and the sign of the former is flipped. However, if that value happens to be
typemin(Int8)
, there will be an overflow, sincetypemax(Int8)==127
. To address this, I instead added1
to the minimum value of theInt
generator. Does that seem reasonable?1//0
and-1//0
& Ill-formed intervalsNaN
, and any Boolean comparison will yieldfalse
.ill
.Also, it might make sense to fix the random seed for reproducibility reasons, but I am not sure if this would go against the spirit of this fuzzing-based approach, which I am not too familiar with.
I apologize for the wall of text for this (at least in theory) rather simple addition, and would appreciate any feedback!