Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Brian Gerstle
@bgerstle
:+1:
later o/
Brian Gerstle
@bgerstle
cover is only partially what i wanted: it will fail the test if coverage is insufficient, but i want the test to always pass if coverage is sufficient. however, the test will fail if the property is ever falsified, which also breaks coverage
also, when coverage is insufficient, there's no counterexample or even seed output, the latter being potentially very problematic if the tests fail since i might not be able to reproduce
Robert Widmann
@CodaFi
You can ^&&^ the property together with itself.
The no seed thing, however, is a bug. I will fix it soon
Brian Gerstle
@bgerstle

You can ^&&^ the property together with itself.

what will that do?

@CodaFi :point_up:
i can file an issue describing my expected usage & behavior in more detail if that would help
This message was deleted
Brian Gerstle
@bgerstle
or rather, how will that solve the problem?
Robert Widmann
@CodaFi
The Conjunct will simultaneously be, by the laws of boolean algebra, equivalent to the original expression and will fail when the non-cover side fails.
I should have been more clear: one side should be covered, one side not
You can file an issue, yeah.
Brian Gerstle
@bgerstle
i'll try that out..
Brian Gerstle
@bgerstle
sorry, to be clear: it was already failing when the coverage failed. the problem is i wanted it to pass even if the property didn't always hold true
which isn't exactly what cover is meant to do
it's meant to say that you covered certain parts of the input spectrum
AFAICT
there doesn't appear a way to change the number of allowed failures for a property
except perhaps by discarding
and changing the number of allowed discarded tests
Robert Widmann
@CodaFi
Mhm. Then there isn't a combinator for that explicitly.
By the way, I believe fixed your issue here typelift/SwiftCheck#159
Brian Gerstle
@bgerstle
lgtm :+1:
btw, i couldn't get the discard approach to work, it never seemed to fail no matter how low i set max allowable discards
Robert Widmann
@CodaFi
Another bug! That one, I don't believe we have unit tests for. Should be easy to reproduce.
Oh wait, not a bug "Discarded tests (i.e. ones with a false precondition) do not affect coverage."
We need a new combinator!
Robert Widmann
@CodaFi
So, wait, did you try something like
let p = //... Some property
return p ^&&^ p.cover(/**/)
Brian Gerstle
@bgerstle
i think so... sorry in the middle of something else atm :-/
Brian Gerstle
@bgerstle
not sure i follow how that would work in my case. basically i'm testing that different objects should (mostly) have different hashes. w/o worrying about cover or any of that, it looks like this:
forAll { a, b in 
  return (a != b) ==> (a.hash != b.hash)
}
now, this isn't true all the time (you can't have a perfect hash algorithm), in fact, I hit a falsifiable case
so, i wanted to say that the part after ==> only needs to be true about 95% of the time (arbitrary percentage, just shouldn't be too bad for performance reasons)
one way to do that is to always return true, and just require that certain the a.hash != b.hash component is "covered" 95% of the time
e.g. return (a != b) => (true.cover(a.hash != b.hash, percentage: 95, label: "hashes are different))
this means the always passes unless coverage isn't satisfied (i.e. fewer than 95% of the hashes were different when the values were different)
but i ran into the bug which you fixed earlier, that failed coverage didn't report replay values
if that's fixed i'm satisfied w/ my above workaround
Brian Gerstle
@bgerstle
confirmed:
*** Insufficient coverage after 1000 tests
(only 99% hashes are different, not 100%)
[redacted]
error: [redacted]: failed - Property coverage insufficient.  Replay with 219013233 7406 and size 0
Robert Widmann
@CodaFi
That's an interesting workaround. Actually, I'd like to preserve it somewhere like the testing suite if you wouldn't mind.
Brian Gerstle
@bgerstle
of course not
i've got something else for you, PR incoming shortly..
Brian Gerstle
@bgerstle
whoops added something else in there by accident, rebasing..
@CodaFi i also have some generators that others may find useful, e.g. for CoreGraphics & UIKit types
would you be interested in a PR which puts them in a separate folder, so users can integrate via CocoaPods subspecs as needed?
e.g. CGRect, CGVector, etc.
Robert Widmann
@CodaFi
I am wary of doing this in general right now, only because the new Foundation changes are going to break a lot of work very soon