Files
swift-mirror/test/Concurrency/Runtime/async_task_equals_hashCode.swift
Daniel Rodríguez Troitiño 6e9c5c96e7 [windows][test] Mark two tests that end up deadlocked as unsupported.
Two tests seems to end up deadlocked in the Windows CI machines. Mark
them as unsupported for the time being so the CI machines are useful
again.
2021-03-01 10:07:29 -08:00

59 lines
2.0 KiB
Swift

// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency %import-libdispatch -parse-as-library) | %FileCheck %s --dump-input=always
// REQUIRES: executable_test
// REQUIRES: concurrency
// UNSUPPORTED: OS=windows-os
#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
import Glibc
#endif
func simple() async {
print("\(#function) -----------------------")
let one = await Task.current()
let two = await Task.current()
print("same equal: \(one == two)") // CHECK: same equal: true
print("hashes equal: \(one.hashValue == two.hashValue)") // CHECK: hashes equal: true
async let x = Task.current()
let three = await x
print("parent/child equal: \(three == two)") // CHECK: parent/child equal: false
print("parent/child hashes equal: \(three.hashValue == two.hashValue)") // CHECK: parent/child hashes equal: false
}
func unsafe() async {
print("\(#function) -----------------------")
let one = Task.unsafeCurrent!
let two = Task.unsafeCurrent!
print("unsafe same equal: \(one == two)") // CHECK: same equal: true
print("unsafe hashes equal: \(one.hashValue == two.hashValue)") // CHECK: hashes equal: true
async let x = Task.unsafeCurrent!
let three = await x
print("unsafe parent/child equal: \(three == two)") // CHECK: parent/child equal: false
print("unsafe parent/child hashes equal: \(three.hashValue == two.hashValue)") // CHECK: parent/child hashes equal: false
print("unsafe.task parent/child equal: \(three.task == two.task)") // CHECK: parent/child equal: false
print("unsafe.task parent/child hashes equal: \(three.task.hashValue == two.task.hashValue)") // CHECK: parent/child hashes equal: false
}
func unsafeSync() {
print("\(#function) -----------------------")
let one = Task.unsafeCurrent!
let two = Task.unsafeCurrent!
print("unsafe same equal: \(one == two)") // CHECK: same equal: true
print("unsafe hashes equal: \(one.hashValue == two.hashValue)") // CHECK: hashes equal: true
}
@main struct Main {
static func main() async {
await simple()
await unsafe()
unsafeSync()
}
}