mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This enables the use of reference-counted foreign reference types on Windows. As it turns out, the assertion that was failing on Windows previously was unnecessary. This also enabled many of the tests on Windows. rdar://154694125 / resolves https://github.com/swiftlang/swift/issues/82643
52 lines
1.1 KiB
Swift
52 lines
1.1 KiB
Swift
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -Onone -D NO_OPTIMIZATIONS)
|
|
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -validate-tbd-against-ir=none -O)
|
|
//
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
import ForeignReference
|
|
|
|
var ReferenceCountedTestSuite = TestSuite("Foreign reference types that have reference counts")
|
|
|
|
@inline(never)
|
|
public func blackHole<T>(_ _: T) { }
|
|
|
|
ReferenceCountedTestSuite.test("Local") {
|
|
var x = createLocalCount()
|
|
#if NO_OPTIMIZATIONS
|
|
expectEqual(x.value, 2)
|
|
#endif
|
|
|
|
let t = (x, x, x)
|
|
#if NO_OPTIMIZATIONS
|
|
expectEqual(x.value, 5)
|
|
#endif
|
|
}
|
|
|
|
@inline(never)
|
|
func globalTest1() {
|
|
var x = createGlobalCount()
|
|
let t = (x, x, x)
|
|
#if NO_OPTIMIZATIONS
|
|
expectEqual(globalCount, 4)
|
|
#endif
|
|
blackHole(t)
|
|
}
|
|
|
|
@inline(never)
|
|
func globalTest2() {
|
|
var x = createGlobalCount()
|
|
#if NO_OPTIMIZATIONS
|
|
expectEqual(globalCount, 1)
|
|
#endif
|
|
}
|
|
|
|
ReferenceCountedTestSuite.test("Global") {
|
|
expectEqual(globalCount, 0)
|
|
globalTest1()
|
|
globalTest2()
|
|
expectEqual(globalCount, 0)
|
|
}
|
|
|
|
runAllTests()
|