Clean TODOs and commented code which works.

This commit is contained in:
Ilya Ryzhenkov
2014-03-05 20:33:13 +04:00
committed by Andrey Breslav
parent 266f6ad81a
commit fb7034a472
6 changed files with 21 additions and 23 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ public fun <T> 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 <T, R> assertNotNull(actual: T?, block: (T) -> R) {
assertNotNull(actual, "", block)
+2 -3
View File
@@ -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)
+11 -12
View File
@@ -33,7 +33,7 @@ class PreconditionsTest() {
test fun failingRequireWithLazyMessage() {
val error = failsWith(javaClass<IllegalArgumentException>()) {
require(false) {"Hello"}
require(false) { "Hello" }
}
assertEquals("Hello", error.getMessage())
}
@@ -66,7 +66,7 @@ class PreconditionsTest() {
test fun failingCheckWithLazyMessage() {
val error = failsWith(javaClass<IllegalStateException>()) {
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)
}
}
}
@@ -30,7 +30,7 @@ fun productSnippet(product: Product) = "<li>${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))
@@ -9,7 +9,7 @@ import junit.framework.TestCase
class Kt1617Test: TestCase() {
fun testMapFunction() {
val coll: Collection<String> = arrayList("foo", "bar")
val coll: Collection<String> = arrayListOf("foo", "bar")
val files = coll.map{ File(it) }
@@ -1,16 +1,16 @@
package regressions
import junit.framework.TestCase
import kotlin.test.expect
class Kt1619Test: TestCase() {
fun doSomething(list: List<String?>): Boolean {
return list.size() > 0
fun doSomething(list: List<String?>): Int {
return list.size()
}
fun testCollectionNotNullCanBeUsedForNullables() {
val list: List<String> = arrayList("foo", "bar")
// TODO uncomment this line to reproduce KT-1619
// doSomething(list)
val list: List<String> = arrayListOf("foo", "bar")
expect(2) { doSomething(list) }
}
}