Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions Sources/ComposableArchitecture/TestStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@
#else
@preconcurrency@MainActor
#endif
public final class TestStore<State, Action> {

public final class TestStore<State: Equatable, Action> {
/// The current dependencies of the test store.
///
/// The dependencies define the execution context that your feature runs in. They can be modified
Expand Down Expand Up @@ -529,17 +528,15 @@
/// - filePath: The filePath.
/// - line: The line.
/// - column: The column.
public init<R: Reducer>(
public init(
initialState: @autoclosure () -> State,
reducer: () -> R,
withDependencies prepareDependencies: (inout DependencyValues) -> Void = { _ in
},
reducer: () -> some Reducer<State, Action>,
withDependencies prepareDependencies: (inout DependencyValues) -> Void = { _ in },
fileID: StaticString = #fileID,
file filePath: StaticString = #filePath,
line: UInt = #line,
column: UInt = #column
)
where State: Equatable, R.State == State, R.Action == Action {
) {
let sharedChangeTracker = SharedChangeTracker()
let reducer = Dependencies.withDependencies {
prepareDependencies(&$0)
Expand Down Expand Up @@ -734,7 +731,7 @@
) {
// NB: This existential opening can go away if we can constrain 'State: Equatable' at the
// 'TestStore' level, but for some reason this breaks DocC.
if self.sharedChangeTracker.hasChanges, let stateType = State.self as? any Equatable.Type {

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (16) (IOS, 16.0)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (16) (MACOS, 16.0)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (16) (test, MACOS, 16.0)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (16) (test, IOS, 16.0)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (MACOS, 15.2)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, MACOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, MACOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, MACOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, MAC_CATALYST, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, MAC_CATALYST, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, MAC_CATALYST, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (IOS, 15.2)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, TVOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, TVOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, TVOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, IOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, IOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, IOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, WATCHOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, WATCHOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, WATCHOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, WATCHOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, VISIONOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, VISIONOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds

Check warning on line 734 in Sources/ComposableArchitecture/TestStore.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (15) (test, VISIONOS, 15.4)

conditional cast from 'State.Type' to 'any Equatable.Type' always succeeds
func open<EquatableState: Equatable>(_: EquatableState.Type) {
let store = self as! TestStore<EquatableState, Action>
try? store.expectedStateShouldMatch(
Expand Down Expand Up @@ -858,9 +855,9 @@
/// ```swift
/// let testStore: TestStoreOf<Feature>
/// ```
public typealias TestStoreOf<R: Reducer> = TestStore<R.State, R.Action>
public typealias TestStoreOf<R: Reducer> = TestStore<R.State, R.Action> where R.State: Equatable

extension TestStore where State: Equatable {
extension TestStore {
/// Sends an action to the store and asserts when state changes.
///
/// To assert on how state changes you can provide a trailing closure, and that closure is handed
Expand Down Expand Up @@ -1276,7 +1273,7 @@
}
}

extension TestStore where State: Equatable, Action: Equatable {
extension TestStore where Action: Equatable {
private func _receive(
_ expectedAction: Action,
assert updateStateToExpectedResult: ((inout State) throws -> Void)? = nil,
Expand Down Expand Up @@ -1450,7 +1447,7 @@
}
}

extension TestStore where State: Equatable {
extension TestStore {
private func _receive(
_ isMatching: (Action) -> Bool,
assert updateStateToExpectedResult: ((inout State) throws -> Void)? = nil,
Expand Down Expand Up @@ -2250,7 +2247,7 @@
}
}

extension TestStore where State: Equatable {
extension TestStore {
/// Sends an action to the store and asserts when state changes.
///
/// This method is similar to ``send(_:assert:fileID:file:line:column:)-8f2pl``, except it allows
Expand Down Expand Up @@ -2814,7 +2811,7 @@
}
}

class TestReducer<State, Action>: Reducer {
class TestReducer<State: Equatable, Action>: Reducer {
let base: Reduce<State, Action>
var dependencies: DependencyValues
let effectDidSubscribe = AsyncStream.makeStream(of: Void.self)
Expand Down
Loading