Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Robert Widmann
@CodaFi
Use "cover"
Brian Gerstle
@bgerstle
and/or add the map impl arity that i need
i thought cover was what i wanted, unclear how to use it though
Robert Widmann
@CodaFi
See the release notes. I had an image of me using it in there.
Brian Gerstle
@bgerstle
ok, i'll dig a bit deeper
i'll see if there are tests demonstrating its use too
gotta run for now though
thanks for the split hint (also explains why my hash test failed)
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