diff --git a/libraries/stdlib/src/kotlin/test/Test.kt b/libraries/stdlib/src/kotlin/test/Test.kt index b63a762e10c..d35700281d8 100644 --- a/libraries/stdlib/src/kotlin/test/Test.kt +++ b/libraries/stdlib/src/kotlin/test/Test.kt @@ -44,7 +44,7 @@ public fun assertNotNull(actual: T?, message: String = ""): T { return actual!! } -//TODO merge with next via default +//TODO merge with next via default (currently inline functions do not support default values) /** Asserts that the expression is not null, with an optional message and a function block to process the not-null value */ public inline fun assertNotNull(actual: T?, block: (T) -> R) { assertNotNull(actual, "", block) diff --git a/libraries/stdlib/test/ExceptionTest.kt b/libraries/stdlib/test/ExceptionTest.kt index 07b7b2744a8..5481959a823 100644 --- a/libraries/stdlib/test/ExceptionTest.kt +++ b/libraries/stdlib/test/ExceptionTest.kt @@ -29,12 +29,11 @@ class ExceptionTest { fun assertPrintStackTraceStream(t: Throwable) { val byteBuffer = ByteArrayOutputStream() -/* - // TODO compiler error + PrintStream(byteBuffer).use { t.printStackTrace(it) } -*/ + val stream = PrintStream(byteBuffer) stream.use { t.printStackTrace(stream) diff --git a/libraries/stdlib/test/PreconditionsTest.kt b/libraries/stdlib/test/PreconditionsTest.kt index 4ba0b97c93f..c88448050ff 100644 --- a/libraries/stdlib/test/PreconditionsTest.kt +++ b/libraries/stdlib/test/PreconditionsTest.kt @@ -33,7 +33,7 @@ class PreconditionsTest() { test fun failingRequireWithLazyMessage() { val error = failsWith(javaClass()) { - require(false) {"Hello"} + require(false) { "Hello" } } assertEquals("Hello", error.getMessage()) } @@ -66,7 +66,7 @@ class PreconditionsTest() { test fun failingCheckWithLazyMessage() { val error = failsWith(javaClass()) { - check(false) {"Hello"} + check(false) { "Hello" } } assertEquals("Hello", error.getMessage()) } @@ -105,16 +105,15 @@ class PreconditionsTest() { assertFalse(called) } - test fun failingAssert() { - val assertDefaultMessage = "Assertion failed" + test fun failingAssert() { val error = fails { assert(false) } - if(error is AssertionError) { - assertEquals(assertDefaultMessage, error.getMessage()) + if (error is AssertionError) { + assertEquals("Assertion failed", error.getMessage()) } else { - fail("Invalid exception type: "+error) + fail("Invalid exception type: " + error) } } @@ -126,21 +125,21 @@ class PreconditionsTest() { val error = fails { assert(false, "Hello") } - if(error is AssertionError) { + if (error is AssertionError) { assertEquals("Hello", error.getMessage()) } else { - fail("Invalid exception type: "+error) + fail("Invalid exception type: " + error) } } test fun failingAssertWithLazyMessage() { val error = fails { - assert(false) {"Hello"} + assert(false) { "Hello" } } - if(error is AssertionError) { + if (error is AssertionError) { assertEquals("Hello", error.getMessage()) } else { - fail("Invalid exception type: "+error) + fail("Invalid exception type: " + error) } } } \ No newline at end of file diff --git a/libraries/stdlib/test/language/StringExpressionExampleTest.kt b/libraries/stdlib/test/language/StringExpressionExampleTest.kt index 4f7bebbc7dd..8c1634d002a 100644 --- a/libraries/stdlib/test/language/StringExpressionExampleTest.kt +++ b/libraries/stdlib/test/language/StringExpressionExampleTest.kt @@ -30,7 +30,7 @@ fun productSnippet(product: Product) = "
  • ${product.name}. Price : ${product.p class StringExpressionExampleTest : TestCase() { - val customer = Customer("James", arrayList(Product("Beer", 1.99), Product("Wine", 5.99))) + val customer = Customer("James", arrayListOf(Product("Beer", 1.99), Product("Wine", 5.99))) fun testExpressions(): Unit { println(customerTemplate(customer)) diff --git a/libraries/stdlib/test/regressions/Kt1617Test.kt b/libraries/stdlib/test/regressions/Kt1617Test.kt index 4dade12a55f..f8c808fd239 100644 --- a/libraries/stdlib/test/regressions/Kt1617Test.kt +++ b/libraries/stdlib/test/regressions/Kt1617Test.kt @@ -9,7 +9,7 @@ import junit.framework.TestCase class Kt1617Test: TestCase() { fun testMapFunction() { - val coll: Collection = arrayList("foo", "bar") + val coll: Collection = arrayListOf("foo", "bar") val files = coll.map{ File(it) } diff --git a/libraries/stdlib/test/regressions/Kt1619Test.kt b/libraries/stdlib/test/regressions/Kt1619Test.kt index f9881fe374e..5a8c357a497 100644 --- a/libraries/stdlib/test/regressions/Kt1619Test.kt +++ b/libraries/stdlib/test/regressions/Kt1619Test.kt @@ -1,16 +1,16 @@ package regressions import junit.framework.TestCase +import kotlin.test.expect class Kt1619Test: TestCase() { - fun doSomething(list: List): Boolean { - return list.size() > 0 + fun doSomething(list: List): Int { + return list.size() } fun testCollectionNotNullCanBeUsedForNullables() { - val list: List = arrayList("foo", "bar") - // TODO uncomment this line to reproduce KT-1619 - // doSomething(list) + val list: List = arrayListOf("foo", "bar") + expect(2) { doSomething(list) } } } \ No newline at end of file