Skip to content

Instantly share code, notes, and snippets.

@mads-hartmann
Created October 16, 2012 09:20
Show Gist options
  • Save mads-hartmann/3898260 to your computer and use it in GitHub Desktop.
Save mads-hartmann/3898260 to your computer and use it in GitHub Desktop.
ScalaCheck Output That I don't understand
// The output.
info] ! Multiset.remove: Falsified after 1 passed tests.
[info] > ARG_0: (ListMultiset(, ),) <<<---- this is what looks weird, but I guess it's a ListMultiset with "" (no space)," " (a space) and the string is "" (no space)
[info] ! Multiset.remove: Falsified after 7 passed tests.
[info] > ARG_0: (ListMultiset(),)
// The specification
property("remove") = forAll(genMultisetWithString) { ((ms: Multiset[String], s: String) =>
(ms - s).size == ms.size - 1
).tupled }
property("remove") = forAll(genMultisetWithString) { ((ms: Multiset[String], s: String) =>
(ms - s).multiplicity(s) == ms.multiplicity(s) - 1
).tupled }
// The generator
val genMultisetWithString = for {
mset <- genStringMultiset
s <- Arbitrary.arbitrary[String]
} yield (mset + s, s)
@mads-hartmann
Copy link
Author

The code seems to work in the REPL though :-/

scala> val ms = ListMultiset("", " ")
ms: com.sidewayscoding.immutable.ListMultiset[java.lang.String] = ListMultiset(,  )

scala> val s = ""
s: java.lang.String = ""

scala> (ms - s).size == ms.size - 1
res2: Boolean = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment