fun randomNatural() = Random.nextInt(from = 1, until = 100_000_000) ➊
@Test
fun `zero identity`() { ➋
repeat(100) { ➌
val x = randomNatural()
expectThat(x + 0).isEqualTo(x)
}
}
@Test
fun `commutative property`() { ➍
repeat(100) {
val x = randomNatural()
val y = randomNatural()
expectThat(x + y).isEqualTo(y + x)
}
}
@Test
fun `associative property`() { ➎
repeat(100) {
val x = randomNatural()
val y = randomNatural()
val z = randomNatural()
expect { ➏
that((x + y) + z).isEqualTo(x + (y + z))
that((y + z) + x).isEqualTo(y + (z + x))
that((z + x) + y).isEqualTo(z + (x + y))
}
}
}