Skip to content

Commit

Permalink
Merge pull request #38 from SwiftPackageIndex/add-SwiftVersion.init
Browse files Browse the repository at this point in the history
Add SwiftVersion.init(major:minor:)
  • Loading branch information
finestructure committed Feb 12, 2024
2 parents 7396dec + 052950a commit 49d1003
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/SPIManifest/SwiftVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ public enum SwiftVersion: ShortVersion, Codable, CaseIterable {
case v5_6 = "5.6"
case v5_7 = "5.7"
case v5_8 = "5.8"
case v5_9 = "5.9" // currently a pre-release version
case v5_9 = "5.9"

public static var latestRelease: Self { .v5_9 }

public init?(major: Int, minor: Int) {
self.init(rawValue: "\(major).\(minor)")
}
}


Expand Down
5 changes: 5 additions & 0 deletions Tests/SPIManifestTests/SwiftVersionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import XCTest

class SwiftVersionTests: XCTestCase {

func test_init() throws {
XCTAssertEqual(SwiftVersion(major: 5, minor: 9), .v5_9)
XCTAssertEqual(SwiftVersion(major: 5, minor: 5), nil)
}

func test_isLatestRelease() throws {
XCTAssertEqual(SwiftVersion.v5_7.isLatestRelease, false)
XCTAssertEqual(SwiftVersion.v5_8.isLatestRelease, false)
Expand Down

0 comments on commit 49d1003

Please sign in to comment.