Make kotlin-test tests compile as tests for multiplatform project
Also remove utils not needed anymore.
This commit is contained in:
@@ -6,14 +6,6 @@ dependencies {
|
|||||||
compile project(':kotlin-stdlib-common')
|
compile project(':kotlin-stdlib-common')
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
test {
|
|
||||||
kotlin {
|
|
||||||
srcDir 'src/test'
|
|
||||||
exclude '**'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// common block
|
// common block
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package kotlin.test.tests
|
|
||||||
|
|
||||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
|
||||||
internal operator fun String.contains(sub: String) = (this as java.lang.String).contains(sub)
|
|
||||||
|
|
||||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
|
||||||
internal fun String.startsWith(other: String) = (this as java.lang.String).startsWith(other)
|
|
||||||
+50
-46
@@ -14,49 +14,55 @@ class BasicAssertionsTest {
|
|||||||
assertEquals("a", "a")
|
assertEquals("a", "a")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test
|
||||||
|
fun testAssertFailsWith() {
|
||||||
|
assertFailsWith<IllegalStateException> { throw IllegalStateException() }
|
||||||
|
assertFailsWith<AssertionError> { throw AssertionError() }
|
||||||
|
|
||||||
|
run {
|
||||||
|
try {
|
||||||
|
assertFailsWith<IllegalStateException> { throw IllegalArgumentException() }
|
||||||
|
}
|
||||||
|
catch (e: AssertionError) {
|
||||||
|
return@run
|
||||||
|
}
|
||||||
|
throw AssertionError("Expected to fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
run {
|
||||||
|
try {
|
||||||
|
assertFailsWith<IllegalStateException> { }
|
||||||
|
}
|
||||||
|
catch (e: AssertionError) {
|
||||||
|
return@run
|
||||||
|
}
|
||||||
|
throw AssertionError("Expected to fail")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
fun testAssertEqualsFails() {
|
fun testAssertEqualsFails() {
|
||||||
assertEquals(1, 2)
|
assertFailsWith<AssertionError> { assertEquals(1, 2) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAssertTrue() {
|
fun testAssertTrue() {
|
||||||
assertTrue(true)
|
assertTrue(true)
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testAssertTrueWithLambda() {
|
|
||||||
assertTrue { true }
|
assertTrue { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test()
|
||||||
fun testAssertTrueFails() {
|
fun testAssertTrueFails() {
|
||||||
assertTrue(false)
|
assertFailsWith<AssertionError> { assertTrue(false) }
|
||||||
}
|
assertFailsWith<AssertionError> { assertTrue { false } }
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
|
||||||
fun testAssertTrueWithLambdaFails() {
|
|
||||||
assertTrue { false }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAssertFalse() {
|
fun testAssertFalse() {
|
||||||
assertFalse(false)
|
assertFalse(false)
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testAssertFalseLambda() {
|
|
||||||
assertFalse { false }
|
assertFalse { false }
|
||||||
}
|
assertFailsWith<AssertionError> { assertFalse(true) }
|
||||||
|
assertFailsWith<AssertionError> { assertFalse { true } }
|
||||||
@Test(expected = AssertionError::class)
|
|
||||||
fun testAssertFalseFails() {
|
|
||||||
assertFalse(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
|
||||||
fun testAssertFalseWithLambdaFails() {
|
|
||||||
assertFalse { true }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -64,10 +70,9 @@ class BasicAssertionsTest {
|
|||||||
assertFails { throw IllegalStateException() }
|
assertFails { throw IllegalStateException() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test()
|
||||||
fun testAssertFailsFails() {
|
fun testAssertFailsFails() {
|
||||||
assertFails { }
|
assertFailsWith<AssertionError> { assertFails { } }
|
||||||
Assert.fail("Shouldn't pass here")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,9 +81,9 @@ class BasicAssertionsTest {
|
|||||||
assertNotEquals(1, 2)
|
assertNotEquals(1, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test()
|
||||||
fun testAssertNotEqualsFails() {
|
fun testAssertNotEqualsFails() {
|
||||||
assertNotEquals(1, 1)
|
assertFailsWith<AssertionError> { assertNotEquals(1, 1) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -86,9 +91,9 @@ class BasicAssertionsTest {
|
|||||||
assertNotNull(true)
|
assertNotNull(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test()
|
||||||
fun testAssertNotNullFails() {
|
fun testAssertNotNullFails() {
|
||||||
assertNotNull(null)
|
assertFailsWith<AssertionError> { assertNotNull(null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -96,11 +101,13 @@ class BasicAssertionsTest {
|
|||||||
assertNotNull("") { assertEquals("", it) }
|
assertNotNull("") { assertEquals("", it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test
|
||||||
fun testAssertNotNullLambdaFails() {
|
fun testAssertNotNullLambdaFails() {
|
||||||
assertNotNull(null) {
|
assertFailsWith<AssertionError> {
|
||||||
@Suppress("UNREACHABLE_CODE")
|
val value: String? = null
|
||||||
assertNotNull(it)
|
assertNotNull(value) {
|
||||||
|
it.substring(0, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,23 +116,20 @@ class BasicAssertionsTest {
|
|||||||
assertNull(null)
|
assertNull(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test
|
||||||
fun testAssertNullFails() {
|
fun testAssertNullFails() {
|
||||||
assertNull(true)
|
assertFailsWith<AssertionError> { assertNull("") }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
@Test()
|
||||||
fun testFail() {
|
fun testFail() {
|
||||||
fail("should fail")
|
assertFailsWith<AssertionError> { fail("should fail") }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testExpect() {
|
fun testExpect() {
|
||||||
expect(1) { 1 }
|
expect(1) { 1 }
|
||||||
|
assertFailsWith<AssertionError> { expect(1) { 2 } }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError::class)
|
|
||||||
fun testExpectFails() {
|
|
||||||
expect(1) { 2 }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package kotlin.test.tests
|
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
internal fun <T> listOf(vararg elements: T): List<T> {
|
|
||||||
val result = ArrayList<T>(elements.size)
|
|
||||||
for (e in elements) {
|
|
||||||
result.add(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun <T> setOf(vararg elements: T): Set<T> {
|
|
||||||
val result = HashSet<T>(elements.size)
|
|
||||||
for (e in elements) {
|
|
||||||
result.add(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -18,6 +18,9 @@ compileKotlin2Js {
|
|||||||
|
|
||||||
compileTestKotlin2Js {
|
compileTestKotlin2Js {
|
||||||
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
|
||||||
|
kotlinOptions {
|
||||||
|
metaInfo = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user