Skip to content

Commit 26da327

Browse files
stephencelisgithub-actions[bot]
authored andcommitted
Run swift-format
1 parent 4ece153 commit 26da327

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

Tests/ComposableArchitectureTests/EffectTests.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class EffectTests: XCTestCase {
5050
.store(in: &self.cancellables)
5151
}
5252

53-
#if canImport(RoomPlan) || (!canImport(Darwin) && swift(>=5.7))
53+
#if canImport(RoomPlan) || (!canImport(Darwin) && swift(>=5.7))
5454
func testConcatenate() async {
5555
if #available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) {
5656
let clock = TestClock()
@@ -102,35 +102,35 @@ final class EffectTests: XCTestCase {
102102
XCTAssertEqual(values, [1])
103103
}
104104

105-
#if canImport(RoomPlan) || (!canImport(Darwin) && swift(>=5.7))
106-
func testMerge() async {
107-
if #available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) {
108-
let clock = TestClock()
105+
#if canImport(RoomPlan) || (!canImport(Darwin) && swift(>=5.7))
106+
func testMerge() async {
107+
if #available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) {
108+
let clock = TestClock()
109109

110-
let effect = Effect<Int, Never>.merge(
111-
(1...3).map { count in
112-
.task {
113-
try await clock.sleep(for: .seconds(count))
114-
return count
110+
let effect = Effect<Int, Never>.merge(
111+
(1...3).map { count in
112+
.task {
113+
try await clock.sleep(for: .seconds(count))
114+
return count
115+
}
115116
}
116-
}
117-
)
117+
)
118118

119-
var values: [Int] = []
120-
effect.sink(receiveValue: { values.append($0) }).store(in: &self.cancellables)
119+
var values: [Int] = []
120+
effect.sink(receiveValue: { values.append($0) }).store(in: &self.cancellables)
121121

122-
XCTAssertEqual(values, [])
122+
XCTAssertEqual(values, [])
123123

124-
await clock.advance(by: .seconds(1))
125-
XCTAssertEqual(values, [1])
124+
await clock.advance(by: .seconds(1))
125+
XCTAssertEqual(values, [1])
126126

127-
await clock.advance(by: .seconds(1))
128-
XCTAssertEqual(values, [1, 2])
127+
await clock.advance(by: .seconds(1))
128+
XCTAssertEqual(values, [1, 2])
129129

130-
await clock.advance(by: .seconds(1))
131-
XCTAssertEqual(values, [1, 2, 3])
130+
await clock.advance(by: .seconds(1))
131+
XCTAssertEqual(values, [1, 2, 3])
132+
}
132133
}
133-
}
134134
#endif
135135

136136
func testEffectSubscriberInitializer() {

Tests/ComposableArchitectureTests/ReducerTests.swift

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,60 +19,60 @@ final class ReducerTests: XCTestCase {
1919
XCTAssertEqual(state, 1)
2020
}
2121

22-
#if canImport(RoomPlan) || (!canImport(Darwin) && swift(>=5.7))
23-
func testCombine_EffectsAreMerged() async throws {
24-
if #available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) {
25-
enum Action: Equatable {
26-
case increment
27-
}
22+
#if canImport(RoomPlan) || (!canImport(Darwin) && swift(>=5.7))
23+
func testCombine_EffectsAreMerged() async throws {
24+
if #available(iOS 16, macOS 13, tvOS 16, watchOS 9, *) {
25+
enum Action: Equatable {
26+
case increment
27+
}
2828

29-
struct Delayed: ReducerProtocol {
30-
typealias State = Int
29+
struct Delayed: ReducerProtocol {
30+
typealias State = Int
3131

32-
@Dependency(\.continuousClock) var clock
32+
@Dependency(\.continuousClock) var clock
3333

34-
let delay: Duration
35-
let setValue: @Sendable () async -> Void
34+
let delay: Duration
35+
let setValue: @Sendable () async -> Void
3636

37-
func reduce(into state: inout State, action: Action) -> EffectTask<Action> {
38-
state += 1
39-
return .fireAndForget {
40-
try await self.clock.sleep(for: self.delay)
41-
await self.setValue()
37+
func reduce(into state: inout State, action: Action) -> EffectTask<Action> {
38+
state += 1
39+
return .fireAndForget {
40+
try await self.clock.sleep(for: self.delay)
41+
await self.setValue()
42+
}
4243
}
4344
}
44-
}
4545

46-
var fastValue: Int? = nil
47-
var slowValue: Int? = nil
46+
var fastValue: Int? = nil
47+
var slowValue: Int? = nil
4848

49-
let store = TestStore(
50-
initialState: 0,
51-
reducer: CombineReducers {
52-
Delayed(delay: .seconds(1), setValue: { @MainActor in fastValue = 42 })
53-
Delayed(delay: .seconds(2), setValue: { @MainActor in slowValue = 1729 })
54-
}
55-
)
49+
let store = TestStore(
50+
initialState: 0,
51+
reducer: CombineReducers {
52+
Delayed(delay: .seconds(1), setValue: { @MainActor in fastValue = 42 })
53+
Delayed(delay: .seconds(2), setValue: { @MainActor in slowValue = 1729 })
54+
}
55+
)
5656

57-
let clock = TestClock()
58-
store.dependencies.continuousClock = clock
57+
let clock = TestClock()
58+
store.dependencies.continuousClock = clock
5959

60-
await store.send(.increment) {
61-
$0 = 2
60+
await store.send(.increment) {
61+
$0 = 2
62+
}
63+
// Waiting a second causes the fast effect to fire.
64+
await clock.advance(by: .seconds(1))
65+
try await Task.sleep(nanoseconds: NSEC_PER_SEC / 3)
66+
XCTAssertEqual(fastValue, 42)
67+
XCTAssertEqual(slowValue, nil)
68+
// Waiting one more second causes the slow effect to fire. This proves that the effects
69+
// are merged together, as opposed to concatenated.
70+
await clock.advance(by: .seconds(1))
71+
await store.finish()
72+
XCTAssertEqual(fastValue, 42)
73+
XCTAssertEqual(slowValue, 1729)
6274
}
63-
// Waiting a second causes the fast effect to fire.
64-
await clock.advance(by: .seconds(1))
65-
try await Task.sleep(nanoseconds: NSEC_PER_SEC / 3)
66-
XCTAssertEqual(fastValue, 42)
67-
XCTAssertEqual(slowValue, nil)
68-
// Waiting one more second causes the slow effect to fire. This proves that the effects
69-
// are merged together, as opposed to concatenated.
70-
await clock.advance(by: .seconds(1))
71-
await store.finish()
72-
XCTAssertEqual(fastValue, 42)
73-
XCTAssertEqual(slowValue, 1729)
7475
}
75-
}
7676
#endif
7777

7878
func testCombine() async {

0 commit comments

Comments
 (0)