Skip to content

Commit

Permalink
20: Added test to guard against issue #20
Browse files Browse the repository at this point in the history
  • Loading branch information
KyNorthstar committed Jul 30, 2020
1 parent 77d063c commit a5a3f50
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
37 changes: 37 additions & 0 deletions Tests/LazyContainersTests/GitHubIssue20Tests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// GitHubIssue20Tests.swift
// LazyContainersTests
//
// Created by Ben Leggiero on 2020-07-29.
//

import XCTest
@testable import LazyContainers



var shouldNotRun = false

class ShouldNotInit {
init() {
shouldNotRun = true
}
}



/// Guards against issue #20
/// https://github.com/RougeWare/Swift-Lazy-Patterns/issues/20
final class GitHubIssue20Tests: XCTestCase {

@Lazy
var lazyShouldNotRun = ShouldNotInit()

func testLazyInitWithPropertyWrapper() {
XCTAssertFalse(shouldNotRun)
}

static var allTests = [
("testLazyInitWithPropertyWrapper", testLazyInitWithPropertyWrapper)
]
}
1 change: 1 addition & 0 deletions Tests/LazyContainersTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import XCTest
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(LazyContainersTests.allTests),
testCase(GitHubIssue20Tests.allTests),
]
}
#endif
7 changes: 5 additions & 2 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import XCTest

import LazyContainersTests

var tests = [XCTestCaseEntry]()
tests += LazyContainersTests.allTests()
let tests: [XCTestCaseEntry] = [
LazyContainersTests.allTests,
GitHubIssue20Tests.allTests,
]

XCTMain(tests)

0 comments on commit a5a3f50

Please sign in to comment.