BC native tests port to Konan's TestRunner

This commit is contained in:
Pavel Punegov
2017-10-11 15:09:33 +03:00
parent 9b07fd61ce
commit 9d077d7f4f
352 changed files with 1798 additions and 384 deletions
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.empty_substring
import kotlin.test.*
@Test fun runTest() {
val hello = "Hello world"
println(hello.subSequence(1, 1).toString())
}
+1 -1
View File
@@ -1,4 +1,4 @@
package koko.lala
package runtime.basic.entry0
fun fail() {
println("Test failed, this is a wrong main() function.")
@@ -1,3 +1,5 @@
package runtime.basic.entry1
fun fail() {
println("Test failed, this is a wrong main() function.")
}
@@ -1,3 +1,5 @@
package runtime.basic.entry2
fun main(args: Array<String>) {
fail()
}
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.for0
import kotlin.test.*
@Test fun runTest() {
val byteArray = ByteArray(3)
byteArray[0] = 2
byteArray[1] = 3
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.hash0
import kotlin.test.*
@Test fun runTest() {
println(239.hashCode())
println((-1L).hashCode())
println('a'.hashCode())
+5 -1
View File
@@ -1,3 +1,7 @@
fun main(args : Array<String>) {
package runtime.basic.hello0
import kotlin.test.*
@Test fun runTest() {
println("Hello, world!")
}
@@ -1,3 +1,4 @@
// TODO: TestRuner should be able to pass input to stdin
// TODO: remove kotlin_native.io once overrides are in place.
fun main(args : Array<String>) {
print(readLine().toString())
@@ -1,3 +1,4 @@
// TODO: TestRuner should be able to pass input to stdin
// TODO: remove kotlin_native.io once overrides are in place.
fun main(args : Array<String>) {
print("you entered '" + readLine() + "'")
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.hello3
import kotlin.test.*
@Test fun runTest() {
println(239)
// TODO: enable, once override by name is implemented.
println(true)
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.hello4
import kotlin.test.*
@Test fun runTest() {
val x = 2
println(if (x == 2) "Hello" else "Привет")
println(if (x == 3) "Bye" else "Пока")
@@ -1,3 +1,7 @@
package runtime.basic.initializers0
import kotlin.test.*
class A {
init{
println ("A::init")
@@ -25,7 +29,7 @@ class A {
}
}
fun main(args:Array<String>) {
@Test fun runTest() {
println("main")
A.foo()
A.foo()
@@ -1,4 +1,8 @@
class Test {
package runtime.basic.initializers1
import kotlin.test.*
class TestClass {
companion object {
init {
println("Init Test")
@@ -6,8 +10,8 @@ class Test {
}
}
fun main(args : Array<String>) {
val t1 = Test()
val t2 = Test()
@Test fun runTest() {
val t1 = TestClass()
val t2 = TestClass()
println("Done")
}
@@ -1,3 +1,7 @@
package runtime.basic.initializers2
import kotlin.test.*
class A(val msg: String) {
init {
println("init $msg")
@@ -9,7 +13,7 @@ val globalValue1 = 1
val globalValue2 = A("globalValue2")
val globalValue3 = A("globalValue3")
fun main(args: Array<String>) {
@Test fun runTest() {
println(globalValue1.toString())
println(globalValue2.toString())
println(globalValue3.toString())
@@ -1,7 +1,11 @@
package runtime.basic.initializers3
import kotlin.test.*
class Foo(val bar: Int)
var x = Foo(42)
fun main(args: Array<String>) {
@Test fun runTest() {
println(x.bar)
}
@@ -1,7 +1,11 @@
package runtime.basic.initializers4
import kotlin.test.*
const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1
val DOUBLE = Double.MAX_VALUE - 1.0
fun main(args: Array<String>) {
@Test fun runTest() {
println(INT_MAX_POWER_OF_TWO)
println(DOUBLE > 0.0)
}
@@ -1,8 +1,12 @@
package runtime.basic.initializers5
import kotlin.test.*
object A {
val a = 42
val b = A.a
}
fun main(args : Array<String>) {
@Test fun runTest() {
println(A.b)
}
@@ -1,3 +1,6 @@
package runtime.basic.interface0
import kotlin.test.*
interface A {
fun b() = c()
@@ -10,7 +13,7 @@ class B(): A {
}
}
fun main(args: Array<String>) {
@Test fun runTest() {
val a:A = B()
a.b()
}
@@ -1,3 +1,5 @@
package runtime.basic.entry2
fun fail() {
println("Test failed, this is a wrong main() function.")
}
@@ -1,10 +1,14 @@
package runtime.basic.standard
import kotlin.test.*
class Foo(val bar: Int)
fun <T> assertEquals(actual: T, expected: T) {
if (actual != expected) throw AssertionError("Assertion failed. Expected value: $expected, actual value: $actual")
}
fun main(args: Array<String>) {
@Test fun runTest() {
try {
TODO()
throw AssertionError("TODO() doesn't throw an exception")
@@ -1,3 +1,7 @@
package runtime.basic.statements0
import kotlin.test.*
fun simple() {
var a = 238
a++
@@ -27,7 +31,7 @@ fun fields() {
println(foo.i)
}
fun main(args: Array<String>) {
@Test fun runTest() {
simple()
fields()
}
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.throw0
import kotlin.test.*
@Test fun runTest() {
val cond = 1
if (cond == 2) throw RuntimeException()
if (cond == 3) throw NoSuchElementException("no such element")
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.tostring0
import kotlin.test.*
@Test fun runTest() {
println(127.toByte().toString())
println(255.toByte().toString())
println(239.toShort().toString())
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.tostring1
import kotlin.test.*
@Test fun runTest() {
val hello = "Hello world"
println(hello.subSequence(1, 5).toString())
}
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.basic.tostring2
import kotlin.test.*
@Test fun runTest() {
val hello = "Hello"
val array = hello.toCharArray()
for (ch in array) {
@@ -1,3 +1,7 @@
package runtime.basic.tostring3
import kotlin.test.*
fun testByte() {
val values = ByteArray(2)
values[0] = Byte.MIN_VALUE
@@ -58,7 +62,7 @@ fun testDouble() {
}
}
fun main(args : Array<String>) {
@Test fun runTest() {
testByte()
testShort()
testInt()
@@ -1,3 +1,7 @@
package runtime.collections.AbstractMutableCollection
import kotlin.test.*
class TestCollection(): AbstractMutableCollection<Int>() {
companion object {
const val SIZE = 7
@@ -48,7 +52,7 @@ fun assertEquals(a: TestCollection, b: List<Int>) {
}
}
fun main(args: Array<String>) {
@Test fun runTest() {
val c = TestCollection()
if (!c.addAll(listOf(1, 2, 3, 2, 4, 5, 4))) throw AssertionError("addAll is false when it must be true.")
if (c.addAll(listOf(1, 2)) != false) throw AssertionError("addAll is true when it must be false.")
@@ -1,3 +1,7 @@
package runtime.collections.BitSet
import kotlin.test.*
fun assertContainsOnly(bitSet: BitSet, trueBits: Set<Int>, size: Int) {
for (i in 0 until size) {
val expectedBit = i in trueBits
@@ -437,7 +441,7 @@ fun testEqualsHashCode() {
assertTrue("Different sized BitSet with higher bits not set returned false", b1 == b3)
}
fun main(args: Array<String>) {
@Test fun runTest() {
testConstructor()
testSet()
testFlip()
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.collections.array0
import kotlin.test.*
@Test fun runTest() {
// Create instances of all array types.
val byteArray = ByteArray(5)
println(byteArray.size.toString())
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.collections.array1
import kotlin.test.*
@Test fun runTest() {
val byteArray = ByteArray(5)
byteArray[1] = 2
byteArray[3] = 4
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.collections.array2
import kotlin.test.*
@Test fun runTest() {
val byteArray = Array<Byte>(5, { i -> (i * 2).toByte() })
byteArray.map { println(it) }
@@ -1,6 +1,10 @@
package runtime.collections.array3
import kotlin.test.*
import konan.*
fun main(args : Array<String>) {
@Test fun runTest() {
val data = immutableBinaryBlobOf(0x1, 0x2, 0x3, 0x7, 0x8, 0x9, 0x80, 0xff)
for (b in data) {
print("$b ")
@@ -1,3 +1,7 @@
package runtime.collections.array_list1
import kotlin.test.*
fun assertTrue(cond: Boolean) {
if (!cond)
println("FAIL")
@@ -342,7 +346,7 @@ fun testIteratorAdd() {
assertEquals(listOf("1", "2", "-2", "3", "4", "-4", "5"), a)
}
fun main(args : Array<String>) {
@Test fun runTest() {
testBasic()
testIterator()
testRemove()
@@ -1,3 +1,7 @@
package runtime.collections.hash_map0
import kotlin.test.*
fun assertTrue(cond: Boolean) {
if (!cond)
println("FAIL")
@@ -247,7 +251,7 @@ fun testEntriesIteratorSet() {
assertEquals(mapOf("a" to "1!", "b" to "2!", "c" to "3!"), m)
}
fun main(args : Array<String>) {
@Test fun runTest() {
testBasic()
testRehashAndCompact()
testClear()
@@ -1,3 +1,7 @@
package runtime.collections.hash_set0
import kotlin.test.*
fun assertTrue(cond: Boolean) {
if (!cond)
println("FAIL")
@@ -118,7 +122,7 @@ fun testRetainAll() {
assertEquals(setOf("1", "3", "5"), s)
}
fun main(args : Array<String>) {
@Test fun runTest() {
testBasic()
testIterator()
testEquals()
@@ -1,3 +1,11 @@
package runtime.collections.listof0
import kotlin.test.*
@Test fun runTest() {
main(arrayOf("a"))
}
fun main(args : Array<String>) {
val nonConstStr = args[0]
val list = arrayListOf(nonConstStr, "b", "c")
@@ -1,5 +1,8 @@
package runtime.collections.moderately_large_array
fun main(args: Array<String>) {
import kotlin.test.*
@Test fun runTest() {
val a = ByteArray(1000000)
var sum = 0
@@ -1,4 +1,8 @@
fun main(args: Array<String>) {
package runtime.collections.moderately_large_array1
import kotlin.test.*
@Test fun runTest() {
val a = Array<Byte>(100000, { i -> i.toByte()})
var sum = 0
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.collections.range0
import kotlin.test.*
@Test fun runTest() {
for (i in 1..3) print(i)
println()
for (i in 'a'..'d') print(i)
@@ -1,4 +1,8 @@
fun main(a: Array<String>) {
package runtime.collections.sort0
import kotlin.test.*
@Test fun runTest() {
println(arrayOf("x", "a", "b").sorted().toString())
println(intArrayOf(239, 42, -1, 100500, 0).sorted().toString());
}
@@ -1,4 +1,8 @@
fun main(a: Array<String>) {
package runtime.collections.sort1
import kotlin.test.*
@Test fun runTest() {
val foo = mutableListOf("x", "a", "b")
foo.sort()
println(foo.toString())
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.exceptions.catch1
import kotlin.test.*
@Test fun runTest() {
try {
println("Before")
foo()
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.exceptions.catch2
import kotlin.test.*
@Test fun runTest() {
try {
println("Before")
foo()
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.exceptions.catch7
import kotlin.test.*
@Test fun runTest() {
try {
foo()
} catch (e: Throwable) {
@@ -1,6 +1,10 @@
package runtime.exceptions.extend0
import kotlin.test.*
class C : Exception("OK")
fun main(args: Array<String>) {
@Test fun runTest() {
try {
throw C()
} catch (e: Throwable) {
@@ -1,10 +1,14 @@
package runtime.memory.basic0
import kotlin.test.*
class A {
var field: B? = null
}
class B(var field: Int)
fun main(args : Array<String>) {
@Test fun runTest() {
val a = A()
a.field = B(2)
}
@@ -1,3 +1,7 @@
package runtime.memory.cycles0
import kotlin.test.*
data class Node(val data: Int, var next: Node?, var prev: Node?, val outer: Node?)
fun makeCycle(len: Int, outer: Node?): Node {
@@ -35,7 +39,7 @@ fun createCycles(junk: Node) {
}
fun main(args : Array<String>) {
@Test fun runTest() {
// Create outer link from cyclic garbage.
val outer = Node(42, null, null, null)
createCycles(outer)
@@ -1,3 +1,7 @@
package runtime.memory.escape0
import kotlin.test.*
//fun foo1(arg: String) : String = foo0(arg)
fun foo1(arg: Any) : Any = foo0(arg)
@@ -46,7 +50,7 @@ fun zoo7(arg1: Any, arg2: Any, selector: Int) : Any {
return if (selector < 2) arg1 else arg2;
}
fun main(args : Array<String>) {
@Test fun runTest() {
//val z = zoo7(Any(), Any(), 1)
val x = zoo5(Any())
//println(bar(foo1(foo2("")), foo2(foo1(""))))
@@ -1,3 +1,7 @@
package runtime.memory.escape1
import kotlin.test.*
class B(val s: String)
class A {
@@ -9,6 +13,6 @@ fun foo(): B {
return a.b
}
fun main(args: Array<String>) {
@Test fun runTest() {
println(foo().s)
}
@@ -1,3 +1,7 @@
package runtime.memory.escape2
import kotlin.test.*
class A(val s: String)
class B {
@@ -17,7 +21,7 @@ fun bar(b: B) {
val global = B()
fun main(args: Array<String>) {
@Test fun runTest() {
bar(global)
println(global.a!!.s)
}
@@ -1,4 +1,8 @@
fun main(args: Array<String>) {
package runtime.memory.throw_cleanup
import kotlin.test.*
@Test fun runTest() {
foo(false)
try {
foo(true)
+5 -1
View File
@@ -1,3 +1,7 @@
package runtime.memory.var1
import kotlin.test.*
class Integer(val value: Int) {
operator fun inc() = Integer(value + 1)
}
@@ -7,7 +11,7 @@ fun foo(x: Any, y: Any) {
y.use()
}
fun main(args : Array<String>) {
@Test fun runTest() {
var x = Integer(0)
for (i in 0..1) {
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.memory.var2
import kotlin.test.*
@Test fun runTest() {
var x = Any()
for (i in 0..1) {
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.memory.var3
import kotlin.test.*
@Test fun runTest() {
foo().use()
}
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args : Array<String>) {
package runtime.memory.var4
import kotlin.test.*
@Test fun runTest() {
var x = Error()
for (i in 0..1) {
+5 -1
View File
@@ -1,3 +1,7 @@
package runtime.text.chars0
import kotlin.test.*
fun assertTrue(v: Boolean) = if (!v) throw AssertionError() else Unit
fun assertFalse(v: Boolean) = if (v) throw AssertionError() else Unit
fun assertEquals(a: Int, b: Int) { if (a != b) throw AssertionError() }
@@ -103,7 +107,7 @@ fun testCategory() {
} catch (e: IllegalArgumentException) {}
}
fun main(args: Array<String>) {
@Test fun runTest() {
testIsSurrogatePair()
testToChars()
testToCodePoint()
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args: Array<String>) {
package runtime.text.parse0
import kotlin.test.*
@Test fun runTest() {
println("false".toBoolean())
println("true".toBoolean())
println("-1".toByte())
+5 -1
View File
@@ -1,4 +1,8 @@
fun main(args: Array<String>) {
package runtime.text.string0
import kotlin.test.*
@Test fun runTest() {
val str = "hello"
println(str.equals("HElLo", true))
val strI18n = "Привет"
@@ -1,3 +1,7 @@
package runtime.text.string_builder0
import kotlin.test.*
// Utils ====================================================================================================
fun assertTrue(cond: Boolean) {
if (!cond)
@@ -262,7 +266,7 @@ fun testBasic() {
assertEquals("", sb.toString())
}
fun main(args : Array<String>) {
@Test fun runTest() {
testBasic()
testInsert()
testReverse()
@@ -1,4 +1,8 @@
fun main(arg:Array<String>) {
package runtime.text.string_builder1
import kotlin.test.*
@Test fun runTest() {
val a = StringBuilder()
a.append("Hello").appendln("Kotlin").appendln(42).appendln(0.1).appendln(true)
println(a.toString())
@@ -1,3 +1,7 @@
package runtime.text.to_string0
import kotlin.test.*
// Based on Apache Harmony tests.
fun assertEquals(actual: String, expected: String, msg: String) {
@@ -34,7 +38,7 @@ fun testLongToStringWithRadix() {
}
fun main(args: Array<String>) {
@Test fun runTest() {
testIntToStringWithRadix()
testLongToStringWithRadix()
println("OK")
@@ -1,6 +1,10 @@
package runtime.workers.worker0
import kotlin.test.*
import konan.worker.*
fun main(args: Array<String>) {
@Test fun runTest() {
val worker = startWorker()
val future = worker.schedule(TransferMode.CHECKED, { "Input".shallowCopy()}) {
input -> input + " processed"
@@ -1,6 +1,10 @@
package runtime.workers.worker1
import kotlin.test.*
import konan.worker.*
fun main(args: Array<String>) {
@Test fun runTest() {
val COUNT = 5
val workers = Array(COUNT, { _ -> startWorker()})
@@ -1,9 +1,13 @@
package runtime.workers.worker2
import kotlin.test.*
import konan.worker.*
data class WorkerArgument(val intParam: Int, val stringParam: String)
data class WorkerResult(val intResult: Int, val stringResult: String)
fun main(args: Array<String>) {
@Test fun runTest() {
val COUNT = 5
val workers = Array(COUNT, { _ -> startWorker()})
@@ -1,8 +1,16 @@
package runtime.workers.worker3
import kotlin.test.*
import konan.worker.*
data class WorkerArgument(val intParam: Int, val stringParam: String)
data class WorkerResult(val intResult: Int, val stringResult: String)
@Test fun runTest() {
main(emptyArray())
}
fun main(args: Array<String>) {
val worker = startWorker()
val s = "zzz${args.size.toString()}"