Skip to content

Commit

Permalink
20: Sadly, parameter labels must be reserved for Swift 5.3 for now
Browse files Browse the repository at this point in the history
  • Loading branch information
KyNorthstar committed Aug 1, 2020
1 parent 00000aa commit 362473c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Tests/LazyContainersTests/GitHubIssue20Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import XCTest



#if swift(>=5.3)
var shouldNotRun = false

class ShouldNotInit {
Expand All @@ -35,3 +36,4 @@ final class GitHubIssue20Tests: XCTestCase {
("testLazyInitWithPropertyWrapper", testLazyInitWithPropertyWrapper)
]
}
#endif
23 changes: 21 additions & 2 deletions Tests/LazyContainersTests/LazyContainersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>() {
sideEffectA = "Side effect A2"
Expand Down Expand Up @@ -61,6 +63,7 @@ final class LazyContainersTests: XCTestCase {

// MARK: - `Lazy`

#if swift(>=5.3)
func testLazyInitWithPropertyWrapperAndCustomInitializerWithSideEffect() {
XCTAssertEqual(sideEffectA, nil)
XCTAssertFalse(_lazyInitWithPropertyWrapperAndCustomInitializerWithSideEffect.isInitialized)
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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),
Expand All @@ -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
}

0 comments on commit 362473c

Please sign in to comment.