Files
swift-mirror/test/Interop/C/struct/foreign-reference.swift
Egor Zhdan b440c4ff70 [cxx-interop] Enable reference-counted types on Windows
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
2025-08-20 12:35:10 +01:00

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()