nick8325 / quickcheck

Automatic testing of Haskell programs.
Other
713 stars 119 forks source link

`shrink` and `shrinkDecimal` do not work with negative numbers. #268

Closed kindaro closed 4 years ago

kindaro commented 5 years ago

Consider how negative integral numbers are shrunk:

λ shrinkIntegral 100
[0,50,75,88,94,97,99]
λ shrinkIntegral (-100)
[100,0,-50,-75,-88,-94,-97,-99]

Now see how fractional numbers are:

λ shrink 1.23
[1.0,0.0,1.2,0.0,0.6,0.9,1.1,0.0,0.62,0.93,1.08,1.16,1.2,1.22]
λ shrinkDecimal  (1.23)
[1.0,0.0,1.2,0.0,0.6,0.9,1.1,0.0,0.62,0.93,1.08,1.16,1.2,1.22]
λ shrink (-1.23)
[0.0]
λ shrinkDecimal  (-1.23)
[0.0]

I think this is wrong. Negative and positive numbers are equally rightful members of a number ring, both in its additive and multiplicative aspect. They should be treated evenly.

nick8325 commented 4 years ago

Fixed. Thanks for reporting the bug!