Skip to content

Commit

Permalink
Merge pull request #173 from mattrubin/synthesized-equatable-operator
Browse files Browse the repository at this point in the history
Synthesize Equatable conformance when compiling with Swift 4.1
  • Loading branch information
mattrubin authored Apr 21, 2018
2 parents 127a07a + 3111dcc commit 859880f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ language: objective-c
xcode_workspace: OneTimePassword.xcworkspace
xcode_scheme: OneTimePassword (iOS)

osx_image: xcode9
osx_image: xcode9.3

env:
- RUNTIME="iOS 8.1" DEVICE="iPad 2"
- RUNTIME="iOS 8.4" DEVICE="iPhone 4s"
- RUNTIME="iOS 9.0" DEVICE="iPhone 5s"
- RUNTIME="iOS 9.3" DEVICE="iPhone 6s"
- RUNTIME="iOS 10.0" DEVICE="iPhone SE"
- RUNTIME="iOS 10.3" DEVICE="iPhone 7 Plus"
- RUNTIME="iOS 11.0" DEVICE="iPhone X"
- RUNTIME="iOS 11.3" DEVICE="iPhone X"

# Include builds for watchOS
matrix:
include:
# Include an Xcode 9.0 build to test Swift 4.0 support
- osx_image: xcode9
env: RUNTIME="iOS 11.0" DEVICE="iPhone 8"
# Include an Xcode 9.2 build to test on iOS 8.x, because Xcode 9.3's iOS 8 simulator fails to launch
- osx_image: xcode9.2
env: RUNTIME="iOS 8.4" DEVICE="iPhone 4s"
# Include several build-only jobs for watchOS
- xcode_scheme: OneTimePassword (watchOS)
env: BUILD_ONLY="YES" RUNTIME="watchOS 4.0" DEVICE="Apple Watch Series 3 - 38mm"
env: BUILD_ONLY="YES" RUNTIME="watchOS 4.3" DEVICE="Apple Watch Series 3 - 38mm"
- xcode_scheme: OneTimePassword (watchOS)
env: BUILD_ONLY="YES" RUNTIME="watchOS 3.2" DEVICE="Apple Watch Series 2 - 42mm"
- xcode_scheme: OneTimePassword (watchOS)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public struct Generator: Equatable {
}
}

#if swift(>=4.1)
#else
/// Compares two `Generator`s for equality.
public func == (lhs: Generator, rhs: Generator) -> Bool {
return (lhs.factor == rhs.factor)
Expand All @@ -211,6 +213,7 @@ public func == (lhs: Generator.Factor, rhs: Generator.Factor) -> Bool {
return false
}
}
#endif

// MARK: - Private

Expand Down
3 changes: 3 additions & 0 deletions Sources/PersistentToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public struct PersistentToken: Equatable, Hashable {
}
}

#if swift(>=4.1)
#else
/// Compares two `PersistentToken`s for equality.
public func == (lhs: PersistentToken, rhs: PersistentToken) -> Bool {
return (lhs.identifier == rhs.identifier)
&& (lhs.token == rhs.token)
}
#endif
3 changes: 3 additions & 0 deletions Sources/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ public struct Token: Equatable {
}
}

#if swift(>=4.1)
#else
/// Compares two `Token`s for equality.
public func == (lhs: Token, rhs: Token) -> Bool {
return (lhs.name == rhs.name)
&& (lhs.issuer == rhs.issuer)
&& (lhs.generator == rhs.generator)
}
#endif

0 comments on commit 859880f

Please sign in to comment.