Skip to content

Commit

Permalink
Add test based on JetBrains#2931
Browse files Browse the repository at this point in the history
  • Loading branch information
SvyatoslavScherbina committed May 3, 2019
1 parent 78715b1 commit d483990
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend.native/tests/framework/values/values.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package conversions

import kotlin.native.concurrent.freeze
import kotlin.native.concurrent.isFrozen
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
Expand Down Expand Up @@ -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()
}
}
}
22 changes: 22 additions & 0 deletions backend.native/tests/framework/values/values.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)),
]
}
}

0 comments on commit d483990

Please sign in to comment.