Deprecate js Math.random and provide replacement with Random.nextDouble
#KT-23564 Fixed
This commit is contained in:
@@ -7,6 +7,4 @@ package test
|
|||||||
|
|
||||||
public expect fun assertTypeEquals(expected: Any?, actual: Any?)
|
public expect fun assertTypeEquals(expected: Any?, actual: Any?)
|
||||||
|
|
||||||
public expect fun randomInt(limit: Int): Int
|
|
||||||
|
|
||||||
internal expect fun String.removeLeadingPlusOnJava6(): String
|
internal expect fun String.removeLeadingPlusOnJava6(): String
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ package kotlin.js
|
|||||||
public external object Math {
|
public external object Math {
|
||||||
@Deprecated("Use kotlin.math.PI instead.", ReplaceWith("PI", "kotlin.math.PI"))
|
@Deprecated("Use kotlin.math.PI instead.", ReplaceWith("PI", "kotlin.math.PI"))
|
||||||
public val PI: Double
|
public val PI: Double
|
||||||
|
@Deprecated("Use Random.nextDouble instead", ReplaceWith("kotlin.random.Random.nextDouble()", "kotlin.random.Random"))
|
||||||
public fun random(): Double
|
public fun random(): Double
|
||||||
@Deprecated("Use kotlin.math.abs instead.", ReplaceWith("abs(value)", "kotlin.math.abs"))
|
@Deprecated("Use kotlin.math.abs instead.", ReplaceWith("abs(value)", "kotlin.math.abs"))
|
||||||
public fun abs(value: Double): Double
|
public fun abs(value: Double): Double
|
||||||
|
|||||||
@@ -11,8 +11,5 @@ public actual fun assertTypeEquals(expected: Any?, actual: Any?) {
|
|||||||
assertEquals(expected?.let { it::class.js }, actual?.let { it::class.js })
|
assertEquals(expected?.let { it::class.js }, actual?.let { it::class.js })
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
public actual fun randomInt(limit: Int): Int = (kotlin.js.Math.random() * limit).toInt()
|
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
internal actual inline fun String.removeLeadingPlusOnJava6(): String = this
|
internal actual inline fun String.removeLeadingPlusOnJava6(): String = this
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ public actual fun assertTypeEquals(expected: Any?, actual: Any?) {
|
|||||||
assertEquals(expected?.javaClass, actual?.javaClass)
|
assertEquals(expected?.javaClass, actual?.javaClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
public actual fun randomInt(limit: Int): Int = (Math.random() * limit).toInt()
|
|
||||||
|
|
||||||
private val isJava6 = System.getProperty("java.version").startsWith("1.6.")
|
private val isJava6 = System.getProperty("java.version").startsWith("1.6.")
|
||||||
|
|
||||||
internal actual fun String.removeLeadingPlusOnJava6(): String =
|
internal actual fun String.removeLeadingPlusOnJava6(): String =
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package test.utils
|
package test.utils
|
||||||
|
|
||||||
import test.randomInt
|
import kotlin.random.Random
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ class KotlinVersionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test fun randomVersionComparison() {
|
@Test fun randomVersionComparison() {
|
||||||
fun randomComponent(): Int = randomInt(KotlinVersion.MAX_COMPONENT_VALUE + 1)
|
fun randomComponent(): Int = Random.nextInt(KotlinVersion.MAX_COMPONENT_VALUE + 1)
|
||||||
fun randomVersion() = KotlinVersion(randomComponent(), randomComponent(), randomComponent())
|
fun randomVersion() = KotlinVersion(randomComponent(), randomComponent(), randomComponent())
|
||||||
repeat(1000) {
|
repeat(1000) {
|
||||||
val v1 = randomVersion()
|
val v1 = randomVersion()
|
||||||
|
|||||||
Reference in New Issue
Block a user