Add test based on #2931

This commit is contained in:
Svyatoslav Scherbina
2019-05-03 12:06:36 +03:00
committed by SvyatoslavScherbina
parent 78715b14c5
commit d483990c7e
2 changed files with 35 additions and 0 deletions
@@ -8,6 +8,7 @@
package conversions
import kotlin.native.concurrent.freeze
import kotlin.native.concurrent.isFrozen
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
@@ -337,4 +338,16 @@ fun createTransformDecimalStringToInt(): Transform<String, Int> = TransformDecim
open class TransformIntToLong : Transform<Int, Long> {
override fun map(value: Int): Long = value.toLong()
}
class GH2931 {
class Data
class Holder {
val data = Data()
init {
freeze()
}
}
}
@@ -526,6 +526,27 @@ func testKotlinOverride() throws {
try assertEquals(actual: TransformIntToLongCallingSuper().map(value: 5), expected: 5)
}
// See https://github.com/JetBrains/kotlin-native/issues/2931
func testGH2931() throws {
for i in 0..<50000 {
let holder = GH2931.Holder()
let queue = DispatchQueue.global(qos: .background)
let group = DispatchGroup()
for j in 0..<2 {
group.enter()
queue.async {
autoreleasepool {
holder.data
}
group.leave()
}
}
group.wait()
}
}
// -------- Execution of the test --------
class ValuesTests : TestProvider {
@@ -565,6 +586,7 @@ class ValuesTests : TestProvider {
TestCase(name: "TestNames", method: withAutorelease(testNames)),
TestCase(name: "TestSwiftOverride", method: withAutorelease(testSwiftOverride)),
TestCase(name: "TestKotlinOverride", method: withAutorelease(testKotlinOverride)),
TestCase(name: "TestGH2931", method: withAutorelease(testGH2931)),
]
}
}