moved the stdlib tests into the same directory as the stdlib, so it works a bit better with maven support in IDEA

This commit is contained in:
James Strachan
2012-03-14 16:14:04 +00:00
parent 9cd21d3a4d
commit 7ef65c0099
35 changed files with 2 additions and 2 deletions
+42
View File
@@ -0,0 +1,42 @@
package test.standard
import kotlin.*
import kotlin.test.*
import junit.framework.TestCase
class GetOrElseTest() : TestCase() {
val v1: String? = "hello"
val v2: String? = null
var counter = 0
fun testDefaultValue() {
assertEquals("hello", v1?: "bar")
expect("hello") {
v1?: "bar"
}
}
fun testDefaultValueOnNull() {
assertEquals("bar", v2?: "bar")
expect("bar") {
v2?: "bar"
}
}
fun calculateBar(): String {
counter++
return "bar"
}
fun testLazyDefaultValue() {
counter = 0
assertEquals("hello", v1?: calculateBar())
assertEquals(counter, 0, "counter should not be incremented yet")
assertEquals("bar", v2?: calculateBar())
assertEquals(counter, 1, "counter should be incremented in the default function")
}
}