Write random contract tests and fix implementations to pass them

This commit is contained in:
Ilya Gorbunov
2018-07-04 06:42:19 +03:00
parent ed1f869354
commit b96803248f
5 changed files with 411 additions and 13 deletions
@@ -35,7 +35,8 @@ internal actual fun fastLog2(value: Int): Int =
internal abstract class AbstractPlatformRandom : Random() {
abstract val impl: java.util.Random
override fun nextBits(bitCount: Int): Int = impl.nextInt() ushr (32 - bitCount).coerceAtLeast(0)
override fun nextBits(bitCount: Int): Int =
impl.nextInt().takeUpperBits(bitCount)
override fun nextInt(): Int = impl.nextInt()
override fun nextInt(bound: Int): Int = impl.nextInt(bound)
@@ -75,5 +76,3 @@ private class KotlinRandom(val impl: Random) : java.util.Random() {
throw UnsupportedOperationException("Setting seed is not supported.")
}
}