Skip to content
Merged
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]"
windows_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]"
enable_wasm_sdk_build: true
wasm_sdk_build_command: swift build -Xcc -D_WASI_EMULATED_PTHREAD

Expand Down
46 changes: 40 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import PackageDescription
import CompilerPluginSupport

// Availability Macros

let availabilityMacros: [SwiftSetting] = [
.enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"),
.enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"),
.enableExperimentalFeature(
"AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"
),
.enableExperimentalFeature(
"AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"
),
]

let package = Package(
Expand Down Expand Up @@ -43,7 +45,39 @@ let package = Package(
),
.testTarget(
name: "AsyncAlgorithmsTests",
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"],
dependencies: [
.target(name: "AsyncAlgorithms"),
.target(
name: "AsyncSequenceValidation",
condition: .when(platforms: [
.macOS,
.iOS,
.tvOS,
.watchOS,
.visionOS,
.macCatalyst,
.android,
.linux,
.openbsd,
.wasi,
])
),
.target(
name: "AsyncAlgorithms_XCTest",
condition: .when(platforms: [
.macOS,
.iOS,
.tvOS,
.watchOS,
.visionOS,
.macCatalyst,
.android,
.linux,
.openbsd,
.wasi,
])
),
],
swiftSettings: availabilityMacros + [
.enableExperimentalFeature("StrictConcurrency=complete")
]
Expand All @@ -53,7 +87,7 @@ let package = Package(

if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
package.dependencies += [
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0")
]
} else {
package.dependencies += [
Expand Down
44 changes: 40 additions & 4 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import CompilerPluginSupport
// Availability Macros

let availabilityMacros: [SwiftSetting] = [
.enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"),
.enableExperimentalFeature("AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"),
.enableExperimentalFeature(
"AvailabilityMacro=AsyncAlgorithms 1.0:macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0"
),
.enableExperimentalFeature(
"AvailabilityMacro=AsyncAlgorithms 1.1:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"
),
]

let package = Package(
Expand Down Expand Up @@ -43,7 +47,39 @@ let package = Package(
),
.testTarget(
name: "AsyncAlgorithmsTests",
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"],
dependencies: [
.target(name: "AsyncAlgorithms"),
.target(
name: "AsyncSequenceValidation",
condition: .when(platforms: [
.macOS,
.iOS,
.tvOS,
.watchOS,
.visionOS,
.macCatalyst,
.android,
.linux,
.openbsd,
.wasi,
])
),
.target(
name: "AsyncAlgorithms_XCTest",
condition: .when(platforms: [
.macOS,
.iOS,
.tvOS,
.watchOS,
.visionOS,
.macCatalyst,
.android,
.linux,
.openbsd,
.wasi,
])
),
],
swiftSettings: availabilityMacros + [
.enableExperimentalFeature("StrictConcurrency=complete")
]
Expand All @@ -53,7 +89,7 @@ let package = Package(

if Context.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
package.dependencies += [
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0")
]
} else {
package.dependencies += [
Expand Down
2 changes: 1 addition & 1 deletion Sources/AsyncAlgorithms/Buffer/AsyncBufferSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public struct AsyncBufferSequence<Base: AsyncSequence & Sendable>: AsyncSequence
// to specify that the element is actually Sendable since the draining mechanism passes
// through the isolation that is in nature sending but cannot be marked as such for the
// isolated next method.
// In practice the users of this type are safe from isolation crossing since the Element
// In practice the users of this type are safe from isolation crossing since the Element
// is as sendable as it is required by the base sequences the buffer is constructed from.
enum StorageType {
case transparent(Base.AsyncIterator)
Expand Down
1 change: 0 additions & 1 deletion Sources/AsyncAlgorithms/Buffer/BoundedBufferStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ final class BoundedBufferStorage<Base: AsyncSequence>: Sendable where Base: Send
case .none:
break
case .resumeConsumer(let continuation, let result):

continuation.resume(returning: result)
}
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/AsyncAlgorithmsTests/TestBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ final class TestBuffer: XCTestCase {
XCTAssertNil(pastFailure)
}

#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
func test_given_a_base_sequence_when_bufferingOldest_then_the_policy_is_applied() async {
validate {
"X-12- 34- 5 |"
Expand Down Expand Up @@ -171,6 +172,7 @@ final class TestBuffer: XCTestCase {
"X,,,,,,[45^]"
}
}
#endif

func
test_given_a_buffered_with_unbounded_sequence_when_cancelling_consumer_then_the_iteration_finishes_and_the_base_is_cancelled()
Expand Down Expand Up @@ -325,11 +327,13 @@ final class TestBuffer: XCTestCase {
await fulfillment(of: [finished], timeout: 1.0)
}

#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
func test_given_a_base_sequence_when_bounded_with_limit_0_then_the_policy_is_transparent() async {
validate {
"X-12- 34 -5|"
$0.inputs[0].buffer(policy: .bounded(0))
"X-12- 34 -5|"
}
}
#endif
}
5 changes: 5 additions & 0 deletions Tests/AsyncAlgorithmsTests/TestChunk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
//===----------------------------------------------------------------------===//

import XCTest

#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)

import AsyncSequenceValidation
import AsyncAlgorithms

Expand Down Expand Up @@ -334,3 +337,5 @@ final class TestChunk: XCTestCase {
}
}
}

#endif
2 changes: 2 additions & 0 deletions Tests/AsyncAlgorithmsTests/TestDebounce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import XCTest
import AsyncAlgorithms

final class TestDebounce: XCTestCase {
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
func test_delayingValues() throws {
guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else {
throw XCTSkip("Skipped due to Clock/Instant/Duration availability")
Expand Down Expand Up @@ -67,6 +68,7 @@ final class TestDebounce: XCTestCase {
"----|"
}
}
#endif

func test_Rethrows() async throws {
guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else {
Expand Down
4 changes: 4 additions & 0 deletions Tests/AsyncAlgorithmsTests/TestMerge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ final class TestMerge2: XCTestCase {
XCTAssertEqual(collected.intersection(expected), expected)
}

#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
func test_merge_makes_sequence_with_ordered_elements_when_sources_follow_a_timeline() {
validate {
"a-c-e-g-|"
Expand All @@ -178,6 +179,7 @@ final class TestMerge2: XCTestCase {
"abcdefgh|"
}
}
#endif

func test_merge_finishes_when_iteration_task_is_cancelled() async {
let source1 = Indefinite(value: "test1")
Expand Down Expand Up @@ -508,6 +510,7 @@ final class TestMerge3: XCTestCase {
XCTAssertEqual(collected.intersection(expected), expected)
}

#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
func test_merge_makes_sequence_with_ordered_elements_when_sources_follow_a_timeline() {
validate {
"a---e---|"
Expand All @@ -517,6 +520,7 @@ final class TestMerge3: XCTestCase {
"abcdefgh|"
}
}
#endif

func test_merge_finishes_when_iteration_task_is_cancelled() async {
let source1 = Indefinite(value: "test1")
Expand Down
2 changes: 2 additions & 0 deletions Tests/AsyncAlgorithmsTests/TestThrottle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import XCTest
import AsyncAlgorithms

final class TestThrottle: XCTestCase {
#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)
func test_rate_0() throws {
guard #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) else {
throw XCTSkip("Skipped due to Clock/Instant/Duration availability")
Expand Down Expand Up @@ -188,4 +189,5 @@ final class TestThrottle: XCTestCase {
"a--d--g--j--[l|]"
}
}
#endif
}
5 changes: 5 additions & 0 deletions Tests/AsyncAlgorithmsTests/TestTimer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
//===----------------------------------------------------------------------===//

import XCTest

#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)

import AsyncAlgorithms
import AsyncSequenceValidation

Expand Down Expand Up @@ -57,3 +60,5 @@ final class TestTimer: XCTestCase {
}
}
}

#endif
5 changes: 5 additions & 0 deletions Tests/AsyncAlgorithmsTests/TestValidationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
//===----------------------------------------------------------------------===//

import XCTest

#if canImport(Darwin) || canImport(Glibc) || canImport(Musl) || canImport(Bionic) || canImport(wasi_pthread)

import AsyncAlgorithms
import AsyncSequenceValidation
@testable import AsyncAlgorithms_XCTest
Expand Down Expand Up @@ -354,3 +357,5 @@ struct LaggingAsyncSequence<Base: AsyncSequence, C: Clock>: AsyncSequence {
self.clock = clock
}
}

#endif