kotlin.test: Rename jvm module to junit

This commit is contained in:
Sergey Mashkov
2015-11-25 17:27:30 +03:00
parent 149ce70ce2
commit a5b098c4a7
17 changed files with 73 additions and 21 deletions
@@ -27,7 +27,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin.test.jvm</artifactId>
<artifactId>kotlin.test.junit</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+1 -1
View File
@@ -22,7 +22,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin.test.jvm</artifactId>
<artifactId>kotlin.test.junit</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
@@ -7,13 +7,14 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kotlin.test.jvm</artifactId>
<artifactId>kotlin.test.junit</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>(4,5)</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
+1 -1
View File
@@ -13,7 +13,7 @@
<modules>
<module>shared</module>
<module>jvm</module>
<module>junit</module>
<!--<module>js</module>--> <!-- TODO enable back when js build fixed -->
</modules>
+1
View File
@@ -102,6 +102,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@@ -6,10 +6,12 @@ import kotlin.jvm.internal.*
import kotlin.reflect.*
@Deprecated("Use assertFailsWith instead.", ReplaceWith("assertFailsWith(exceptionClass, block)"), kotlin.DeprecationLevel.ERROR)
fun <T : Throwable> failsWith(exceptionClass: Class<T>, block: () -> Any): T = assertFailsWith(exceptionClass, { block() })
fun <T : Throwable> failsWith(exceptionClass: Class<T>, block: () -> Any): T = assertFailsWith(exceptionClass) { block() }
/** Asserts that a [block] fails with a specific exception being thrown. */
fun <T : Throwable> assertFailsWith(exceptionClass: Class<T>, block: () -> Unit): T = assertFailsWith(exceptionClass, null, block)
fun <T : Throwable> assertFailsWith(exceptionClass: Class<T>, block: () -> Unit): T {
return assertFailsWith(exceptionClass, null, block)
}
/** Asserts that a [block] fails with a specific exception being thrown. */
fun <T : Throwable> assertFailsWith(exceptionClass: Class<T>, message: String?, block: () -> Unit): T {
@@ -28,9 +30,12 @@ fun <T : Throwable> assertFailsWith(exceptionClass: Class<T>, message: String?,
throw IllegalStateException(msg + "Should have failed.")
}
/** Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown. */
fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit): T = assertFailsWith(exceptionClass, null, block)
/** Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown. */
@Suppress("DEPRECATION")
fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String? = null, block: () -> Unit): T = assertFailsWith(exceptionClass.javaClass, message, block)
fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?, block: () -> Unit): T = assertFailsWith(exceptionClass.javaClass, message, block)
/** Asserts that a [block] fails with a specific exception of type [T] being thrown.
* Since inline method doesn't allow to trace where it was invoked, it is required to pass a [message] to distinguish this method call from others.
@@ -175,13 +175,3 @@ interface AsserterContributor {
fun contribute(): Asserter?
}
internal fun <T, R> T.let(block: (T) -> R): R = block(this)
internal fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T? {
for (e in this) {
if (predicate(e)) {
return e
}
}
return null
}
@@ -0,0 +1,4 @@
package kotlin.test
internal fun <T, R> T.let(block: (T) -> R): R = block(this)
@@ -24,6 +24,13 @@ class BasicAssertionsJVMTest {
throw IllegalArgumentException()
}
}
@Test
fun testFailsWithClassMessage() {
@Suppress("UNCHECKED_CAST")
assertFailsWith(Class.forName("java.lang.IllegalArgumentException") as Class<Throwable>) {
throw IllegalArgumentException()
}
}
@Test
fun testToDo() {
+1 -1
View File
@@ -21,7 +21,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin.test.jvm</artifactId>
<artifactId>kotlin.test.junit</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
@@ -23,7 +23,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin.test.jvm</artifactId>
<artifactId>kotlin.test.junit</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>