Skip to content

Commit

Permalink
Remove AsyncEnumeratedSequence tests (#541)
Browse files Browse the repository at this point in the history
Given we moved the type to Soto we can't tests it in SotoCore
  • Loading branch information
adam-fowler authored Apr 9, 2023
1 parent c412960 commit 0997ca4
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions Tests/SotoCoreTests/Concurrency/AsyncSequenceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ final class AsyncSequenceTests: XCTestCase {
func testFixedSizeByteBufferShortSequence() async throws {
try await self.testFixedSizeByteBufferSequence(bufferSize: 250, generatedByteBufferSizeRange: 500..<1000, fixedChunkSize: 1000)
}

func testEnumeratedSequence() async throws {
let sequence = [24, 23, 300]
let asyncSequence = sequence.asyncSequence
let result: [(Int, Int)] = try await asyncSequence.enumerated().collect()
XCTAssertEqual(result.map { $0.0 }, [0, 1, 2])
XCTAssertEqual(result.map { $0.1 }, sequence)
}
}

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -104,40 +96,4 @@ struct TestByteBufferSequence: AsyncSequence {
}
}

/// create AsyncSequence from Sequence
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Sequence {
var asyncSequence: SequenceAsyncSequence<Self> { .init(base: self) }
}

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
struct SequenceAsyncSequence<Base: Sequence>: AsyncSequence {
typealias Element = Base.Element
let base: Base
public struct AsyncIterator: AsyncIteratorProtocol {
var iterator: Base.Iterator

public mutating func next() async throws -> Element? {
return self.iterator.next()
}
}

/// Make async iterator
public func makeAsyncIterator() -> AsyncIterator {
return AsyncIterator(iterator: self.base.makeIterator())
}
}

/// Collect output of AsyncSequence into an Array
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension AsyncSequence {
func collect() async rethrows -> [Element] {
var result: [Element] = []
for try await element in self {
result.append(element)
}
return result
}
}

#endif // compiler(>=5.5.2) && canImport(_Concurrency)

0 comments on commit 0997ca4

Please sign in to comment.