mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The lit feature `objc_interop` is used as a proxy for the availability of libdispatch and Foundation. Although we don't support Obj-C on non-Apple platforms, we support libdispatch and Foundation. Let's break up `objc_interop` into finer-grained categories so we can run more tests on non-Apple platforms. This patch adds lit features `libdispatch` and `foundation` (currently only enabled on Apple platforms) and removes the `objc_interop` dependency from libdispatch tests.
43 lines
1.4 KiB
Swift
43 lines
1.4 KiB
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: libdispatch
|
|
// REQUIRES: foundation
|
|
|
|
import Dispatch
|
|
import Foundation
|
|
import StdlibUnittest
|
|
|
|
var DispatchAPI = TestSuite("DispatchAPI")
|
|
|
|
DispatchAPI.test("DispatchTime.addSubtractDateConstants") {
|
|
var then = DispatchTime.now() + Date.distantFuture.timeIntervalSinceNow
|
|
expectEqual(DispatchTime(uptimeNanoseconds: UInt64.max), then)
|
|
|
|
then = DispatchTime.now() + Date.distantPast.timeIntervalSinceNow
|
|
expectEqual(DispatchTime(uptimeNanoseconds: 1), then)
|
|
|
|
then = DispatchTime.now() - Date.distantFuture.timeIntervalSinceNow
|
|
expectEqual(DispatchTime(uptimeNanoseconds: 1), then)
|
|
|
|
then = DispatchTime.now() - Date.distantPast.timeIntervalSinceNow
|
|
expectEqual(DispatchTime(uptimeNanoseconds: UInt64.max), then)
|
|
}
|
|
|
|
DispatchAPI.test("DispatchWallTime.addSubtractDateConstants") {
|
|
let distantPastRawValue = DispatchWallTime.distantFuture.rawValue - UInt64(1)
|
|
|
|
var then = DispatchWallTime.now() + Date.distantFuture.timeIntervalSinceNow
|
|
expectEqual(DispatchWallTime.distantFuture, then)
|
|
|
|
then = DispatchWallTime.now() + Date.distantPast.timeIntervalSinceNow
|
|
expectEqual(distantPastRawValue, then.rawValue)
|
|
|
|
then = DispatchWallTime.now() - Date.distantFuture.timeIntervalSinceNow
|
|
expectEqual(distantPastRawValue, then.rawValue)
|
|
|
|
then = DispatchWallTime.now() - Date.distantPast.timeIntervalSinceNow
|
|
expectEqual(DispatchWallTime.distantFuture, then)
|
|
}
|
|
|
|
runAllTests()
|