Remove Random.nextInt(bound) test
- Should be covered by the common stdlib tests - Default implementation is used now
This commit is contained in:
committed by
Pavel Punegov
parent
ee37eef93c
commit
8e4806725b
@@ -505,11 +505,6 @@ task runtime_random(type: RunKonanTest) {
|
||||
source = "runtime/basic/random.kt"
|
||||
}
|
||||
|
||||
task runtime_random_bound(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // Uses exceptions.
|
||||
source = "runtime/basic/random_bound.kt"
|
||||
}
|
||||
|
||||
task runtime_worker_random(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // Uses workers.
|
||||
source = "runtime/basic/worker_random.kt"
|
||||
|
||||
@@ -61,19 +61,3 @@ fun testNextInt() {
|
||||
testReproducibility(getTimeMillis(), { Random.nextInt(1000) })
|
||||
testReproducibility(1000L, { Random.nextInt(1024) })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBoundsNextInt() {
|
||||
boundTest(5000)
|
||||
boundTest(32)
|
||||
boundTest(2)
|
||||
boundTest(Int.MAX_VALUE)
|
||||
}
|
||||
|
||||
private fun boundTest(bound: Int) {
|
||||
val a = Array<Int>(100, { Random.nextInt(bound) })
|
||||
a.forEach {
|
||||
assertTrue(it >= 0, "Should be: $it >= 0")
|
||||
assertTrue(it < bound, "Should be: $it < $bound")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package runtime.basic.random_bound
|
||||
|
||||
import kotlin.random.*
|
||||
import kotlin.test.*
|
||||
|
||||
@Test
|
||||
fun testBoundsNextInt() {
|
||||
assertFailsWith<IllegalArgumentException>("Should fail on bound 0", { Random.nextInt(0) })
|
||||
assertFailsWith<IllegalArgumentException>("Should fail on bound -100", { Random.nextInt(-100) })
|
||||
assertFailsWith<IllegalArgumentException>("Should fail on bound ${Int.MIN_VALUE}", { Random.nextInt(Int.MIN_VALUE) })
|
||||
}
|
||||
Reference in New Issue
Block a user