Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise they would be ignored according .gitignore settings. Probably they should be deleted from repo. Interop/.idea/compiler.xml Interop/.idea/gradle.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml Interop/.idea/modules.xml Interop/.idea/modules/Indexer/Indexer.iml Interop/.idea/modules/Runtime/Runtime.iml Interop/.idea/modules/StubGenerator/StubGenerator.iml backend.native/backend.native.iml backend.native/bc.frontend/bc.frontend.iml backend.native/cli.bc/cli.bc.iml backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt backend.native/tests/link/lib/foo.kt backend.native/tests/link/lib/foo2.kt backend.native/tests/teamcity-test.property
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 kotlin.test.tests
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.native.internal.test.*
|
||||
|
||||
@Ignore
|
||||
class IgnoredClass {
|
||||
@Ignore object IgnoredObject {
|
||||
@Test fun test() { throw AssertionError("Ignored test") }
|
||||
}
|
||||
|
||||
@Test fun test() { throw AssertionError("Ignored test") }
|
||||
}
|
||||
|
||||
@Ignore
|
||||
object IgnoredObject {
|
||||
@Test fun test() { throw AssertionError("Ignored test") }
|
||||
}
|
||||
|
||||
class A {
|
||||
companion object {
|
||||
@BeforeTest fun before() { println("before (A.companion)") }
|
||||
@AfterTest fun after() { println("after (A.companion)") }
|
||||
@Test fun test1() { println("test1 (A.companion)") }
|
||||
|
||||
@BeforeClass fun beforeClass() { println("beforeClass (A.companion)") }
|
||||
@AfterClass fun afterClass() { println("afterClass (A.companion)") }
|
||||
}
|
||||
|
||||
@BeforeTest fun before() { println("before (A)") }
|
||||
@AfterTest fun after() { println("after (A)") }
|
||||
@Test fun test1() { println("test1 (A)") }
|
||||
@Ignore @Test fun ignoredTest() { throw AssertionError("Ignored test") }
|
||||
|
||||
@BeforeClass fun beforeClass() { println("beforeClass (A)") }
|
||||
@AfterClass fun afterClass() { println("afterClass (A)") }
|
||||
|
||||
object O {
|
||||
@BeforeTest fun before() { println("before (A.object)") }
|
||||
@AfterTest fun after() { println("after (A.object)") }
|
||||
@Test fun test1() { println("test1 (A.object)") }
|
||||
@Ignore @Test fun ignoredTest() { throw AssertionError("Ignored test") }
|
||||
|
||||
@BeforeClass fun beforeClass() { println("beforeClass (A.object)") }
|
||||
@AfterClass fun afterClass() { println("afterClass (A.object)") }
|
||||
}
|
||||
}
|
||||
|
||||
object O {
|
||||
@BeforeTest fun before() { println("before (object)") }
|
||||
@AfterTest fun after() { println("after (object)") }
|
||||
@Test fun test1() { println("test1 (object)") }
|
||||
@Ignore @Test fun ignoredTest() { throw AssertionError("Ignored test") }
|
||||
|
||||
@BeforeClass fun beforeClass() { println("beforeClass (object)") }
|
||||
@AfterClass fun afterClass() { println("afterClass (object)") }
|
||||
}
|
||||
|
||||
@BeforeTest fun before() { println("before (file)") }
|
||||
@AfterTest fun after() { println("after (file)") }
|
||||
@Test fun test1() { println("test1 (file)") }
|
||||
@Ignore @Test fun ignoredTest() { throw AssertionError("Ignored test") }
|
||||
|
||||
@BeforeClass fun beforeClass() { println("beforeClass (file)") }
|
||||
@AfterClass fun afterClass() { println("afterClass (file)") }
|
||||
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* 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 kotlin.test.tests
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class BasicAssertionsTest {
|
||||
@Test
|
||||
fun testAssertEquals() {
|
||||
assertEquals(1, 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertEqualsString() {
|
||||
assertEquals("a", "a")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertFailsWith() {
|
||||
assertFailsWith<IllegalStateException> { throw IllegalStateException() }
|
||||
assertFailsWith<AssertionError> { throw AssertionError() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertFailsWithFails() {
|
||||
withDefaultAsserter run@ {
|
||||
try {
|
||||
assertFailsWith<IllegalStateException> { throw IllegalArgumentException() }
|
||||
}
|
||||
catch (e: AssertionError) {
|
||||
return@run
|
||||
}
|
||||
throw AssertionError("Expected to fail")
|
||||
}
|
||||
withDefaultAsserter run@ {
|
||||
try {
|
||||
assertFailsWith<IllegalStateException> { }
|
||||
}
|
||||
catch (e: AssertionError) {
|
||||
return@run
|
||||
}
|
||||
throw AssertionError("Expected to fail")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertFailsWithClass() {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
throw IllegalArgumentException("This is illegal")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertFailsWithClassFails() {
|
||||
checkFailedAssertion {
|
||||
assertFailsWith<IllegalArgumentException> { throw IllegalStateException() }
|
||||
}
|
||||
|
||||
checkFailedAssertion {
|
||||
assertFailsWith<Exception> { }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertEqualsFails() {
|
||||
checkFailedAssertion { assertEquals(1, 2) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertTrue() {
|
||||
assertTrue(true)
|
||||
assertTrue { true }
|
||||
}
|
||||
|
||||
@Test()
|
||||
fun testAssertTrueFails() {
|
||||
checkFailedAssertion { assertTrue(false) }
|
||||
checkFailedAssertion { assertTrue { false } }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertFalse() {
|
||||
assertFalse(false)
|
||||
assertFalse { false }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertFalseFails() {
|
||||
checkFailedAssertion { assertFalse(true) }
|
||||
checkFailedAssertion{ assertFalse { true } }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertFails() {
|
||||
assertFails { throw IllegalStateException() }
|
||||
}
|
||||
|
||||
@Test()
|
||||
fun testAssertFailsFails() {
|
||||
checkFailedAssertion { assertFails { } }
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testAssertNotEquals() {
|
||||
assertNotEquals(1, 2)
|
||||
}
|
||||
|
||||
@Test()
|
||||
fun testAssertNotEqualsFails() {
|
||||
checkFailedAssertion { assertNotEquals(1, 1) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertNotNull() {
|
||||
assertNotNull(true)
|
||||
}
|
||||
|
||||
@Test()
|
||||
fun testAssertNotNullFails() {
|
||||
checkFailedAssertion { assertNotNull(null) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertNotNullLambda() {
|
||||
assertNotNull("") { assertEquals("", it) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertNotNullLambdaFails() {
|
||||
checkFailedAssertion {
|
||||
val value: String? = null
|
||||
assertNotNull(value) {
|
||||
it.substring(0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertNull() {
|
||||
assertNull(null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAssertNullFails() {
|
||||
checkFailedAssertion { assertNull("") }
|
||||
}
|
||||
|
||||
@Test()
|
||||
fun testFail() {
|
||||
checkFailedAssertion { fail("should fail") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExpect() {
|
||||
expect(1) { 1 }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExpectFails() {
|
||||
checkFailedAssertion { expect(1) { 2 } }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testContracts() {
|
||||
open class S
|
||||
class P(val str: String = "P") : S()
|
||||
|
||||
val s: S = P()
|
||||
val p: Any = P("A")
|
||||
|
||||
assertTrue(s is P)
|
||||
assertEquals("P", s.str)
|
||||
assertFalse(p !is P)
|
||||
assertEquals("A", p.str)
|
||||
|
||||
val nullableT: P? = P("N")
|
||||
assertNotNull(nullableT)
|
||||
assertEquals("N", nullableT.str)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun checkFailedAssertion(assertion: () -> Unit) {
|
||||
assertFailsWith<AssertionError> { withDefaultAsserter(assertion) }
|
||||
}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER")
|
||||
private fun withDefaultAsserter(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 kotlin.test.tests
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.native.internal.test.*
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
println("test")
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println("Custom main")
|
||||
testLauncherEntryPoint(args)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package kotlin.test.tests
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class A {
|
||||
@Test
|
||||
fun foo1() {}
|
||||
|
||||
@Test
|
||||
fun foo2() {}
|
||||
|
||||
@Test
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
class B {
|
||||
@Test
|
||||
fun foo1() {}
|
||||
|
||||
@Test
|
||||
fun foo2() {}
|
||||
|
||||
@Test
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun foo1() {}
|
||||
|
||||
@Test
|
||||
fun foo2() {}
|
||||
|
||||
@Test
|
||||
fun bar() {}
|
||||
@@ -0,0 +1,66 @@
|
||||
package library
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val output = mutableListOf<String>()
|
||||
|
||||
interface I1 {
|
||||
@Test
|
||||
fun foo()
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
@Test
|
||||
fun foo()
|
||||
}
|
||||
|
||||
open class A {
|
||||
|
||||
@BeforeTest
|
||||
open fun before() {
|
||||
output.add("A.before")
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
open fun after() {
|
||||
output.add("A.after")
|
||||
}
|
||||
|
||||
@Test
|
||||
open fun test0() {
|
||||
output.add("A.test0")
|
||||
}
|
||||
|
||||
@Test
|
||||
open fun test1() {
|
||||
output.add("A.test1")
|
||||
}
|
||||
|
||||
@Test
|
||||
open fun test2() {
|
||||
output.add("A.test2")
|
||||
}
|
||||
|
||||
@Test
|
||||
open fun test3() {
|
||||
output.add("A.test3")
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
open fun ignored0() {
|
||||
output.add("A.ignored0")
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
open fun ignored1() {
|
||||
output.add("A.ignored1")
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
open fun ignored2() {
|
||||
output.add("A.ignored2")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import kotlin.native.internal.test.*
|
||||
import kotlin.test.*
|
||||
import library.*
|
||||
|
||||
open class B : A() {
|
||||
// Override test methods without a test annotation.
|
||||
// We should run these methods anyway.
|
||||
|
||||
override fun before() {
|
||||
output.add("B.before")
|
||||
}
|
||||
|
||||
// test0 should be executed.
|
||||
|
||||
// Should be executed.
|
||||
override fun test1() {
|
||||
output.add("B.test1")
|
||||
}
|
||||
|
||||
// Should be executed
|
||||
@Ignore
|
||||
override fun test2() {
|
||||
output.add("B.test2")
|
||||
}
|
||||
|
||||
// Should be ignored.
|
||||
@Ignore
|
||||
@Test
|
||||
override fun test3() {
|
||||
output.add("B.test3")
|
||||
}
|
||||
|
||||
// ignored0 should be ignored.
|
||||
|
||||
// Should be ignored.
|
||||
override fun ignored1() {
|
||||
output.add("B.ignored1")
|
||||
}
|
||||
|
||||
// Should be executed.
|
||||
@Test
|
||||
override fun ignored2() {
|
||||
output.add("B.ignored2")
|
||||
}
|
||||
}
|
||||
|
||||
// All test methods from B should be executed for C.
|
||||
class C: B() {}
|
||||
|
||||
class D: I1, I2 {
|
||||
// This method shouldn't be executed because its parent methods annotated
|
||||
// with @Test belong to an interface instead of an abstract class.
|
||||
override fun foo(){
|
||||
output.add("D.foo")
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
testLauncherEntryPoint(args)
|
||||
output.forEach(::println)
|
||||
assertEquals(8, output.count { it == "A.after" })
|
||||
assertEquals(8, output.count { it == "B.before" })
|
||||
|
||||
assertEquals(2, output.count { it == "A.test0" })
|
||||
assertEquals(2, output.count { it == "B.test1" })
|
||||
assertEquals(2, output.count { it == "B.test2" })
|
||||
assertEquals(2, output.count { it == "B.ignored2" })
|
||||
|
||||
assertTrue(output.none { it == "B.test3" })
|
||||
assertTrue(output.none { it == "A.ignored0" })
|
||||
assertTrue(output.none { it == "B.ignored1" })
|
||||
|
||||
assertTrue(output.none { it == "D.foo" })
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package kotlin.test.tests
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Ignore
|
||||
class Ignored {
|
||||
@Test
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class Failed {
|
||||
@Test
|
||||
fun bar() {
|
||||
try {
|
||||
baz()
|
||||
} catch(e: Exception) {
|
||||
throw Exception("Bar", e)
|
||||
}
|
||||
}
|
||||
|
||||
fun baz() {
|
||||
throw Exception("Baz")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user