Extremely basic usage of the package - readme example #40
-
I don't understand the most basic example in the readme:
Questions:
if I understand correctly. But here there's no function that we're testing, so are we essentially just testing that (probabilistically) all elements of
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Thanks for the questions!
There's no explicit function/property per se that we're testing here; it's an example to introduce the
Yes, that is correct - note that
That's an issue with the printing 😓 The generator ended up producing I'll also add a convenience function to retrieve the actual counterexample programmatically, so people don't have to rely on the printing giving them what they need for further debugging.
For the most part, yes it's completely random. It's difficult to give exact statistical properties because it depends on the individual There is I mostly mention Bayesian stats as a sort of "think of testing not in terms of absolutes" kind of thing - unless a function is tested with literally all inputs (or other mathematical proof that shows you've tested all equivalency classes of the possible inputs), it's really impossible to say "the code works correctly". As such, I tend to think of a testsuite as giving myself some confidence in correctness, with each run of the testsuite increasing that confidence (hence, I'm updating my prior that the function under test works correctly 😉 ).
That depends on how they're being composed & used 🤔 By default, int8gen = Data.Integers{Int8}()
float16gen = Data.Floats{Float16}()
@check function baz(i=int8gen, f=float16gen)
# ...
end so each of If, on the other hand, you're using that
For the most part, yes. I have been thinking about stateful generators that first try to generate some special values, but that turns out to be a bit difficult for composition. For example, if you had a generator that for the first call of In practice, what exactly is considered a special value for the purpose of finding bugs depends a lot on what property you're testing - there's no ultimately perfect heuristic to use here 🤷 Hope this helps alleviate (at least some of) the confusion! |
Beta Was this translation helpful? Give feedback.
-
Cool thank you - I would say yes a slightly different example in the readme would be helpful, and I'm glad there was a sort-of-issue with the printing, although the reality is I mostly didn't get the example because I forgot that On the statistical properties I guess my work often involves things like "audit sampling" where we basically want to conclude that at a confidence level of X% there are less than Y% erroneous records in a population, and to do that we need to verify a sample of size Z (which can be computed from our desired levels of X and Y). I suppose that just doesn't really make sense here because some inputs will be "special cases" (which as you say aren't really generally identifiable) so normal sampling theory just doesn't apply. Hope to find a way to use this package one day! |
Beta Was this translation helpful? Give feedback.
Thanks for the questions!
There's no explicit function/property per se that we're testing here; it's an example to introduce the
@check
syntax while defining a propertyfoo
. I should probably put a better example there that actually tests something! I originally used such a small example so that readers aren't overwhelmed with a large block of foreign syntax, but I can see how that backfires when the property is pretty nonsensical 😅Yes, that is correct - note that
intgen
is defined asData.Integers{Int8}()