Open gfredericks opened 9 years ago
(schema->gen BigDecimal) returns a generator of floats, when I'd prefer that it would crash because it doesn't know how to generate BigDecimal.
(schema->gen BigDecimal)
BigDecimal
The reason it does this is because the s/Num clause is using the java.lang.Number class which is a superclass of BigDecimal.
s/Num
java.lang.Number
I think inheritance for generators kind of works in the opposite direction (IS THIS WHAT CONTRAVARIANT MEANS??).
Not sure what the best fix is. Only idea I have is swapping s/Num for Double.
Double
also worth pointing out that once I add my own (defmethod schema->gen BigDecimal ...) everything is fine -- the problem is just that I was confused prior to adding it.
(defmethod schema->gen BigDecimal ...)
(schema->gen BigDecimal)
returns a generator of floats, when I'd prefer that it would crash because it doesn't know how to generateBigDecimal
.The reason it does this is because the
s/Num
clause is using thejava.lang.Number
class which is a superclass ofBigDecimal
.I think inheritance for generators kind of works in the opposite direction (IS THIS WHAT CONTRAVARIANT MEANS??).
Not sure what the best fix is. Only idea I have is swapping
s/Num
forDouble
.