Remove obsolete and not relevant to stdlib tests
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
package test.dataclass
|
||||
|
||||
import org.junit.Test
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
class DataClassTest {
|
||||
@Test
|
||||
fun dataClass() {
|
||||
val p = Person("James", 43)
|
||||
println("Got $p")
|
||||
assertEquals("Person(name=James, age=43)", "$p", "toString")
|
||||
|
||||
val (a, b) = p
|
||||
assertEquals("James", a, "a")
|
||||
assertEquals(43, b, "b")
|
||||
|
||||
assertEquals(Person("James", 43), Person("James", 43), "person equals")
|
||||
|
||||
// TODO not implemented yet
|
||||
// assertTrue(Person("ZZZ", 21) > Person("AAA", 21), "person a > b")
|
||||
}
|
||||
}
|
||||
|
||||
data class Person(val name: String, val age: Int)
|
||||
@@ -1,42 +0,0 @@
|
||||
package test.standard
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.test.*
|
||||
import org.junit.Test as test
|
||||
|
||||
class GetOrElseTest {
|
||||
val v1: String? = "hello"
|
||||
val v2: String? = null
|
||||
var counter = 0
|
||||
|
||||
@test fun defaultValue() {
|
||||
assertEquals("hello", v1?: "bar")
|
||||
|
||||
expect("hello") {
|
||||
v1?: "bar"
|
||||
}
|
||||
}
|
||||
|
||||
@test fun defaultValueOnNull() {
|
||||
assertEquals("bar", v2?: "bar")
|
||||
|
||||
expect("bar") {
|
||||
v2?: "bar"
|
||||
}
|
||||
}
|
||||
|
||||
fun calculateBar(): String {
|
||||
counter++
|
||||
return "bar"
|
||||
}
|
||||
|
||||
@test fun lazyDefaultValue() {
|
||||
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")
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package testjc
|
||||
|
||||
import kotlin.test.*
|
||||
import junit.framework.TestCase
|
||||
import java.util.*
|
||||
|
||||
class C()
|
||||
|
||||
class JavaClassTest() : TestCase() {
|
||||
fun testMe () {
|
||||
assertEquals("java.util.ArrayList", java.util.ArrayList<Any>().javaClass.name)
|
||||
assertEquals("java.util.ArrayList", ArrayList::class.java.name)
|
||||
assertEquals("testjc.C", C::class.java.name)
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package test.collections
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.io.*
|
||||
import kotlin.test.*
|
||||
import org.junit.Test as test
|
||||
|
||||
class OldStdlibTest() {
|
||||
@test fun testCollectionEmpty() {
|
||||
assertFalse {
|
||||
listOf(0, 1, 2).isEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
@test fun testCollectionSize() {
|
||||
assertTrue {
|
||||
listOf(0, 1, 2).size == 3
|
||||
}
|
||||
}
|
||||
|
||||
@test fun testInputStreamIterator() {
|
||||
val x = ByteArray (10)
|
||||
|
||||
for(index in 0..9) {
|
||||
x [index] = index.toByte()
|
||||
}
|
||||
|
||||
x.inputStream().buffered().use { stream ->
|
||||
for(b in stream) {
|
||||
println(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class IOStreamsTest {
|
||||
} finally {
|
||||
writer?.close()
|
||||
}
|
||||
var act: String?
|
||||
val act: String?
|
||||
var reader: BufferedReader? = null
|
||||
try {
|
||||
reader = tmpFile.inputStream().reader().buffered()
|
||||
@@ -25,4 +25,18 @@ class IOStreamsTest {
|
||||
}
|
||||
assertEquals("Hello, World!", act)
|
||||
}
|
||||
|
||||
@test fun testInputStreamIterator() {
|
||||
val x = ByteArray(10) { it.toByte() }
|
||||
|
||||
val result = mutableListOf<Byte>()
|
||||
|
||||
x.inputStream().buffered().use { stream ->
|
||||
for(b in stream) {
|
||||
result += b
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(x.asList(), result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package testPackage
|
||||
|
||||
import org.junit.Test as test
|
||||
import kotlin.test.*
|
||||
|
||||
class SimpleTest {
|
||||
|
||||
public fun testFoo() {
|
||||
val name = "world"
|
||||
val message = "hello $name!"
|
||||
assertEquals("hello world!", message)
|
||||
}
|
||||
|
||||
@test fun cheese() {
|
||||
val name = "world"
|
||||
val message = "bye $name!"
|
||||
assertEquals("bye world!", message)
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package language
|
||||
|
||||
import org.junit.Test as test
|
||||
import kotlin.test.*
|
||||
|
||||
class Product(val name: String, val price: Double) {
|
||||
}
|
||||
|
||||
class Customer(val name: String, val products: List<Product>) {
|
||||
}
|
||||
|
||||
|
||||
fun customerTemplate(customer: Customer) = """
|
||||
<html>
|
||||
<body>
|
||||
<h1>Hello ${customer.name}</h1>
|
||||
<ul>
|
||||
${customer.products.map{ productSnippet(it) }.joinToString("\n")}
|
||||
</ul>
|
||||
<p>lets do some kool stuff</p>
|
||||
</body>
|
||||
"""
|
||||
|
||||
fun productSnippet(product: Product) = "<li>${product.name}. Price : ${product.price}</li>"
|
||||
|
||||
// TODO support number formatting methods?
|
||||
// fun productSnippet(product: Product) = "<li>${product.name}. Price : ${product.price.format('## ###,00')} </li>"
|
||||
|
||||
val EXPECTED = """
|
||||
<html>
|
||||
<body>
|
||||
<h1>Hello James</h1>
|
||||
<ul>
|
||||
<li>Beer. Price : 1.99</li>
|
||||
<li>Wine. Price : 5.99</li>
|
||||
</ul>
|
||||
<p>lets do some kool stuff</p>
|
||||
</body>
|
||||
"""
|
||||
|
||||
class StringExpressionExampleTest {
|
||||
val customer = Customer("James", arrayListOf(Product("Beer", 1.99), Product("Wine", 5.99)))
|
||||
|
||||
@test fun testExpressions(): Unit {
|
||||
assertEquals(EXPECTED, customerTemplate(customer))
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package language.main
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println("Hello world!")
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package language.mainint
|
||||
|
||||
fun main(args: Array<String>): Int {
|
||||
println("Hello world: Int")
|
||||
return 0
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package language.mainunit
|
||||
|
||||
fun main(args: Array<String>): Unit {
|
||||
println("Hello world: Unit")
|
||||
}
|
||||
Reference in New Issue
Block a user