Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw authored and github-actions[bot] committed Sep 12, 2024
1 parent 03ad0cc commit 8013f1a
Showing 1 changed file with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
#if canImport(Testing)
import ComposableArchitecture
import Testing
import ComposableArchitecture
import Testing

@Suite
struct EffectCancellationIsolationTests {
@Test
func testIsolation1() async {
let store = await TestStore(initialState: Feature.State()) {
Feature()
@Suite
struct EffectCancellationIsolationTests {
@Test
func testIsolation1() async {
let store = await TestStore(initialState: Feature.State()) {
Feature()
}
await store.send(.start)
await store.receive(\.response) {
$0.value = 42
}
await store.send(.stop)
}
await store.send(.start)
await store.receive(\.response) {
$0.value = 42

@Test
func testIsolation2() async {
let store = await TestStore(initialState: Feature.State()) {
Feature()
}
await store.send(.start)
await store.receive(\.response) {
$0.value = 42
}
await store.send(.stop)
}
await store.send(.stop)
}

@Test
func testIsolation2() async {
let store = await TestStore(initialState: Feature.State()) {
Feature()
@Reducer
private struct Feature {
struct State: Equatable {
var value = 0
}
await store.send(.start)
await store.receive(\.response) {
$0.value = 42
enum Action {
case response(Int)
case start
case stop
}
await store.send(.stop)
}
}

@Reducer
private struct Feature {
struct State: Equatable {
var value = 0
}
enum Action {
case response(Int)
case start
case stop
}
enum CancelID { case longLiving }
var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .response(let value):
state.value = value
return .none
case .start:
return .run { send in
await send(.response(42))
try await Task.never()
}
enum CancelID { case longLiving }
var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .response(let value):
state.value = value
return .none
case .start:
return .run { send in
await send(.response(42))
try await Task.never()
}
.cancellable(id: CancelID.longLiving, cancelInFlight: true)
case .stop:
return .cancel(id: CancelID.longLiving)
case .stop:
return .cancel(id: CancelID.longLiving)
}
}
}
}
}

#endif

0 comments on commit 8013f1a

Please sign in to comment.