diff --git a/Sources/AllTestz/main.swift b/Sources/AllTestz/main.swift index 4d6eee064..4a0dc0a4b 100644 --- a/Sources/AllTestz/main.swift +++ b/Sources/AllTestz/main.swift @@ -296,18 +296,6 @@ final class EventTests_ : EventTests, RxTestCase { ] } } -final class Foo_ : Foo, RxTestCase { - #if os(macOS) - required override init() { - super.init() - } - #endif - - static var allTests: [(String, (Foo_) -> () -> Void)] { return [ - ("testObservableFactoryClosureLifetime", Foo.testObservableFactoryClosureLifetime), - ] } -} - final class HistoricalSchedulerTest_ : HistoricalSchedulerTest, RxTestCase { #if os(macOS) required override init() { @@ -1670,6 +1658,7 @@ final class ObservableTest_ : ObservableTest, RxTestCase { ("testAsObservable_never", ObservableTest.testAsObservable_never), ("testSubscribeWithNext", ObservableTest.testSubscribeWithNext), ("testDeferredFactoryClosureLifetime", ObservableTest.testDeferredFactoryClosureLifetime), + ("testObservableFactoryClosureLifetime", ObservableTest.testObservableFactoryClosureLifetime), ] } } @@ -2247,7 +2236,6 @@ func XCTMain(_ tests: [() -> Void]) { testCase(DisposeBagTest_.allTests), testCase(DriverTest_.allTests), testCase(EventTests_.allTests), - testCase(Foo_.allTests), testCase(HistoricalSchedulerTest_.allTests), testCase(InfallibleCombineLatestTest_.allTests), testCase(InfallibleTest_.allTests), diff --git a/Tests/RxSwiftTests/Observable+Tests.swift b/Tests/RxSwiftTests/Observable+Tests.swift index efca33e12..19ccedbc7 100644 --- a/Tests/RxSwiftTests/Observable+Tests.swift +++ b/Tests/RxSwiftTests/Observable+Tests.swift @@ -229,26 +229,26 @@ extension ObservableTest { } // MARK: - Deferred -extension ObservableTest { - func testDeferredFactoryClosureLifetime() { - class Foo { - let expectation: XCTestExpectation +private class DeferredExpectation { + let expectation: XCTestExpectation - init(expectation: XCTestExpectation) { - self.expectation = expectation - } + init(expectation: XCTestExpectation) { + self.expectation = expectation + } - func bar() -> Observable { - Observable - .deferred { - self.expectation.fulfill() - return .never() - } + func bar() -> Observable { + Observable + .deferred { + self.expectation.fulfill() + return .never() } - } + } +} +extension ObservableTest { + func testDeferredFactoryClosureLifetime() { let factoryClosureInvoked = expectation(description: "Factory closure has been invoked") - var foo: Foo? = Foo(expectation: factoryClosureInvoked) + var foo: DeferredExpectation? = DeferredExpectation(expectation: factoryClosureInvoked) weak var initialFoo = foo let disposable = foo?.bar().subscribe()