Skip to content

Instantly share code, notes, and snippets.

@Maragues
Last active August 27, 2019 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maragues/a713727b538327e893a330c9427b6523 to your computer and use it in GitHub Desktop.
Save Maragues/a713727b538327e893a330c9427b6523 to your computer and use it in GitHub Desktop.
class PropertyTestSum : StringSpec({
"Sum is commutative " {
assertAll { a: Int, b: Int ->
sum(a, b) shouldBe sum(b, a)
}
}
"Sum is associative " {
assertAll { a: Int, b: Int, c: Int ->
sum(a, b, c) shouldBe sum(a, c, b)
sum(a, b, c) shouldBe sum(c, b, a)
sum(a, b, c) shouldBe sum(b, c, a)
}
}
"The sum of any number and zero is the original number" {
assertAll { a: Int ->
sum(a, 0) shouldBe a
}
}
"Sum is distributive " {
assertAll { a: Int, b: Int, c: Int ->
sum(a, b) * c shouldBe sum(a * c, b * c)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment