diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/Kt1149.kt b/compiler/testData/codegen/boxWithStdlib/regressions/Kt1149.kt new file mode 100644 index 00000000000..1abb4b7ec6f --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/regressions/Kt1149.kt @@ -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() + var res = ArrayList() + list.add(object : SomeTrait { + override fun foo() { + res.add("anonymous.foo()") + } + }) + list.forEach{ it.foo() } + return if ("anonymous.foo()" == res[0]) "OK" else "fail" +} diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/Kt1619Test.kt b/compiler/testData/codegen/boxWithStdlib/regressions/Kt1619Test.kt new file mode 100644 index 00000000000..044f0a9f442 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/regressions/Kt1619Test.kt @@ -0,0 +1,18 @@ +package regressions + +class Kt1619Test { + + fun doSomething(list: List): Int { + return list.size() + } + + fun testCollectionNotNullCanBeUsedForNullables(): Int { + val list: List = arrayListOf("foo", "bar") + return doSomething(list) + } +} + +fun box(): String { + return if (Kt1619Test().testCollectionNotNullCanBeUsedForNullables() == 2) "OK" else "fail" +} + diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/Kt2495Test.kt b/compiler/testData/codegen/boxWithStdlib/regressions/Kt2495Test.kt new file mode 100644 index 00000000000..0b7af7dc4d7 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/regressions/Kt2495Test.kt @@ -0,0 +1,15 @@ +package regressions + +fun f(xs: Iterator): 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" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt1172.kt b/compiler/testData/codegen/boxWithStdlib/regressions/kt1172.kt new file mode 100644 index 00000000000..ecc936bcf7c --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/regressions/kt1172.kt @@ -0,0 +1,13 @@ +package test.regressions.kt1172 + +import kotlin.concurrent.* +import java.util.* + +public fun scheduleRefresh(vararg files : Object) { + java.util.ArrayList(files.map{ it }) +} + +fun box(): String { + scheduleRefresh() + return "OK" +} diff --git a/libraries/stdlib/test/regressions/kt1202.kt b/compiler/testData/codegen/boxWithStdlib/regressions/kt1202.kt similarity index 86% rename from libraries/stdlib/test/regressions/kt1202.kt rename to compiler/testData/codegen/boxWithStdlib/regressions/kt1202.kt index 83eafec9c2d..deaa57f525c 100644 --- a/libraries/stdlib/test/regressions/kt1202.kt +++ b/compiler/testData/codegen/boxWithStdlib/regressions/kt1202.kt @@ -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) : ParseResult { fun parse(text : String) : ParseResult = 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" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 51559008d09..5c235588e6b 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -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"); diff --git a/libraries/stdlib/test/regressions/Kt1149.kt b/libraries/stdlib/test/regressions/Kt1149.kt deleted file mode 100644 index d0d2becdcff..00000000000 --- a/libraries/stdlib/test/regressions/Kt1149.kt +++ /dev/null @@ -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() - var res = ArrayList() - list.add(object : SomeTrait { - override fun foo() { - res.add("anonymous.foo()") - } - }) - list.forEach{ it.foo() } - Assert.assertEquals("anonymous.foo()", res[0]) - } -} diff --git a/libraries/stdlib/test/regressions/Kt1617Test.kt b/libraries/stdlib/test/regressions/Kt1617Test.kt deleted file mode 100644 index f8c808fd239..00000000000 --- a/libraries/stdlib/test/regressions/Kt1617Test.kt +++ /dev/null @@ -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 = arrayListOf("foo", "bar") - - val files = coll.map{ File(it) } - - println("Found files: $files") - } -} \ No newline at end of file diff --git a/libraries/stdlib/test/regressions/Kt1619Test.kt b/libraries/stdlib/test/regressions/Kt1619Test.kt deleted file mode 100644 index 5a8c357a497..00000000000 --- a/libraries/stdlib/test/regressions/Kt1619Test.kt +++ /dev/null @@ -1,16 +0,0 @@ -package regressions - -import junit.framework.TestCase -import kotlin.test.expect - -class Kt1619Test: TestCase() { - - fun doSomething(list: List): Int { - return list.size() - } - - fun testCollectionNotNullCanBeUsedForNullables() { - val list: List = arrayListOf("foo", "bar") - expect(2) { doSomething(list) } - } -} \ No newline at end of file diff --git a/libraries/stdlib/test/regressions/Kt2495Test.kt b/libraries/stdlib/test/regressions/Kt2495Test.kt deleted file mode 100644 index 4df76d699da..00000000000 --- a/libraries/stdlib/test/regressions/Kt2495Test.kt +++ /dev/null @@ -1,20 +0,0 @@ -package regressions - -import kotlin.test.assertEquals -import org.junit.Test as test - -fun f(xs: Iterator): 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) - } -} \ No newline at end of file diff --git a/libraries/stdlib/test/regressions/kt1172.kt b/libraries/stdlib/test/regressions/kt1172.kt deleted file mode 100644 index 4507af43cbe..00000000000 --- a/libraries/stdlib/test/regressions/kt1172.kt +++ /dev/null @@ -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(files.map{ it }) -} - -fun main(args : Array?) { -} - -class Kt1172Test() : TestCase() { - fun testMe() { - main(null) - } -}