diff --git a/ComposableArchitecture.xcworkspace/contents.xcworkspacedata b/ComposableArchitecture.xcworkspace/contents.xcworkspacedata index 3351883247b5..f562e7d0e9ff 100644 --- a/ComposableArchitecture.xcworkspace/contents.xcworkspacedata +++ b/ComposableArchitecture.xcworkspace/contents.xcworkspacedata @@ -1,9 +1,6 @@ - - diff --git a/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6a817126f01c..5052698fa3a5 100644 --- a/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-case-paths", "state" : { - "revision" : "bba1111185863c9288c5f047770f421c3b7793a4", - "version" : "1.1.3" + "revision" : "e593aba2c6222daad7c4f2732a431eed2c09bb07", + "version" : "1.3.0" } }, { @@ -50,8 +50,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections", "state" : { - "revision" : "d029d9d39c87bed85b1c50adee7c41795261a192", - "version" : "1.0.6" + "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", + "version" : "1.1.0" } }, { diff --git a/Examples/SyncUps/SyncUps/AppFeature.swift b/Examples/SyncUps/SyncUps/AppFeature.swift index 0b8a7e1254fd..dafca442ac2b 100644 --- a/Examples/SyncUps/SyncUps/AppFeature.swift +++ b/Examples/SyncUps/SyncUps/AppFeature.swift @@ -67,7 +67,7 @@ struct AppFeature { return .none } - state.path[id: id, case: \.detail]?.syncUp.meetings.insert( + state.path[id: id]?.detail?.syncUp.meetings.insert( Meeting( id: Meeting.ID(self.uuid()), date: self.now, @@ -75,7 +75,7 @@ struct AppFeature { ), at: 0 ) - guard let syncUp = state.path[id: id, case: \.detail]?.syncUp + guard let syncUp = state.path[id: id]?.detail?.syncUp else { return .none } state.syncUpsList.syncUps[id: syncUp.id] = syncUp return .none diff --git a/Examples/SyncUps/SyncUpsTests/AppFeatureTests.swift b/Examples/SyncUps/SyncUpsTests/AppFeatureTests.swift index 1666f89e6dc6..cc30596f21c7 100644 --- a/Examples/SyncUps/SyncUpsTests/AppFeatureTests.swift +++ b/Examples/SyncUps/SyncUpsTests/AppFeatureTests.swift @@ -22,11 +22,11 @@ final class AppFeatureTests: XCTestCase { } await store.send(\.path[id:0].detail.deleteButtonTapped) { - $0.path[id: 0, case: \.detail]?.destination = .alert(.deleteSyncUp) + $0.path[id: 0]?.detail?.destination = .alert(.deleteSyncUp) } await store.send(\.path[id:0].detail.destination.alert.confirmDeletion) { - $0.path[id: 0, case: \.detail]?.destination = nil + $0.path[id: 0]?.detail?.destination = nil } await store.receive(\.path[id:0].detail.delegate.deleteSyncUp) { @@ -59,19 +59,19 @@ final class AppFeatureTests: XCTestCase { } await store.send(\.path[id:0].detail.editButtonTapped) { - $0.path[id: 0, case: \.detail]?.destination = .edit( + $0.path[id: 0]?.detail?.destination = .edit( SyncUpForm.State(syncUp: syncUp) ) } syncUp.title = "Blob" await store.send(\.path[id:0].detail.destination.edit.syncUp, syncUp) { - $0.path[id: 0, case: \.detail]?.$destination[case: \.edit]?.syncUp.title = "Blob" + $0.path[id: 0]?.detail?.destination?.edit?.syncUp.title = "Blob" } await store.send(\.path[id:0].detail.doneEditingButtonTapped) { - $0.path[id: 0, case: \.detail]?.destination = nil - $0.path[id: 0, case: \.detail]?.syncUp.title = "Blob" + $0.path[id: 0]?.detail?.destination = nil + $0.path[id: 0]?.detail?.syncUp.title = "Blob" } await store.receive(\.path[id:0].detail.delegate.syncUpUpdated) { @@ -127,7 +127,7 @@ final class AppFeatureTests: XCTestCase { await store.send(\.path[id:1].record.onTask) await store.receive(\.path[id:1].record.delegate.save) { - $0.path[id: 0, case: \.detail]?.syncUp.meetings = [ + $0.path[id: 0]?.detail?.syncUp.meetings = [ Meeting( id: Meeting.ID(UUID(0)), date: Date(timeIntervalSince1970: 1_234_567_890), diff --git a/Examples/SyncUps/SyncUpsTests/SyncUpDetailTests.swift b/Examples/SyncUps/SyncUpsTests/SyncUpDetailTests.swift index 3a2f803ddd7d..548bbcb8b904 100644 --- a/Examples/SyncUps/SyncUpsTests/SyncUpDetailTests.swift +++ b/Examples/SyncUps/SyncUpsTests/SyncUpDetailTests.swift @@ -97,7 +97,7 @@ final class SyncUpDetailTests: XCTestCase { syncUp.title = "Blob's Meeting" await store.send(\.destination.edit.syncUp, syncUp) { - $0.$destination[case: \.edit]?.syncUp.title = "Blob's Meeting" + $0.destination?.edit?.syncUp.title = "Blob's Meeting" } await store.send(.doneEditingButtonTapped) { diff --git a/Examples/SyncUps/SyncUpsTests/SyncUpsListTests.swift b/Examples/SyncUps/SyncUpsTests/SyncUpsListTests.swift index cac8683028dc..41c7e99f5b15 100644 --- a/Examples/SyncUps/SyncUpsTests/SyncUpsListTests.swift +++ b/Examples/SyncUps/SyncUpsTests/SyncUpsListTests.swift @@ -26,7 +26,7 @@ final class SyncUpsListTests: XCTestCase { syncUp.title = "Engineering" await store.send(\.destination.add.syncUp, syncUp) { - $0.$destination[case: \.add]?.syncUp.title = "Engineering" + $0.destination?.add?.syncUp.title = "Engineering" } await store.send(.confirmAddSyncUpButtonTapped) { diff --git a/Examples/TicTacToe/tic-tac-toe/Tests/AppCoreTests/AppCoreTests.swift b/Examples/TicTacToe/tic-tac-toe/Tests/AppCoreTests/AppCoreTests.swift index 44b4f20e61c4..e794be25d34c 100644 --- a/Examples/TicTacToe/tic-tac-toe/Tests/AppCoreTests/AppCoreTests.swift +++ b/Examples/TicTacToe/tic-tac-toe/Tests/AppCoreTests/AppCoreTests.swift @@ -18,28 +18,20 @@ final class AppCoreTests: XCTestCase { } await store.send(\.login.view.email, "blob@pointfree.co") { - $0.modify(\.login) { - $0.email = "blob@pointfree.co" - } + $0.login?.email = "blob@pointfree.co" } await store.send(\.login.view.password, "bl0bbl0b") { - $0.modify(\.login) { - $0.password = "bl0bbl0b" - $0.isFormValid = true - } + $0.login?.password = "bl0bbl0b" + $0.login?.isFormValid = true } await store.send(\.login.view.loginButtonTapped) { - $0.modify(\.login) { - $0.isLoginRequestInFlight = true - } + $0.login?.isLoginRequestInFlight = true } await store.receive(\.login.loginResponse.success) { $0 = .newGame(NewGame.State()) } await store.send(\.newGame.oPlayerName, "Blob Sr.") { - $0.modify(\.newGame) { - $0.oPlayerName = "Blob Sr." - } + $0.newGame?.oPlayerName = "Blob Sr." } await store.send(\.newGame.logoutButtonTapped) { $0 = .login(Login.State()) @@ -59,41 +51,29 @@ final class AppCoreTests: XCTestCase { } await store.send(\.login.view.email, "blob@pointfree.co") { - $0.modify(\.login) { - $0.email = "blob@pointfree.co" - } + $0.login?.email = "blob@pointfree.co" } await store.send(\.login.view.password, "bl0bbl0b") { - $0.modify(\.login) { - $0.password = "bl0bbl0b" - $0.isFormValid = true - } + $0.login?.password = "bl0bbl0b" + $0.login?.isFormValid = true } await store.send(\.login.view.loginButtonTapped) { - $0.modify(\.login) { - $0.isLoginRequestInFlight = true - } + $0.login?.isLoginRequestInFlight = true } await store.receive(\.login.loginResponse.success) { - $0.modify(\.login) { - $0.isLoginRequestInFlight = false - $0.twoFactor = TwoFactor.State(token: "deadbeef") - } + $0.login?.isLoginRequestInFlight = false + $0.login?.twoFactor = TwoFactor.State(token: "deadbeef") } await store.send(\.login.twoFactor.view.code, "1234") { - $0.modify(\.login) { - $0.twoFactor?.code = "1234" - $0.twoFactor?.isFormValid = true - } + $0.login?.twoFactor?.code = "1234" + $0.login?.twoFactor?.isFormValid = true } await store.send(\.login.twoFactor.view.submitButtonTapped) { - $0.modify(\.login) { - $0.twoFactor?.isTwoFactorRequestInFlight = true - } + $0.login?.twoFactor?.isTwoFactorRequestInFlight = true } await store.receive(\.login.twoFactor.twoFactorResponse.success) { $0 = .newGame(NewGame.State()) diff --git a/Package.resolved b/Package.resolved index f2e26e674c05..01491b1cf6cb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-case-paths", "state" : { - "revision" : "bba1111185863c9288c5f047770f421c3b7793a4", - "version" : "1.1.3" + "revision" : "e593aba2c6222daad7c4f2732a431eed2c09bb07", + "version" : "1.3.0" } }, { diff --git a/Package.swift b/Package.swift index ba1f896c0ab1..f0585cce0218 100644 --- a/Package.swift +++ b/Package.swift @@ -21,7 +21,7 @@ let package = Package( .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), .package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"), .package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.0"), - .package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.1.0"), + .package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.3.0"), .package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.1.0"), .package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.0.0"), .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"), diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift index bb9808906d73..9fa05b41d34b 100644 --- a/Package@swift-5.9.swift +++ b/Package@swift-5.9.swift @@ -23,7 +23,7 @@ let package = Package( .package(url: "https://github.com/apple/swift-syntax", from: "509.0.0"), .package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"), .package(url: "https://github.com/pointfreeco/combine-schedulers", from: "1.0.0"), - .package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.1.0"), + .package(url: "https://github.com/pointfreeco/swift-case-paths", from: "1.3.0"), .package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.1.0"), .package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.0.0"), .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.1.0"), diff --git a/Sources/ComposableArchitecture/TestStore.swift b/Sources/ComposableArchitecture/TestStore.swift index 5304d5b8d83b..9fcfda18c3ef 100644 --- a/Sources/ComposableArchitecture/TestStore.swift +++ b/Sources/ComposableArchitecture/TestStore.swift @@ -529,43 +529,6 @@ public final class TestStore { self.useMainSerialExecutor = true } - /// Creates a test store with an initial state and a reducer powering its runtime. - /// - /// See and the documentation of ``TestStore`` for more information on how to best - /// use a test store. - /// - /// - Parameters: - /// - initialState: The state the feature starts in. - /// - reducer: The reducer that powers the runtime of the feature. - /// - prepareDependencies: A closure that can be used to override dependencies that will be - /// accessed during the test. These dependencies will be used when producing the initial - /// state. - @available(*, deprecated, message: "State must be equatable to perform assertions.") - public init( - initialState: @autoclosure () -> R.State, - @ReducerBuilder reducer: () -> R, - withDependencies prepareDependencies: (inout DependencyValues) -> Void = { _ in - }, - file: StaticString = #file, - line: UInt = #line - ) - where - R.State == State, - R.Action == Action - { - let reducer = XCTFailContext.$current.withValue(XCTFailContext(file: file, line: line)) { - Dependencies.withDependencies(prepareDependencies) { - TestReducer(Reduce(reducer()), initialState: initialState()) - } - } - self.file = file - self.line = line - self.reducer = reducer - self.store = Store(initialState: reducer.state) { reducer } - self.timeout = 1 * NSEC_PER_SEC - self.useMainSerialExecutor = true - } - // NB: Only needed until Xcode ships a macOS SDK that uses the 5.7 standard library. // See: https://forums.swift.org/t/xcode-14-rc-cannot-specialize-protocol-type/60171/15 #if (canImport(RegexBuilder) || !os(macOS) && !targetEnvironment(macCatalyst))