Skip to content

Commit ef0589d

Browse files
authored
Merge pull request #10 from mtj0928/fix-ci
Fix CI Settings
2 parents bf57a7d + 10b98e3 commit ef0589d

17 files changed

+131
-177
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ jobs:
1111
strategy:
1212
matrix:
1313
swift_version:
14-
- "5.10"
1514
- "6.0"
1615
- "6.1"
1716
- "6.2"
@@ -27,7 +26,7 @@ jobs:
2726
- name: Add Swiftly to PATH
2827
run: echo "${HOME}/.swiftly/bin" >> "${GITHUB_PATH}"
2928
- name: Install Swift
30-
run: ~/.swiftly/bin/swiftly install ${{ matrix.swift_version }}
29+
run: ~/.swiftly/bin/swiftly install --use ${{ matrix.swift_version }}
3130
- name: Get swift version
3231
run: swift --version
3332
- uses: actions/checkout@v4

Package@swift-5.10.swift

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ print(results) // 😁 [0, 2, 4, 6, 8, 10]
172172
```
173173

174174
## Requirements
175-
Swift 5.10 or later.
175+
Swift 6.0 or later.
176176

177177
## Installation
178178
You can install the library via Swift Package Manager.

Sources/AsyncOperations/withOrderedTaskGroup.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if compiler(>=6.0)
21
/// A wrapper function of `withTaskGroup`.
32
///
43
/// The main difference with `withTaskGroup` is that the group's next function returns the results in the order the tasks were added.
@@ -30,18 +29,6 @@ public func withOrderedTaskGroup<ChildTaskResult: Sendable, GroupResult>(
3029
return await body(&orderedTaskGroup)
3130
}
3231
}
33-
#else
34-
public func withOrderedTaskGroup<ChildTaskResult: Sendable, GroupResult>(
35-
of childTaskResultType: ChildTaskResult.Type,
36-
returning returnType: GroupResult.Type = GroupResult.self,
37-
body: (inout OrderedTaskGroup<ChildTaskResult>) async -> GroupResult
38-
) async -> GroupResult {
39-
await withTaskGroup(of: (Index, ChildTaskResult).self, returning: returnType) { group in
40-
var orderedTaskGroup = OrderedTaskGroup<ChildTaskResult>(group)
41-
return await body(&orderedTaskGroup)
42-
}
43-
}
44-
#endif
4532

4633
public struct OrderedTaskGroup<ChildTaskResult: Sendable> {
4734
private var internalGroup: TaskGroup<(Index, ChildTaskResult)>
@@ -53,7 +40,6 @@ public struct OrderedTaskGroup<ChildTaskResult: Sendable> {
5340
self.internalGroup = internalGroup
5441
}
5542

56-
#if compiler(>=6.0)
5743
public mutating func addTask(
5844
priority: TaskPriority? = nil,
5945
operation: sending @escaping @isolated(any) () async -> ChildTaskResult
@@ -65,19 +51,6 @@ public struct OrderedTaskGroup<ChildTaskResult: Sendable> {
6551
}
6652
addedTaskIndex = addedTaskIndex.next()
6753
}
68-
#else
69-
public mutating func addTask(
70-
priority: TaskPriority? = nil,
71-
operation: @escaping @Sendable () async -> ChildTaskResult
72-
) {
73-
let currentIndex = addedTaskIndex
74-
internalGroup.addTask(priority: priority) {
75-
let result = await operation()
76-
return (currentIndex, result)
77-
}
78-
addedTaskIndex = addedTaskIndex.next()
79-
}
80-
#endif
8154

8255
public mutating func waitForAll() async {
8356
await internalGroup.waitForAll()

Sources/AsyncOperations/withThrowingOrderedTaskGroup.swift

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if compiler(>=6.0)
21
/// A wrapper function of `withThrowingTaskGroup`.
32
///
43
/// The main difference with `withThrowingTaskGroup` is that the group's next function returns the results in the order the tasks were added.
@@ -36,21 +35,6 @@ public func withThrowingOrderedTaskGroup<ChildTaskResult: Sendable, GroupResult>
3635
return try await body(&throwingOrderedTaskGroup)
3736
}
3837
}
39-
#else
40-
public func withThrowingOrderedTaskGroup<ChildTaskResult: Sendable, GroupResult>(
41-
of childTaskResultType: ChildTaskResult.Type,
42-
returning returnType: GroupResult.Type = GroupResult.self,
43-
body: (inout ThrowingOrderedTaskGroup<ChildTaskResult, any Error>) async throws -> GroupResult
44-
) async rethrows -> GroupResult {
45-
try await withThrowingTaskGroup(
46-
of: (Index, ChildTaskResult).self,
47-
returning: GroupResult.self
48-
) { group in
49-
var throwingOrderedTaskGroup = ThrowingOrderedTaskGroup<ChildTaskResult, any Error>(group)
50-
return try await body(&throwingOrderedTaskGroup)
51-
}
52-
}
53-
#endif
5438

5539
public struct ThrowingOrderedTaskGroup<ChildTaskResult: Sendable, Failure: Error> {
5640
private var internalGroup: ThrowingTaskGroup<(Index, ChildTaskResult), Failure>
@@ -62,7 +46,6 @@ public struct ThrowingOrderedTaskGroup<ChildTaskResult: Sendable, Failure: Error
6246
self.internalGroup = internalGroup
6347
}
6448

65-
#if compiler(>=6.0)
6649
public mutating func addTask(
6750
priority: TaskPriority? = nil,
6851
operation: sending @escaping @isolated(any) () async throws(Failure) -> ChildTaskResult
@@ -78,23 +61,6 @@ public struct ThrowingOrderedTaskGroup<ChildTaskResult: Sendable, Failure: Error
7861
}
7962
addedTaskIndex = addedTaskIndex.next()
8063
}
81-
#else
82-
public mutating func addTask(
83-
priority: TaskPriority? = nil,
84-
operation: @escaping @Sendable () async throws -> ChildTaskResult
85-
) {
86-
let currentIndex = addedTaskIndex
87-
internalGroup.addTask(priority: priority) {
88-
do {
89-
let result = try await operation()
90-
return (currentIndex, result)
91-
} catch {
92-
throw InternalError(index: currentIndex, rawError: error)
93-
}
94-
}
95-
addedTaskIndex = addedTaskIndex.next()
96-
}
97-
#endif
9864

9965
public mutating func waitForAll() async throws {
10066
do {

Tests/AsyncOperationsTests/AsyncSequence/AsyncSequenceAsyncForEachTests.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import AsyncOperations
2-
import XCTest
2+
import Testing
33

4-
final class AsyncSequenceAsyncForEachTests: XCTestCase {
4+
struct AsyncSequenceAsyncForEachTests {
5+
6+
@Test
57
@MainActor
6-
func testAsyncForEach() async throws {
8+
func asyncForEach() async throws {
79
var results: [Int] = []
810
var events: [ConcurrentTaskEvent] = []
911

@@ -18,8 +20,8 @@ final class AsyncSequenceAsyncForEachTests: XCTestCase {
1820
events.append(.end)
1921
results.append(number)
2022
}
21-
XCTAssertEqual(results.count, 5)
22-
XCTAssertEqual(Set(results), [0, 1, 2, 3, 4])
23-
XCTAssertEqual(events, [.start, .start, .start, .end, .start, .end, .start, .end, .end, .end])
23+
#expect(results.count == 5)
24+
#expect(Set(results) == [0, 1, 2, 3, 4])
25+
#expect(events == [.start, .start, .start, .end, .start, .end, .start, .end, .end, .end])
2426
}
2527
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import AsyncOperations
2-
import XCTest
2+
import Testing
33

4-
final class SequenceAsyncAllSatisfyTests: XCTestCase {
5-
func testAsyncAllSatisfy() async throws {
4+
struct SequenceAsyncAllSatisfyTests {
5+
@Test
6+
func asyncAllSatisfy() async throws {
67
let satisfiedResult = await [0, 1, 2, 3, 4].asyncAllSatisfy { number in
78
await Task.yield()
89
return number < 5
910
}
10-
XCTAssertTrue(satisfiedResult)
11+
#expect(satisfiedResult)
1112

1213
let unsatisfiedResult = await [0, 1, 2, 3, 4].asyncAllSatisfy { number in
1314
await Task.yield()
1415
return number < 4
1516
}
16-
XCTAssertFalse(unsatisfiedResult)
17+
#expect(!unsatisfiedResult)
1718
}
1819
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import AsyncOperations
2-
import XCTest
2+
import Testing
33

4-
5-
final class SequenceAsyncCompactMapTests: XCTestCase {
6-
func testAsyncCompactMapMultipleTasks() async throws {
4+
struct SequenceAsyncCompactMapTests {
5+
@Test func asyncCompactMapMultipleTasks() async throws {
76
let results = await [0, 1, 2, 3, 4].asyncCompactMap { number in
87
await Task.yield()
98
return number % 2 == 0 ? nil : number * 2
109
}
1110

12-
XCTAssertEqual(results, [2, 6])
11+
#expect(results == [2, 6])
1312
}
1413
}
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import AsyncOperations
2-
import XCTest
2+
import Testing
33

4-
final class SequenceAsyncContainsTests: XCTestCase {
5-
func testAsyncContains() async throws {
4+
struct SequenceAsyncContainsTests {
5+
6+
@Test
7+
func asyncContains() async throws {
68
let containsResult = await [1, 2, 3].asyncContains { number in
7-
XCTAssertNotEqual(number, 3)
9+
#expect(number != 3)
810
return number == 2
911
}
10-
XCTAssertTrue(containsResult)
12+
#expect(containsResult)
1113

1214
let notContainsResult = await [1, 2, 3].asyncContains { number in
1315
return number == 4
1416
}
15-
XCTAssertFalse(notContainsResult)
17+
#expect(!notContainsResult)
1618
}
1719
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import AsyncOperations
2-
import XCTest
2+
import Testing
33

4-
final class SequenceAsyncFilterTests: XCTestCase {
5-
func testAsyncFilter() async throws {
4+
struct SequenceAsyncFilterTests {
5+
6+
@Test
7+
func asyncFilter() async throws {
68
let filteredNumbers = await [0, 1, 2, 3, 4].asyncFilter { number in
79
await Task.yield()
810
return number.isMultiple(of: 2)
911
}
10-
XCTAssertEqual(filteredNumbers, [0, 2, 4])
12+
#expect(filteredNumbers == [0, 2, 4])
1113
}
1214
}

0 commit comments

Comments
 (0)