mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
36 lines
559 B
Swift
36 lines
559 B
Swift
// RUN: %target-run-simple-swift
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
internal func _myPrecondition(
|
|
_ body: @autoclosure () -> Bool
|
|
) {
|
|
guard body() else {
|
|
fatalError("condition failed")
|
|
}
|
|
}
|
|
|
|
var deinitCounter = 0
|
|
|
|
struct MyCounter<T>: ~Copyable {
|
|
let expectedCount = 1
|
|
let box: T
|
|
init(_ t: T) {
|
|
self.box = t
|
|
}
|
|
deinit {
|
|
print("hello")
|
|
deinitCounter += 1
|
|
_myPrecondition(deinitCounter == self.expectedCount)
|
|
}
|
|
}
|
|
|
|
func test() {
|
|
_ = MyCounter(4343)
|
|
}
|
|
|
|
// CHECK: hello
|
|
test()
|
|
// CHECK-NEXT: great success
|
|
print("great success")
|