Move regression tests from stdlib to compiler
#KT-5770 FIxed
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package test.regressions.kt1149
|
||||
|
||||
import java.util.ArrayList
|
||||
import kotlin.util.*
|
||||
|
||||
public trait SomeTrait {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val list = ArrayList<SomeTrait>()
|
||||
var res = ArrayList<String>()
|
||||
list.add(object : SomeTrait {
|
||||
override fun foo() {
|
||||
res.add("anonymous.foo()")
|
||||
}
|
||||
})
|
||||
list.forEach{ it.foo() }
|
||||
return if ("anonymous.foo()" == res[0]) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package regressions
|
||||
|
||||
class Kt1619Test {
|
||||
|
||||
fun doSomething(list: List<String?>): Int {
|
||||
return list.size()
|
||||
}
|
||||
|
||||
fun testCollectionNotNullCanBeUsedForNullables(): Int {
|
||||
val list: List<String> = arrayListOf("foo", "bar")
|
||||
return doSomething(list)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return if (Kt1619Test().testCollectionNotNullCanBeUsedForNullables() == 2) "OK" else "fail"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package regressions
|
||||
|
||||
fun f(xs: Iterator<Int>): Int {
|
||||
var answer = 0
|
||||
for (x in xs) {
|
||||
answer += x
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val list = arrayList(1, 2, 3)
|
||||
val result = f(list.iterator())
|
||||
return if (6 == result) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package test.regressions.kt1172
|
||||
|
||||
import kotlin.concurrent.*
|
||||
import java.util.*
|
||||
|
||||
public fun scheduleRefresh(vararg files : Object) {
|
||||
java.util.ArrayList<Object>(files.map{ it })
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
scheduleRefresh()
|
||||
return "OK"
|
||||
}
|
||||
+9
-13
@@ -1,8 +1,6 @@
|
||||
package testeval
|
||||
|
||||
import java.util.*
|
||||
import junit.framework.TestCase.*
|
||||
import junit.framework.Assert.* // TODO unnecessary import
|
||||
|
||||
trait Expression
|
||||
class Num(val value : Int) : Expression
|
||||
@@ -106,15 +104,13 @@ fun parseAtomic(tokens : Deque<Token>) : ParseResult<Expression> {
|
||||
|
||||
fun parse(text : String) : ParseResult<Expression> = parseSum(tokenize(text))
|
||||
|
||||
class EvalTest : junit.framework.TestCase() {
|
||||
fun testEval() {
|
||||
assertEquals(1, eval(Num(1)))
|
||||
assertEquals(2, eval(Sum(Num(1), Num(1))))
|
||||
assertEquals(3, eval(Mult(Num(3), Num(1))))
|
||||
assertEquals(6, eval(Mult(Num(3), Sum(Num(1), Num(1)))))
|
||||
}
|
||||
fun box(): String {
|
||||
if (1 != eval(Num(1))) return "fail 1"
|
||||
if (2 != eval(Sum(Num(1), Num(1)))) return "fail 2"
|
||||
if (3 != eval(Mult(Num(3), Num(1)))) return "fail 3"
|
||||
if (6 != eval(Mult(Num(3), Sum(Num(1), Num(1))))) return "fail 4"
|
||||
|
||||
fun testParse() {
|
||||
assertEquals(1, eval(parse("1").value))
|
||||
}
|
||||
}
|
||||
if (1 != eval(parse("1").value)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+36
@@ -2127,6 +2127,24 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Kt1149.kt")
|
||||
public void testKt1149() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/Kt1149.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1172.kt")
|
||||
public void testKt1172() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1172.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1202.kt")
|
||||
public void testKt1202() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1202.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1406.kt")
|
||||
public void testKt1406() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1406.kt");
|
||||
@@ -2139,6 +2157,18 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Kt1617Test.kt")
|
||||
public void testKt1617Test() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/Kt1617Test.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Kt1619Test.kt")
|
||||
public void testKt1619Test() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/Kt1619Test.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1770.kt")
|
||||
public void testKt1770() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt1770.kt");
|
||||
@@ -2187,6 +2217,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Kt2495Test.kt")
|
||||
public void testKt2495Test() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/Kt2495Test.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2593.kt")
|
||||
public void testKt2593() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt2593.kt");
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package test.regressions.kt1149
|
||||
|
||||
import java.util.ArrayList
|
||||
import kotlin.util.*
|
||||
import junit.framework.*
|
||||
|
||||
public trait SomeTrait {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class Kt1149Test() : TestCase() {
|
||||
fun testMe() {
|
||||
val list = ArrayList<SomeTrait>()
|
||||
var res = ArrayList<String>()
|
||||
list.add(object : SomeTrait {
|
||||
override fun foo() {
|
||||
res.add("anonymous.foo()")
|
||||
}
|
||||
})
|
||||
list.forEach{ it.foo() }
|
||||
Assert.assertEquals("anonymous.foo()", res[0])
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package regressions
|
||||
|
||||
// TODO comment out the next line to reproduce KT-1617
|
||||
//import kotlin.util.map
|
||||
|
||||
import java.io.File
|
||||
|
||||
import junit.framework.TestCase
|
||||
|
||||
class Kt1617Test: TestCase() {
|
||||
fun testMapFunction() {
|
||||
val coll: Collection<String> = arrayListOf("foo", "bar")
|
||||
|
||||
val files = coll.map{ File(it) }
|
||||
|
||||
println("Found files: $files")
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package regressions
|
||||
|
||||
import junit.framework.TestCase
|
||||
import kotlin.test.expect
|
||||
|
||||
class Kt1619Test: TestCase() {
|
||||
|
||||
fun doSomething(list: List<String?>): Int {
|
||||
return list.size()
|
||||
}
|
||||
|
||||
fun testCollectionNotNullCanBeUsedForNullables() {
|
||||
val list: List<String> = arrayListOf("foo", "bar")
|
||||
expect(2) { doSomething(list) }
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package regressions
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import org.junit.Test as test
|
||||
|
||||
fun f(xs: Iterator<Int>): Int {
|
||||
var answer = 0
|
||||
for (x in xs) {
|
||||
answer += x
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
class Kt2495Test {
|
||||
test fun duplicateIteratorsBug() {
|
||||
val list = arrayList(1, 2, 3)
|
||||
val result = f(list.iterator())
|
||||
assertEquals(6, result)
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package test.regressions.kt1172
|
||||
|
||||
import kotlin.concurrent.*
|
||||
import junit.framework.*
|
||||
import java.util.*
|
||||
|
||||
public fun scheduleRefresh(vararg files : Object) {
|
||||
// TODO
|
||||
// java.util.ArrayList<Object>(files.map{ it })
|
||||
}
|
||||
|
||||
fun main(args : Array<String?>?) {
|
||||
}
|
||||
|
||||
class Kt1172Test() : TestCase() {
|
||||
fun testMe() {
|
||||
main(null)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user