diff --git a/Tests/LazyContainersTests/GitHubIssue20Tests.swift b/Tests/LazyContainersTests/GitHubIssue20Tests.swift index b8bbdc0..2d5eaa8 100644 --- a/Tests/LazyContainersTests/GitHubIssue20Tests.swift +++ b/Tests/LazyContainersTests/GitHubIssue20Tests.swift @@ -10,6 +10,7 @@ import XCTest +#if swift(>=5.3) var shouldNotRun = false class ShouldNotInit { @@ -35,3 +36,4 @@ final class GitHubIssue20Tests: XCTestCase { ("testLazyInitWithPropertyWrapper", testLazyInitWithPropertyWrapper) ] } +#endif diff --git a/Tests/LazyContainersTests/LazyContainersTests.swift b/Tests/LazyContainersTests/LazyContainersTests.swift index 5475c42..9b1c7bd 100644 --- a/Tests/LazyContainersTests/LazyContainersTests.swift +++ b/Tests/LazyContainersTests/LazyContainersTests.swift @@ -28,8 +28,10 @@ func makeLazyB() -> String { final class LazyContainersTests: XCTestCase { + #if swift(>=5.3) @Lazy(initializer: makeLazyA) var lazyInitWithPropertyWrapperAndCustomInitializerWithSideEffect: String + #endif var lazyInitTraditionally = Lazy() { sideEffectA = "Side effect A2" @@ -61,6 +63,7 @@ final class LazyContainersTests: XCTestCase { // MARK: - `Lazy` + #if swift(>=5.3) func testLazyInitWithPropertyWrapperAndCustomInitializerWithSideEffect() { XCTAssertEqual(sideEffectA, nil) XCTAssertFalse(_lazyInitWithPropertyWrapperAndCustomInitializerWithSideEffect.isInitialized) @@ -111,6 +114,7 @@ final class LazyContainersTests: XCTestCase { XCTAssertNil(sideEffectB, "@Lazy eagerly evaluated its initial value") XCTAssertEqual(test.lazyInitWithPropertyWrapperAndSideEffect, "Lazy B (this time with side-effects)") } + #endif func testLazyInitTraditionally() { @@ -270,9 +274,16 @@ final class LazyContainersTests: XCTestCase { XCTAssertEqual("Manual F", functionalLazyInitTraditionally.wrappedValue) XCTAssertTrue(functionalLazyInitTraditionally.isInitialized) } - - static var allTests = [ + + #if swift(>=5.3) + static let testsWhichRequireSwift5_3 = [ ("testLazyInitWithPropertyWrapperWithCustomInitializerAndSideEffect", testLazyInitWithPropertyWrapperAndCustomInitializerWithSideEffect), + ("testLazyInitWithPropertyWrapperAndSideEffect", testLazyInitWithPropertyWrapperAndSideEffect), + ] + #endif + + + static let testsWhichWorkBeforeSwift5_3 = [ ("testLazyInitTraditionally", testLazyInitTraditionally), ("testResettableLazyInitWithPropertyWrapper", testResettableLazyInitWithPropertyWrapper), @@ -281,4 +292,12 @@ final class LazyContainersTests: XCTestCase { ("testFunctionalLazyInitWithPropertyWrapper", testFunctionalLazyInitWithPropertyWrapper), ("testFunctionalLazyInitTraditionally", testFunctionalLazyInitTraditionally), ] + + + #if swift(>=5.3) + static let allTests = testsWhichRequireSwift5_3 + testsWhichWorkBeforeSwift5_3 + #else + @inline(__always) + static let allTests = testsWhichWorkBeforeSwift5_3 + #endif }