Skip to content

Commit

Permalink
Move foo test class out of test
Browse files Browse the repository at this point in the history
  • Loading branch information
freak4pc committed Apr 20, 2024
1 parent 906ccbf commit cb33afe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
14 changes: 1 addition & 13 deletions Sources/AllTestz/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -1670,6 +1658,7 @@ final class ObservableTest_ : ObservableTest, RxTestCase {
("testAsObservable_never", ObservableTest.testAsObservable_never),
("testSubscribeWithNext", ObservableTest.testSubscribeWithNext),
("testDeferredFactoryClosureLifetime", ObservableTest.testDeferredFactoryClosureLifetime),
("testObservableFactoryClosureLifetime", ObservableTest.testObservableFactoryClosureLifetime),
] }
}

Expand Down Expand Up @@ -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),
Expand Down
30 changes: 15 additions & 15 deletions Tests/RxSwiftTests/Observable+Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> {
Observable<Void>
.deferred {
self.expectation.fulfill()
return .never()
}
func bar() -> Observable<Void> {
Observable<Void>
.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()
Expand Down

0 comments on commit cb33afe

Please sign in to comment.