A Possibility
for generating arbitrary T
#21
Seelengrab
started this conversation in
Design & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, only a handful of data types are implemented directly in Supposition.jl. This feature intends to use the reflection capabilities provided by the compiler to generate (almost) any arbitrary
T
from its type.This needs to:
convert
on every argument, since that would lead to quite a lot of avoidable errorscode_typed
, rejecting methods that infer asUnion{}
(these will throw) and only considering those that have anExpr(:new)
in themselves. The reasoning for this is that any outer constructors that may want to establish invariants through checks likex < 5 || throw(ArgumentError())
are trivially circumventable by just calling the inner constructor directly (either with arguments that happen to dispatch to the inner one, or throughinvoke
).Shrinking-wise, this should just fall back to lexicographic shrinking, but this too should again be customizable. It may be the case that a user is fine with having the full space of possible values emerge from this
Possibility
, but only cares about shrinking them in a specific way.Beta Was this translation helpful? Give feedback.
All reactions