Refactor: extract JVM-specific tests into separate files
Make KotlinVersion random comparison test running in JS
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:JvmVersion
|
||||
package test.utils
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class AssertionsJVMTest() {
|
||||
|
||||
@Test fun passingAssert() {
|
||||
assert(true)
|
||||
var called = false
|
||||
assert(true) { called = true; "some message" }
|
||||
|
||||
assertFalse(called)
|
||||
}
|
||||
|
||||
|
||||
@Test fun failingAssert() {
|
||||
val error = assertFailsWith<AssertionError> {
|
||||
assert(false)
|
||||
}
|
||||
assertEquals("Assertion failed", error.message)
|
||||
}
|
||||
|
||||
|
||||
@Test fun failingAssertWithMessage() {
|
||||
val error = assertFailsWith<AssertionError> {
|
||||
assert(false) { "Hello" }
|
||||
}
|
||||
assertEquals("Hello", error.message)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package test.utils
|
||||
|
||||
import test.randomInt
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
@@ -55,10 +56,8 @@ class KotlinVersionTest {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmVersion // until there's random in JS
|
||||
@Test fun randomVersionComparison() {
|
||||
val random = java.util.Random()
|
||||
fun randomComponent(): Int = random.nextInt(KotlinVersion.MAX_COMPONENT_VALUE + 1)
|
||||
fun randomComponent(): Int = randomInt(KotlinVersion.MAX_COMPONENT_VALUE + 1)
|
||||
fun randomVersion() = KotlinVersion(randomComponent(), randomComponent(), randomComponent())
|
||||
repeat(1000) {
|
||||
val v1 = randomVersion()
|
||||
|
||||
@@ -89,33 +89,6 @@ class PreconditionsTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.jvm.JvmVersion
|
||||
@Test fun passingAssert() {
|
||||
assert(true)
|
||||
var called = false
|
||||
assert(true) { called = true; "some message" }
|
||||
|
||||
assertFalse(called)
|
||||
}
|
||||
|
||||
|
||||
@kotlin.jvm.JvmVersion
|
||||
@Test fun failingAssert() {
|
||||
val error = assertFailsWith<AssertionError> {
|
||||
assert(false)
|
||||
}
|
||||
assertEquals("Assertion failed", error.message)
|
||||
}
|
||||
|
||||
|
||||
@kotlin.jvm.JvmVersion
|
||||
@Test fun failingAssertWithMessage() {
|
||||
val error = assertFailsWith<AssertionError> {
|
||||
assert(false) { "Hello" }
|
||||
}
|
||||
assertEquals("Hello", error.message)
|
||||
}
|
||||
|
||||
@Test fun error() {
|
||||
val error = assertFailsWith<IllegalStateException> {
|
||||
error("There was a problem")
|
||||
|
||||
Reference in New Issue
Block a user