13
13
import AsyncAlgorithms
14
14
15
15
final class TestCompacted : XCTestCase {
16
- func test_compacting ( ) async {
16
+ func test_compacted_is_equivalent_to_compactMap_when_input_as_nil_elements ( ) async {
17
17
let source = [ 1 , 2 , nil , 3 , 4 , nil , 5 ]
18
18
let expected = source. compactMap { $0 }
19
19
let sequence = source. async . compacted ( )
@@ -24,7 +24,7 @@ final class TestCompacted: XCTestCase {
24
24
XCTAssertEqual ( expected, actual)
25
25
}
26
26
27
- func test_compacting_past_end ( ) async {
27
+ func test_compacted_produces_nil_next_element_when_iteration_is_finished ( ) async {
28
28
let source = [ 1 , 2 , nil , 3 , 4 , nil , 5 ]
29
29
let expected = source. compactMap { $0 }
30
30
let sequence = source. async . compacted ( )
@@ -38,7 +38,7 @@ final class TestCompacted: XCTestCase {
38
38
XCTAssertNil ( pastEnd)
39
39
}
40
40
41
- func test_compactingNonNils ( ) async {
41
+ func test_compacted_is_equivalent_to_compactMap_when_input_as_no_nil_elements ( ) async {
42
42
let source : [ Int ? ] = [ 1 , 2 , 3 , 4 , 5 ]
43
43
let expected = source. compactMap { $0 }
44
44
let sequence = source. async . compacted ( )
@@ -49,7 +49,7 @@ final class TestCompacted: XCTestCase {
49
49
XCTAssertEqual ( expected, actual)
50
50
}
51
51
52
- func test_throwing ( ) async throws {
52
+ func test_compacted_throws_when_root_sequence_throws ( ) async throws {
53
53
let sequence = [ 1 , nil , 3 , 4 , 5 , nil , 7 ] . async . map { try throwOn ( 4 , $0) } . compacted ( )
54
54
var iterator = sequence. makeAsyncIterator ( )
55
55
var collected = [ Int] ( )
@@ -66,7 +66,7 @@ final class TestCompacted: XCTestCase {
66
66
XCTAssertNil ( pastEnd)
67
67
}
68
68
69
- func test_cancellation ( ) async {
69
+ func test_compacted_finishes_when_iteration_task_is_cancelled ( ) async {
70
70
let value : String ? = " test "
71
71
let source = Indefinite ( value: value)
72
72
let sequence = source. async . compacted ( )
0 commit comments