Skip to content

Instantly share code, notes, and snippets.

@erip
Last active December 24, 2018 00:30
Show Gist options
  • Save erip/c4810f781606263e0c733cc8e35230fa to your computer and use it in GitHub Desktop.
Save erip/c4810f781606263e0c733cc8e35230fa to your computer and use it in GitHub Desktop.
use "ponytest"
use "ponycheck"
use ".."
interface val _TestSemigroupAssociativity[T] is UnitTest
fun semigroup(): Semigroup[T]
fun t(): String
fun name(): String => "laws/associative/" + t()
fun gen(): Generator[(T, T, T)] val
fun is_associative(h: TestHelper)? =>
let sg = semigroup()
Ponycheck.for_all[(T, T, T)](gen(), h)(
{(args, ph) =>
(let x, let y, let z) = args
// can't find definition of 'T'
ph.assert_eq[T](
sg.combine(sg.combine(x, y), z),
sg.combine(x, sg.combine(y, z))
)
})?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment