diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a88c38d..3482801 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,7 @@ name: Linting on: pull_request: - branches: [ main ] + branches: [main] jobs: check-changes: @@ -24,9 +24,11 @@ jobs: Lint: runs-on: ubuntu-latest + container: + image: swift:6.2-jammy if: ${{ github.event_name == 'push' || needs.check-changes.outputs.changed == 'true' }} needs: check-changes steps: - uses: actions/checkout@v3 - name: "๐Ÿงน Lint changed files" - run: make lint + run: swift package plugin --allow-writing-to-package-directory swiftformat . --lint diff --git a/.github/workflows/linux-tests.yml b/.github/workflows/linux-tests.yml index 592670e..9d1dc79 100644 --- a/.github/workflows/linux-tests.yml +++ b/.github/workflows/linux-tests.yml @@ -33,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - swift: [ "swift:6.1", "swift:6.2", "swift:6.3" ] + swift: [ "swift:6.2", "swift:6.3" ] os: [ amazonlinux2, jammy, rhel-ubi9, noble ] container: diff --git a/.gitignore b/.gitignore index 76f02d4..fb0b96c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ /Packages /*.xcodeproj xcuserdata/ -/Release -/Package.resolved \ No newline at end of file +/Release \ No newline at end of file diff --git a/.swift-version b/.swift-version index f9ce5a9..0cda48a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -5.10 +6.2 diff --git a/Examples/Examples/Dependencies.swift b/Examples/Examples/Dependencies.swift index e100996..d2d9deb 100644 --- a/Examples/Examples/Dependencies.swift +++ b/Examples/Examples/Dependencies.swift @@ -16,7 +16,7 @@ import Vexil struct Dependencies { var flags = FlagPole( hoist: FeatureFlags.self, - sources: FlagPole.defaultSources + [RemoteFlags.values] + sources: FlagPole.defaultSources + [RemoteFlags.values], ) @TaskLocal diff --git a/Examples/Examples/DoubleAndBooleanControlStyle.swift b/Examples/Examples/DoubleAndBooleanControlStyle.swift index ec0d7e6..0bd3783 100644 --- a/Examples/Examples/DoubleAndBooleanControlStyle.swift +++ b/Examples/Examples/DoubleAndBooleanControlStyle.swift @@ -34,6 +34,8 @@ struct DoubleAndBooleanControlStyle: FlagControlStyle { extension FlagControlStyle where Self == DoubleAndBooleanControlStyle { - static var doubleAndBoolean: Self { Self() } + static var doubleAndBoolean: Self { + Self() + } } diff --git a/Examples/Examples/RootView.swift b/Examples/Examples/RootView.swift index 1402a42..09cabf6 100644 --- a/Examples/Examples/RootView.swift +++ b/Examples/Examples/RootView.swift @@ -34,7 +34,7 @@ struct RootView: View { } .flagPole( Dependencies.current.flags, - editableSource: Dependencies.current.flags._sources.first + editableSource: Dependencies.current.flags._sources.first, ) .flagControlStyle(.doubleAndBoolean) diff --git a/Examples/ExamplesTests/ExamplesTests.swift b/Examples/ExamplesTests/ExamplesTests.swift index 4af5294..96fa3b6 100644 --- a/Examples/ExamplesTests/ExamplesTests.swift +++ b/Examples/ExamplesTests/ExamplesTests.swift @@ -17,7 +17,7 @@ import Testing struct ExamplesTests { @Test - func example() async throws { + func example() { // Write your test here and use APIs like `#expect(...)` to check expected conditions. } diff --git a/Examples/Package.swift b/Examples/Package.swift index 104d5ac..e18f18c 100644 --- a/Examples/Package.swift +++ b/Examples/Package.swift @@ -6,5 +6,5 @@ let package = Package( name: "", products: [], dependencies: [], - targets: [] + targets: [], ) diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..044bf93 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,42 @@ +{ + "originHash" : "7724a377457178ce875fe18adc9a76467dd42003b108c81973a2c98f158d4aef", + "pins" : [ + { + "identity" : "swift-async-algorithms", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-async-algorithms.git", + "state" : { + "revision" : "042e1c4d9d19748c9c228f8d4ebc97bb1e339b0b", + "version" : "1.0.4" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections.git", + "state" : { + "revision" : "8c0c0a8b49e080e54e5e328cc552821ff07cd341", + "version" : "1.2.1" + } + }, + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swiftlang/swift-syntax.git", + "state" : { + "revision" : "0687f71944021d616d34d922343dcef086855920", + "version" : "600.0.1" + } + }, + { + "identity" : "swiftformat", + "kind" : "remoteSourceControl", + "location" : "https://github.com/nicklockwood/SwiftFormat.git", + "state" : { + "revision" : "c8e50ff2cfc2eab46246c072a9ae25ab656c6ec3", + "version" : "0.60.1" + } + } + ], + "version" : 3 +} diff --git a/Package.swift b/Package.swift index bc83b29..aaa4bd4 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:6.1 +// swift-tools-version:6.2 // The swift-tools-version declares the minimum version of Swift required to build this package. import CompilerPluginSupport @@ -20,7 +20,7 @@ let package = Package( dependencies: [ .package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"), - .package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.54.1"), + .package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.60.1"), .package(url: "https://github.com/swiftlang/swift-syntax.git", "600.0.0" ..< "603.0.0"), ], @@ -33,13 +33,13 @@ let package = Package( dependencies: [ .target(name: "VexilMacros"), .product(name: "AsyncAlgorithms", package: "swift-async-algorithms"), - ] + ], ), .testTarget( name: "VexilTests", dependencies: [ .target(name: "Vexil"), - ] + ], ), // Macros @@ -51,7 +51,7 @@ let package = Package( .product(name: "SwiftSyntax", package: "swift-syntax"), .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), - ] + ], ), @@ -59,7 +59,7 @@ let package = Package( swiftLanguageModes: [ .v6, - ] + ], ) @@ -70,7 +70,7 @@ let package = Package( // Vexillographer is not supported on Linux package.products.append( - .library(name: "Vexillographer", targets: [ "Vexillographer" ]) + .library(name: "Vexillographer", targets: [ "Vexillographer" ]), ) package.targets.append( @@ -78,8 +78,8 @@ package.targets.append( name: "Vexillographer", dependencies: [ .target(name: "Vexil"), - ] - ) + ], + ), ) // MARK: - Macro Testing @@ -91,8 +91,8 @@ package.targets.append( dependencies: [ .target(name: "VexilMacros"), .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), - ] - ) + ], + ), ) #endif diff --git a/Sources/Vexil/Container.swift b/Sources/Vexil/Container.swift index 1082680..e09fa73 100644 --- a/Sources/Vexil/Container.swift +++ b/Sources/Vexil/Container.swift @@ -21,7 +21,7 @@ names: named(_flagKeyPath), named(_flagLookup), named(init(_flagKeyPath:_flagLookup:)) ) public macro FlagContainer( - generateEquatable: any ExpressibleByBooleanLiteral = true + generateEquatable: any ExpressibleByBooleanLiteral = true, ) = #externalMacro(module: "VexilMacros", type: "FlagContainerMacro") public protocol FlagContainer: Sendable { diff --git a/Sources/Vexil/Flag.swift b/Sources/Vexil/Flag.swift index 490ecf8..f5be4c8 100644 --- a/Sources/Vexil/Flag.swift +++ b/Sources/Vexil/Flag.swift @@ -45,7 +45,7 @@ @attached(accessor) @attached(peer, names: prefixed(`$`)) public macro Flag( - _ description: StaticString + _ description: StaticString, ) = #externalMacro(module: "VexilMacros", type: "FlagMacro") /// Creates a flag with the specified configuration. @@ -91,5 +91,5 @@ public macro Flag( name: StaticString? = nil, keyStrategy: VexilConfiguration.FlagKeyStrategy = .default, description: StaticString, - display: FlagDisplayOption = .default + display: FlagDisplayOption = .default, ) = #externalMacro(module: "VexilMacros", type: "FlagMacro") diff --git a/Sources/Vexil/Group.swift b/Sources/Vexil/Group.swift index 42c3ecb..7e65e99 100644 --- a/Sources/Vexil/Group.swift +++ b/Sources/Vexil/Group.swift @@ -52,7 +52,7 @@ @attached(peer, names: prefixed(`$`)) public macro FlagGroup( _ description: StaticString, - display: FlagGroupDisplayOption = .navigation + display: FlagGroupDisplayOption = .navigation, ) = #externalMacro(module: "VexilMacros", type: "FlagGroupMacro") /// Creates a FlagGroup with the given parameters. @@ -98,7 +98,7 @@ public macro FlagGroup( @attached(accessor) @attached(peer, names: prefixed(`$`)) public macro FlagGroup( - _ description: StaticString + _ description: StaticString, ) = #externalMacro(module: "VexilMacros", type: "FlagGroupMacro") @attached(accessor) @@ -107,5 +107,5 @@ public macro FlagGroup( name: StaticString? = nil, keyStrategy: VexilConfiguration.GroupKeyStrategy = .default, description: StaticString, - display: FlagGroupDisplayOption = .navigation + display: FlagGroupDisplayOption = .navigation, ) = #externalMacro(module: "VexilMacros", type: "FlagGroupMacro") diff --git a/Sources/Vexil/KeyPath.swift b/Sources/Vexil/KeyPath.swift index 89b776f..516d198 100644 --- a/Sources/Vexil/KeyPath.swift +++ b/Sources/Vexil/KeyPath.swift @@ -37,7 +37,7 @@ public struct FlagKeyPath: Hashable, Sendable { _ keyPath: [Key], separator: String = ".", strategy: VexilConfiguration.CodingKeyStrategy = .default, - key: String + key: String, ) { self.keyPath = keyPath self.separator = separator @@ -48,7 +48,7 @@ public struct FlagKeyPath: Hashable, Sendable { public init( _ keyPath: [Key], separator: String = ".", - strategy: VexilConfiguration.CodingKeyStrategy = .default + strategy: VexilConfiguration.CodingKeyStrategy = .default, ) { self.keyPath = keyPath self.separator = separator @@ -89,7 +89,7 @@ public struct FlagKeyPath: Hashable, Sendable { case .root: self.key // mostly a noop } - }() + }(), ) } @@ -97,7 +97,7 @@ public struct FlagKeyPath: Hashable, Sendable { FlagKeyPath( [ .root ], separator: separator, - strategy: strategy + strategy: strategy, ) } diff --git a/Sources/Vexil/Lookup.swift b/Sources/Vexil/Lookup.swift index ee4fb25..0a933aa 100644 --- a/Sources/Vexil/Lookup.swift +++ b/Sources/Vexil/Lookup.swift @@ -20,7 +20,7 @@ import Foundation public protocol FlagLookup: Sendable { @inlinable - func value(for keyPath: FlagKeyPath) -> Value? where Value: FlagValue + func value(for keyPath: FlagKeyPath) -> Value? var changes: FlagChangeStream { get } @@ -35,7 +35,7 @@ extension FlagPole: FlagLookup { /// that key, returning the first non-nil value it finds. /// @inlinable - public func value(for keyPath: FlagKeyPath) -> Value? where Value: FlagValue { + public func value(for keyPath: FlagKeyPath) -> Value? { for source in _sources { if let value: Value = source.flagValue(key: keyPath.key) { return value diff --git a/Sources/Vexil/Observability/FlagGroupWigwag.swift b/Sources/Vexil/Observability/FlagGroupWigwag.swift index 54a148d..6633c9c 100644 --- a/Sources/Vexil/Observability/FlagGroupWigwag.swift +++ b/Sources/Vexil/Observability/FlagGroupWigwag.swift @@ -24,7 +24,7 @@ import Combine /// /// For more information on Wigwags see https://en.wikipedia.org/wiki/Wigwag_(flag_signals) /// -public struct FlagGroupWigwag: Sendable where Output: FlagContainer { +public struct FlagGroupWigwag: Sendable { // MARK: - Properties @@ -58,7 +58,7 @@ public struct FlagGroupWigwag: Sendable where Output: FlagContainer { name: String, description: String?, displayOption: FlagGroupDisplayOption?, - lookup: any FlagLookup + lookup: any FlagLookup, ) { self.keyPath = keyPath self.name = name @@ -89,7 +89,7 @@ extension FlagGroupWigwag: AsyncSequence { private func makeAsyncSequence() -> Sequence { chain( [ getOutput() ].async, - changes.map { _ in getOutput() } + changes.map { _ in getOutput() }, ) } @@ -110,7 +110,7 @@ extension FlagGroupWigwag: Publisher { public typealias Output = Output public typealias Failure = Never - public func receive(subscriber: S) where S: Subscriber, S.Failure == Failure, S.Input == Output { + public func receive(subscriber: S) where S.Failure == Failure, S.Input == Output { FlagPublisher(makeAsyncSequence()) .receive(subscriber: subscriber) } diff --git a/Sources/Vexil/Observability/FlagWigwag.swift b/Sources/Vexil/Observability/FlagWigwag.swift index 8e6137b..8e13e11 100644 --- a/Sources/Vexil/Observability/FlagWigwag.swift +++ b/Sources/Vexil/Observability/FlagWigwag.swift @@ -24,7 +24,7 @@ import Combine /// /// For more information on Wigwags see https://en.wikipedia.org/wiki/Wigwag_(flag_signals) /// -public struct FlagWigwag: Sendable where Output: FlagValue { +public struct FlagWigwag: Sendable { // MARK: - Properties @@ -67,7 +67,7 @@ public struct FlagWigwag: Sendable where Output: FlagValue { defaultValue: Output, description: String?, displayOption: FlagDisplayOption, - lookup: any FlagLookup + lookup: any FlagLookup, ) { self.keyPath = keyPath self.name = name @@ -99,7 +99,7 @@ extension FlagWigwag: AsyncSequence { private func makeAsyncSequence() -> Sequence { chain( [ getOutput() ].async, - changes.map { _ in getOutput() } + changes.map { _ in getOutput() }, ) } @@ -120,7 +120,7 @@ extension FlagWigwag: Publisher { public typealias Output = Output public typealias Failure = Never - public func receive(subscriber: S) where S: Subscriber, S.Failure == Failure, S.Input == Output { + public func receive(subscriber: S) where S.Failure == Failure, S.Input == Output { FlagPublisher(makeAsyncSequence()) .receive(subscriber: subscriber) } diff --git a/Sources/Vexil/Observability/Observing.swift b/Sources/Vexil/Observability/Observing.swift index 24d701a..c37ec12 100644 --- a/Sources/Vexil/Observability/Observing.swift +++ b/Sources/Vexil/Observability/Observing.swift @@ -57,7 +57,7 @@ public struct FilteredFlagChangeStream: AsyncSequence, Sendable { #if swift(>=6) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public mutating func next( - isolation actor: isolated (any Actor)? + isolation actor: isolated (any Actor)?, ) async -> FlagChange? { await iterator.next(isolation: actor) } @@ -98,7 +98,7 @@ public struct EmptyFlagChangeStream: AsyncSequence, Sendable { #if swift(>=6) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public func next( - isolation actor: isolated (any Actor)? + isolation actor: isolated (any Actor)?, ) async -> FlagChange? { nil } diff --git a/Sources/Vexil/Pole+Observability.swift b/Sources/Vexil/Pole+Observability.swift index eb03b92..500f7d7 100644 --- a/Sources/Vexil/Pole+Observability.swift +++ b/Sources/Vexil/Pole+Observability.swift @@ -26,7 +26,7 @@ import Combine /// Each subscriber to the `Publisher` will iterate over the sequence independently, /// use `.multicast()` or `.shared()` if you want to share the iterator. /// -struct FlagPublisher: Sendable where Elements: _Concurrency.AsyncSequence & Sendable, Elements.Element: Sendable { +struct FlagPublisher where Elements.Element: Sendable { /// The `AsyncSequence` that we are publishing elements from let sequence: Elements @@ -46,7 +46,7 @@ extension FlagPublisher: Publisher { typealias Output = Elements.Element typealias Failure = Never - func receive(subscriber: S) where S: Subscriber, Failure == S.Failure, Elements.Element == S.Input { + func receive(subscriber: S) where Failure == S.Failure, Elements.Element == S.Input { let subscription = Subscription(sequence: sequence, downstream: subscriber) subscriber.receive(subscription: subscription) } diff --git a/Sources/Vexil/Pole.swift b/Sources/Vexil/Pole.swift index 2e7074b..8c7e742 100644 --- a/Sources/Vexil/Pole.swift +++ b/Sources/Vexil/Pole.swift @@ -45,7 +45,7 @@ import Foundation /// so as not to conflict with the dynamic member properties on your `FlagContainer`. /// @dynamicMemberLookup -public final class FlagPole: Sendable where RootGroup: FlagContainer { +public final class FlagPole: Sendable { // MARK: - Properties @@ -188,7 +188,7 @@ public final class FlagPole: Sendable where RootGroup: FlagContainer self?.snapshot(including: change) } .prefix(while: { $0 != nil }) // close the stream when we get nil back - .compactMap { $0 } + .compactMap(\.self) return chain([ snapshot() ].async, snapshotStream) } @@ -289,7 +289,7 @@ public final class FlagPole: Sendable where RootGroup: FlagContainer flagPole: self, copyingFlagValuesFrom: source.flatMap(Snapshot.Source.source) ?? .pole, change: change, - displayName: displayName + displayName: displayName, ) } @@ -440,12 +440,12 @@ private final class DebugDescriptionVisitor: FlagVisitor { var valueDescriptions = [String]() - func visitFlag( + func visitFlag( keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, - wigwag: () -> FlagWigwag - ) where Value: FlagValue { + wigwag: () -> FlagWigwag, + ) { guard let value = value() else { valueDescriptions.append("\(keyPath.key)=nil") return diff --git a/Sources/Vexil/Snapshots/MutableFlagContainer.swift b/Sources/Vexil/Snapshots/MutableFlagContainer.swift index 21e4243..2eac7f5 100644 --- a/Sources/Vexil/Snapshots/MutableFlagContainer.swift +++ b/Sources/Vexil/Snapshots/MutableFlagContainer.swift @@ -15,7 +15,7 @@ import Foundation /// A `MutableFlagGroup` is a wrapper type that provides a "setter" for each contained `Flag`. @dynamicMemberLookup -public class MutableFlagContainer where Container: FlagContainer { +public class MutableFlagContainer { // MARK: - Properties diff --git a/Sources/Vexil/Snapshots/Snapshot+FlagValueSource.swift b/Sources/Vexil/Snapshots/Snapshot+FlagValueSource.swift index ea227d5..6bf7843 100644 --- a/Sources/Vexil/Snapshots/Snapshot+FlagValueSource.swift +++ b/Sources/Vexil/Snapshots/Snapshot+FlagValueSource.swift @@ -17,7 +17,7 @@ extension Snapshot: FlagValueSource { displayName ?? "Snapshot \(id)" } - public func flagValue(key: String) -> Value? where Value: FlagValue { + public func flagValue(key: String) -> Value? { values.withLock { $0[key] as? Value } diff --git a/Sources/Vexil/Snapshots/Snapshot+Lookup.swift b/Sources/Vexil/Snapshots/Snapshot+Lookup.swift index d3204d9..9d3cd0d 100644 --- a/Sources/Vexil/Snapshots/Snapshot+Lookup.swift +++ b/Sources/Vexil/Snapshots/Snapshot+Lookup.swift @@ -17,7 +17,7 @@ extension Snapshot: FlagLookup { - public func value(for keyPath: FlagKeyPath) -> Value? where Value: FlagValue { + public func value(for keyPath: FlagKeyPath) -> Value? { values.withLock { $0[keyPath.key] as? Value } diff --git a/Sources/Vexil/Snapshots/Snapshot.swift b/Sources/Vexil/Snapshots/Snapshot.swift index 44fa5e2..04eedb6 100644 --- a/Sources/Vexil/Snapshots/Snapshot.swift +++ b/Sources/Vexil/Snapshots/Snapshot.swift @@ -63,7 +63,7 @@ import Foundation /// ``` /// @dynamicMemberLookup -public final class Snapshot: Sendable where RootGroup: FlagContainer { +public final class Snapshot: Sendable { // MARK: - Properties @@ -92,7 +92,7 @@ public final class Snapshot: Sendable where RootGroup: FlagContainer flagPole: FlagPole, copyingFlagValuesFrom source: Source?, keys: Set? = nil, - displayName: String? = nil + displayName: String? = nil, ) { self.rootKeyPath = flagPole.rootKeyPath self.values = .init(initialState: [:]) diff --git a/Sources/Vexil/Snapshots/SnapshotBuilder.swift b/Sources/Vexil/Snapshots/SnapshotBuilder.swift index 7563e4e..26c9631 100644 --- a/Sources/Vexil/Snapshots/SnapshotBuilder.swift +++ b/Sources/Vexil/Snapshots/SnapshotBuilder.swift @@ -57,7 +57,7 @@ extension Snapshot { extension Snapshot.Builder: FlagLookup { /// Provides lookup capabilities to the flag hierarchy for our visit. - func value(for keyPath: FlagKeyPath) -> Value? where Value: FlagValue { + func value(for keyPath: FlagKeyPath) -> Value? { state.withLock { state in if let flagPole { flagPole.value(for: keyPath) @@ -71,8 +71,8 @@ extension Snapshot.Builder: FlagLookup { } } - // Not used while walking the flag hierarchy - func value(for keyPath: FlagKeyPath, in source: any FlagValueSource) -> Value? where Value: FlagValue { + /// Not used while walking the flag hierarchy + func value(for keyPath: FlagKeyPath, in source: any FlagValueSource) -> Value? { nil } @@ -87,12 +87,12 @@ extension Snapshot.Builder: FlagLookup { extension Snapshot.Builder: FlagVisitor { - func visitFlag( + func visitFlag( keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, - wigwag: () -> FlagWigwag - ) where Value: FlagValue { + wigwag: () -> FlagWigwag, + ) { let key = keyPath.key guard keys == nil || keys?.contains(key) == true, let value = value() else { return diff --git a/Sources/Vexil/Sources/FlagValueDictionary+FlagValueSource.swift b/Sources/Vexil/Sources/FlagValueDictionary+FlagValueSource.swift index 9afdd29..f47722e 100644 --- a/Sources/Vexil/Sources/FlagValueDictionary+FlagValueSource.swift +++ b/Sources/Vexil/Sources/FlagValueDictionary+FlagValueSource.swift @@ -17,7 +17,7 @@ import Combine extension FlagValueDictionary: FlagValueSource { - public func flagValue(key: String) -> Value? where Value: FlagValue { + public func flagValue(key: String) -> Value? { storage.withLock { storage in guard let value = storage[key] else { return nil diff --git a/Sources/Vexil/Sources/FlagValueSource.swift b/Sources/Vexil/Sources/FlagValueSource.swift index 7c0f077..755d26e 100644 --- a/Sources/Vexil/Sources/FlagValueSource.swift +++ b/Sources/Vexil/Sources/FlagValueSource.swift @@ -33,7 +33,7 @@ public protocol FlagValueSource: AnyObject & Sendable { var flagValueSourceName: String { get } /// Provide a way to fetch values. The ``BoxedFlagValue`` type is there to help with boxing and unboxing of flag values. - func flagValue(key: String) -> Value? where Value: FlagValue + func flagValue(key: String) -> Value? /// And to save values โ€“ if your source does not support saving just do nothing. The ``BoxedFlagValue`` type is there to /// help with boxing and unboxing of flag values. diff --git a/Sources/Vexil/Sources/FlagValueSourceCoordinator.swift b/Sources/Vexil/Sources/FlagValueSourceCoordinator.swift index 73425b3..46ddf62 100644 --- a/Sources/Vexil/Sources/FlagValueSourceCoordinator.swift +++ b/Sources/Vexil/Sources/FlagValueSourceCoordinator.swift @@ -17,11 +17,11 @@ /// - Note: If your flag value source is `Sendable` you should conform directly /// to ``FlagValueSource`` and skip this coordinator. /// -public final class FlagValueSourceCoordinator: Sendable where Source: NonSendableFlagValueSource { +public final class FlagValueSourceCoordinator: Sendable { // MARK: - Properties - // Private but for @testable + /// Private but for @testable let source: Lock @@ -60,7 +60,7 @@ extension FlagValueSourceCoordinator: FlagValueSource { } } - public func flagValue(key: String) -> Value? where Value: FlagValue { + public func flagValue(key: String) -> Value? { source.withLockUnchecked { $0.flagValue(key: key) } diff --git a/Sources/Vexil/Sources/NSUbiquitousKeyValueStore+FlagValueSource.swift b/Sources/Vexil/Sources/NSUbiquitousKeyValueStore+FlagValueSource.swift index 4958848..a871231 100644 --- a/Sources/Vexil/Sources/NSUbiquitousKeyValueStore+FlagValueSource.swift +++ b/Sources/Vexil/Sources/NSUbiquitousKeyValueStore+FlagValueSource.swift @@ -31,7 +31,7 @@ extension NSUbiquitousKeyValueStore: NonSendableFlagValueSource { } /// Fetch values for the specified key - public func flagValue(key: String) -> Value? where Value: FlagValue { + public func flagValue(key: String) -> Value? { guard let object = object(forKey: key), @@ -62,9 +62,9 @@ extension NSUbiquitousKeyValueStore: NonSendableFlagValueSource { public typealias ChangeStream = AsyncThrowingMapSequence< AsyncChain2Sequence< AsyncFilterSequence, - AsyncFilterSequence + AsyncFilterSequence, >, - FlagChange + FlagChange, > public func flagValueChanges(keyPathMapper: @Sendable @escaping (String) -> FlagKeyPath) -> ChangeStream { @@ -75,7 +75,7 @@ extension NSUbiquitousKeyValueStore: NonSendableFlagValueSource { .filter { $0.object.isIdentical(to: this) }, NotificationCenter.default .notifications(named: Self.didChangeInternallyNotification, object: nil) - .filter { $0.object.isIdentical(to: this) } + .filter { $0.object.isIdentical(to: this) }, ) .map { _ in FlagChange.all diff --git a/Sources/Vexil/Sources/NonSendableFlagValueSource.swift b/Sources/Vexil/Sources/NonSendableFlagValueSource.swift index 8b69ecf..1496a7d 100644 --- a/Sources/Vexil/Sources/NonSendableFlagValueSource.swift +++ b/Sources/Vexil/Sources/NonSendableFlagValueSource.swift @@ -45,7 +45,7 @@ public protocol NonSendableFlagValueSource { var flagValueSourceName: String { get } /// Provide a way to fetch values. The ``BoxedFlagValue`` type is there to help with boxing and unboxing of flag values. - func flagValue(key: String) -> Value? where Value: FlagValue + func flagValue(key: String) -> Value? /// And to save values โ€“ if your source does not support saving just do nothing. The ``BoxedFlagValue`` type is there to /// help with boxing and unboxing of flag values. diff --git a/Sources/Vexil/Sources/UserDefaults+FlagValueSource.swift b/Sources/Vexil/Sources/UserDefaults+FlagValueSource.swift index b1db981..3e8efa7 100644 --- a/Sources/Vexil/Sources/UserDefaults+FlagValueSource.swift +++ b/Sources/Vexil/Sources/UserDefaults+FlagValueSource.swift @@ -38,7 +38,7 @@ extension UserDefaults: NonSendableFlagValueSource { } /// Fetch values for the specified key - public func flagValue(key: String) -> Value? where Value: FlagValue { + public func flagValue(key: String) -> Value? { guard let object = object(forKey: key), @@ -84,9 +84,9 @@ extension UserDefaults: NonSendableFlagValueSource { public typealias ChangeStream = AsyncMapSequence< AsyncChain2Sequence< AsyncFilterSequence, - NotificationCenter.Notifications + NotificationCenter.Notifications, >, - FlagChange + FlagChange, > public func flagValueChanges(keyPathMapper: @Sendable @escaping (String) -> FlagKeyPath) -> ChangeStream { @@ -97,7 +97,7 @@ extension UserDefaults: NonSendableFlagValueSource { .filter { $0.object.isIdentical(to: this) }, // We use the raw value here because the class property is painfully @MainActor - NotificationCenter.default.notifications(named: .init("NSApplicationDidBecomeActiveNotification")) + NotificationCenter.default.notifications(named: .init("NSApplicationDidBecomeActiveNotification")), ) .map { _ in FlagChange.all @@ -109,9 +109,9 @@ extension UserDefaults: NonSendableFlagValueSource { public typealias ChangeStream = AsyncMapSequence< AsyncChain2Sequence< AsyncFilterSequence, - NotificationCenter.Notifications + NotificationCenter.Notifications, >, - FlagChange + FlagChange, > public func flagValueChanges(keyPathMapper: @escaping (String) -> FlagKeyPath) -> ChangeStream { @@ -122,7 +122,7 @@ extension UserDefaults: NonSendableFlagValueSource { .filter { $0.object.isIdentical(to: this) }, // We use the raw value here because the class property is painfully @MainActor - NotificationCenter.default.notifications(named: .init("UIApplicationDidBecomeActiveNotification")) + NotificationCenter.default.notifications(named: .init("UIApplicationDidBecomeActiveNotification")), ) .map { _ in FlagChange.all diff --git a/Sources/Vexil/StreamManager.swift b/Sources/Vexil/StreamManager.swift index dc866d7..eaa372d 100644 --- a/Sources/Vexil/StreamManager.swift +++ b/Sources/Vexil/StreamManager.swift @@ -86,7 +86,7 @@ extension FlagPole { didChange = true for insertion in difference.insertions { manager.tasks.append( - (insertion.element.flagValueSourceID, makeSubscribeTask(for: insertion.element)) + (insertion.element.flagValueSourceID, makeSubscribeTask(for: insertion.element)), ) } } diff --git a/Sources/Vexil/Utilities/AsyncCurrentValue.swift b/Sources/Vexil/Utilities/AsyncCurrentValue.swift index 9e906cb..5d5a506 100644 --- a/Sources/Vexil/Utilities/AsyncCurrentValue.swift +++ b/Sources/Vexil/Utilities/AsyncCurrentValue.swift @@ -13,7 +13,7 @@ import Foundation -struct AsyncCurrentValue: Sendable { +struct AsyncCurrentValue { struct State { // iterators start with generation = 0, so our initial value diff --git a/Sources/Vexil/Utilities/BoxedFlagValue+Codable.swift b/Sources/Vexil/Utilities/BoxedFlagValue+Codable.swift index 6630783..84ff9f6 100644 --- a/Sources/Vexil/Utilities/BoxedFlagValue+Codable.swift +++ b/Sources/Vexil/Utilities/BoxedFlagValue+Codable.swift @@ -128,7 +128,7 @@ extension BoxedFlagValue: Decodable { } else { throw DecodingError.dataCorrupted( - DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Unsupported type when decoding a BoxedFlagValue") + DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Unsupported type when decoding a BoxedFlagValue"), ) } diff --git a/Sources/Vexil/Utilities/Lock.swift b/Sources/Vexil/Utilities/Lock.swift index 2b95754..17f5399 100644 --- a/Sources/Vexil/Utilities/Lock.swift +++ b/Sources/Vexil/Utilities/Lock.swift @@ -17,14 +17,14 @@ import Foundation import os.lock #endif -struct Mutex: ~Copyable, Sendable { - - // Mutex isn't supposed to use an allocation, but the tools we would need to - // *avoid* an allocation are not available to us (we'd need to import `Builtin`, - // which is forbidden) - // - // Using an allocation here makes us a reference type, but since Mutex is not - // Copyable, it's pretty hard to *observe* that in practice. +struct Mutex: ~Copyable { + + /// Mutex isn't supposed to use an allocation, but the tools we would need to + /// *avoid* an allocation are not available to us (we'd need to import `Builtin`, + /// which is forbidden) + /// + /// Using an allocation here makes us a reference type, but since Mutex is not + /// Copyable, it's pretty hard to *observe* that in practice. private let platformLock: PlatformLock init(_ initialValue: consuming sending Value) { @@ -32,7 +32,7 @@ struct Mutex: ~Copyable, Sendable { } borrowing func withLock( - _ body: (inout sending Value) throws -> sending Result + _ body: (inout sending Value) throws -> sending Result, ) rethrows -> sending Result { try platformLock.withLock(body) } @@ -42,7 +42,7 @@ struct Mutex: ~Copyable, Sendable { /// This is a lock that will use the most appropriate platform lock under the hood. On Apple platforms /// it is effectively a wrapper around `OSAllocatedUnfairLock`. On non-Apple platforms it'll /// use `pthread_lock` and friends. -package struct Lock: Sendable { +package struct Lock { private let platformLock: PlatformLock @@ -100,7 +100,7 @@ struct PlatformLock { private static func withPlatformLock( _ lockPointer: UnsafeMutablePointer, _ valuePointer: UnsafeMutablePointer>, - _ body: (inout sending Value) throws(E) -> sending R + _ body: (inout sending Value) throws(E) -> sending R, ) throws(E) -> sending R { os_unfair_lock_lock(lockPointer) defer { @@ -135,7 +135,7 @@ struct PlatformLock { private static func withPlatformLock( _ lockPointer: UnsafeMutablePointer, _ valuePointer: UnsafeMutablePointer>, - _ body: (inout sending Value) throws(E) -> sending R + _ body: (inout sending Value) throws(E) -> sending R, ) throws(E) -> sending R { let error = pthread_mutex_lock(lockPointer) // pthread_mutex_lock can only fail with EDEADLK, which the os_unfair_lock @@ -154,12 +154,12 @@ struct PlatformLock { #endif - // ManagedBuffer is frankly insane, but it's a good way to ensure we have a single heap - // allocation containing both the lock and the state, and that we can hook into deinit - // to ensure that the PlatformLock and State both get correctly destroyed. - // - // It's horrible to use, but without it, we either have to accept a second allocation, - // or drop down to runtime magic. + /// ManagedBuffer is frankly insane, but it's a good way to ensure we have a single heap + /// allocation containing both the lock and the state, and that we can hook into deinit + /// to ensure that the PlatformLock and State both get correctly destroyed. + /// + /// It's horrible to use, but without it, we either have to accept a second allocation, + /// or drop down to runtime magic. private final class LockBuffer: ManagedBuffer> { deinit { @@ -192,7 +192,7 @@ struct PlatformLock { } func withLock( - _ body: (inout sending Value) throws(E) -> sending R + _ body: (inout sending Value) throws(E) -> sending R, ) throws(E) -> sending R { // `withUnsafeMutablePointers` doesn't handle `sending` result types, so we // transfer the result inside a `Disconnected` to appease the compiler. @@ -204,9 +204,9 @@ struct PlatformLock { } -// Safe to be `Sendable` because `state` is accessible -// only via the `withLock` method, which wraps the access -// in `withPlatformLock`. +/// Safe to be `Sendable` because `state` is accessible +/// only via the `withLock` method, which wraps the access +/// in `withPlatformLock`. extension PlatformLock: @unchecked Sendable {} // MARK: - Disconnected @@ -219,7 +219,7 @@ private struct Disconnected: ~Copyable, @unchecked Sendable { } #if compiler(>=6.2) - /// Swift 6.2 may miscompile `consume()` when inlined. + // Swift 6.2 may miscompile `consume()` when inlined. @inline(never) #endif consuming func consume() -> sending Value { @@ -243,7 +243,7 @@ private struct Disconnected: ~Copyable, @unchecked Sendable { #endif mutating func withValue( - _ work: (inout sending Value) throws(E) -> sending R + _ work: (inout sending Value) throws(E) -> sending R, ) throws(E) -> sending R { try work(&value) } diff --git a/Sources/Vexil/Value.swift b/Sources/Vexil/Value.swift index 09622ce..b18d0d9 100644 --- a/Sources/Vexil/Value.swift +++ b/Sources/Vexil/Value.swift @@ -497,7 +497,7 @@ public extension Encodable where Self: FlagValue, Self: Decodable { } } -// Because we can't encode/decode a JSON fragment in Swift 5.2 on Linux we wrap it in this. -struct Wrapper: Codable where Wrapped: Codable { +/// Because we can't encode/decode a JSON fragment in Swift 5.2 on Linux we wrap it in this. +struct Wrapper: Codable { var wrapped: Wrapped } diff --git a/Sources/Vexil/Visitor.swift b/Sources/Vexil/Visitor.swift index 0aa7236..6f7f6de 100644 --- a/Sources/Vexil/Visitor.swift +++ b/Sources/Vexil/Visitor.swift @@ -99,12 +99,12 @@ public protocol FlagVisitor { /// - wigwag: A closure you can use to obtain the flag's WigWag. You can obtain additional information /// about the flag or subscribe to real-time flag value changes via the WigWag. /// - func visitFlag( + func visitFlag( keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, - wigwag: () -> FlagWigwag - ) where Value: FlagValue + wigwag: () -> FlagWigwag, + ) } diff --git a/Sources/Vexil/Visitors/FlagDescriber.swift b/Sources/Vexil/Visitors/FlagDescriber.swift index 8fb0b1b..6848a83 100644 --- a/Sources/Vexil/Visitors/FlagDescriber.swift +++ b/Sources/Vexil/Visitors/FlagDescriber.swift @@ -15,12 +15,12 @@ final class FlagDescriber: FlagVisitor { var descriptions = [String]() - func visitFlag( + func visitFlag( keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, - wigwag: () -> FlagWigwag - ) where Value: FlagValue { + wigwag: () -> FlagWigwag, + ) { let value = value() let description = (value as? CustomDebugStringConvertible)?.debugDescription ?? (value as? CustomStringConvertible)?.description diff --git a/Sources/Vexil/Visitors/FlagRemover.swift b/Sources/Vexil/Visitors/FlagRemover.swift index c402939..0c7610d 100644 --- a/Sources/Vexil/Visitors/FlagRemover.swift +++ b/Sources/Vexil/Visitors/FlagRemover.swift @@ -20,12 +20,12 @@ final class FlagRemover: FlagVisitor { self.source = source } - func visitFlag( + func visitFlag( keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, - wigwag: () -> FlagWigwag - ) where Value: FlagValue { + wigwag: () -> FlagWigwag, + ) { guard caughtError == nil else { return } diff --git a/Sources/Vexil/Visitors/FlagSetter.swift b/Sources/Vexil/Visitors/FlagSetter.swift index da8383b..af635a5 100644 --- a/Sources/Vexil/Visitors/FlagSetter.swift +++ b/Sources/Vexil/Visitors/FlagSetter.swift @@ -22,12 +22,12 @@ final class FlagSetter: FlagVisitor { self.keys = keys } - func visitFlag( + func visitFlag( keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, - wigwag: () -> FlagWigwag - ) where Value: FlagValue { + wigwag: () -> FlagWigwag, + ) { let key = keyPath.key guard keys.contains(key), caughtError == nil, let value = value() else { return diff --git a/Sources/VexilMacros/FlagContainerMacro.swift b/Sources/VexilMacros/FlagContainerMacro.swift index 39aad13..57c482b 100644 --- a/Sources/VexilMacros/FlagContainerMacro.swift +++ b/Sources/VexilMacros/FlagContainerMacro.swift @@ -23,7 +23,7 @@ extension FlagContainerMacro: MemberMacro { public static func expansion( of node: AttributeSyntax, providingMembersOf declaration: some DeclGroupSyntax, - in context: some MacroExpansionContext + in context: some MacroExpansionContext, ) throws -> [DeclSyntax] { // If the declaration doesn't have any scopes attached we might be inheriting scopes from a public extension var scopes = declaration.modifiers.scopeSyntax @@ -49,7 +49,7 @@ extension FlagContainerMacro: MemberMacro { ExprSyntax("self._flagKeyPath = _flagKeyPath") ExprSyntax("self._flagLookup = _flagLookup") } - .with(\.modifiers, scopes) + .with(\.modifiers, scopes), ), ] @@ -64,7 +64,7 @@ extension FlagContainerMacro: ExtensionMacro { attachedTo declaration: some DeclGroupSyntax, providingExtensionsOf type: some TypeSyntaxProtocol, conformingTo protocols: [TypeSyntax], - in context: some MacroExpansionContext + in context: some MacroExpansionContext, ) throws -> [ExtensionDeclSyntax] { var shouldGenerateConformance = protocols.isEmpty && ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil ? node.shouldGenerateConformance @@ -93,7 +93,7 @@ extension FlagContainerMacro: ExtensionMacro { var decls = try [ ExtensionDeclSyntax( extendedType: type, - inheritanceClause: .init(inheritedTypes: [ .init(type: TypeSyntax(stringLiteral: "FlagContainer")) ]) + inheritanceClause: .init(inheritedTypes: [ .init(type: TypeSyntax(stringLiteral: "FlagContainer")) ]), ) { // Flag Hierarchy Walking @@ -126,13 +126,13 @@ extension FlagContainerMacro: ExtensionMacro { components: [ .init( period: .periodToken(), - component: .property(.init(declName: .init(baseName: .identifier(flag.propertyName)))) + component: .property(.init(declName: .init(baseName: .identifier(flag.propertyName)))), ), - ] + ], ), value: flag.key, trailingComma: .commaToken(), - trailingTrivia: .newline + trailingTrivia: .newline, ) } } @@ -151,7 +151,7 @@ extension FlagContainerMacro: ExtensionMacro { try decls += [ ExtensionDeclSyntax( extendedType: type, - inheritanceClause: .init(inheritedTypes: [ .init(type: TypeSyntax(stringLiteral: "Equatable")) ]) + inheritanceClause: .init(inheritedTypes: [ .init(type: TypeSyntax(stringLiteral: "Equatable")) ]), ) { var variables = declaration.memberBlock.storedVariables try FunctionDeclSyntax("func ==(lhs: \(type), rhs: \(type)) -> Bool") { @@ -183,7 +183,7 @@ extension FlagContainerMacro: ExtensionMacro { decls += [ ExtensionDeclSyntax( extendedType: type, - inheritanceClause: .init(inheritedTypes: [ .init(type: TypeSyntax(stringLiteral: "Sendable")) ]) + inheritanceClause: .init(inheritedTypes: [ .init(type: TypeSyntax(stringLiteral: "Sendable")) ]), ) { // Member block intentionally left blank }, diff --git a/Sources/VexilMacros/FlagGroupMacro.swift b/Sources/VexilMacros/FlagGroupMacro.swift index 60897e6..3d86caf 100644 --- a/Sources/VexilMacros/FlagGroupMacro.swift +++ b/Sources/VexilMacros/FlagGroupMacro.swift @@ -114,7 +114,7 @@ extension FlagGroupMacro: AccessorMacro { public static func expansion( of node: AttributeSyntax, providingAccessorsOf declaration: some DeclSyntaxProtocol, - in context: some MacroExpansionContext + in context: some MacroExpansionContext, ) throws -> [AccessorDeclSyntax] { let group = try FlagGroupMacro(node: node, declaration: declaration, context: context) return [ @@ -132,7 +132,7 @@ extension FlagGroupMacro: PeerMacro { public static func expansion( of node: AttributeSyntax, providingPeersOf declaration: some DeclSyntaxProtocol, - in context: some MacroExpansionContext + in context: some MacroExpansionContext, ) throws -> [DeclSyntax] { do { let macro = try FlagGroupMacro(node: node, declaration: declaration, context: context) diff --git a/Sources/VexilMacros/FlagMacro.swift b/Sources/VexilMacros/FlagMacro.swift index 505d5c5..b27c267 100644 --- a/Sources/VexilMacros/FlagMacro.swift +++ b/Sources/VexilMacros/FlagMacro.swift @@ -149,7 +149,7 @@ extension FlagMacro: AccessorMacro { public static func expansion( of node: AttributeSyntax, providingAccessorsOf declaration: some DeclSyntaxProtocol, - in context: some MacroExpansionContext + in context: some MacroExpansionContext, ) throws -> [AccessorDeclSyntax] { let macro = try FlagMacro(node: node, declaration: declaration, context: context) return [ @@ -171,7 +171,7 @@ extension FlagMacro: PeerMacro { public static func expansion( of node: AttributeSyntax, providingPeersOf declaration: some DeclSyntaxProtocol, - in context: some MacroExpansionContext + in context: some MacroExpansionContext, ) throws -> [DeclSyntax] { do { let macro = try FlagMacro(node: node, declaration: declaration, context: context) diff --git a/Sources/Vexillographer/FlagControl/FlagControl.swift b/Sources/Vexillographer/FlagControl/FlagControl.swift index 1a8b0f0..1342f94 100644 --- a/Sources/Vexillographer/FlagControl/FlagControl.swift +++ b/Sources/Vexillographer/FlagControl/FlagControl.swift @@ -14,7 +14,7 @@ import SwiftUI import Vexil -// Public way to create single custom controls +/// Public way to create single custom controls public struct FlagControl: View { private var wigwag: FlagWigwag @@ -30,7 +30,7 @@ public struct FlagControl: View { public init( _ wigwag: FlagWigwag, - @ViewBuilder content: @escaping (FlagControlConfiguration) -> Content + @ViewBuilder content: @escaping (FlagControlConfiguration) -> Content, ) { self.wigwag = wigwag self.content = content @@ -47,8 +47,8 @@ public struct FlagControl: View { hasValue: editableValue != nil, defaultValue: wigwag.defaultValue, value: Binding(get: getValue, set: setValue), - resetValue: resetValue - ) + resetValue: resetValue, + ), ) .task { for await _ in wigwag.changes { diff --git a/Sources/Vexillographer/FlagControl/FlagControlConfiguration.swift b/Sources/Vexillographer/FlagControl/FlagControlConfiguration.swift index 4973bbd..b2d1b9d 100644 --- a/Sources/Vexillographer/FlagControl/FlagControlConfiguration.swift +++ b/Sources/Vexillographer/FlagControl/FlagControlConfiguration.swift @@ -14,8 +14,8 @@ import SwiftUI import Vexil -// Binding to a flag value could be a property wrapper but maybe best -// not to blur the lines +/// Binding to a flag value could be a property wrapper but maybe best +/// not to blur the lines public struct FlagControlConfiguration { private let seed: Int @@ -38,7 +38,7 @@ public struct FlagControlConfiguration { hasValue: Bool, defaultValue: Value, value: Binding, - resetValue: @escaping () -> Void + resetValue: @escaping () -> Void, ) { self.seed = seed self.name = name diff --git a/Sources/Vexillographer/FlagControl/FlagDetail.swift b/Sources/Vexillographer/FlagControl/FlagDetail.swift index 148f5d9..5babe6e 100644 --- a/Sources/Vexillographer/FlagControl/FlagDetail.swift +++ b/Sources/Vexillographer/FlagControl/FlagDetail.swift @@ -14,9 +14,9 @@ import SwiftUI import Vexil -// Sheet with flag info -// - can reset value -// - can see source hierarchy +/// Sheet with flag info +/// - can reset value +/// - can see source hierarchy struct FlagDetailView: View { var configuration: FlagControlConfiguration diff --git a/Sources/Vexillographer/FlagControl/FlagPicker+Bool.swift b/Sources/Vexillographer/FlagControl/FlagPicker+Bool.swift index 0063a4e..cc9b1b5 100644 --- a/Sources/Vexillographer/FlagControl/FlagPicker+Bool.swift +++ b/Sources/Vexillographer/FlagControl/FlagPicker+Bool.swift @@ -14,7 +14,7 @@ import SwiftUI import Vexil -// Convenience for optional bool +/// Convenience for optional bool public extension FlagPicker where Value.BoxedValueType == Bool?, SelectionValue == Bool?, Content == DefaultFlagPickerContent { init(configuration: FlagControlConfiguration) { self.init(configuration: configuration, selection: \.asOptionalBool) { diff --git a/Sources/Vexillographer/FlagControl/FlagPicker+CaseIterable.swift b/Sources/Vexillographer/FlagControl/FlagPicker+CaseIterable.swift index bbffa94..841f68f 100644 --- a/Sources/Vexillographer/FlagControl/FlagPicker+CaseIterable.swift +++ b/Sources/Vexillographer/FlagControl/FlagPicker+CaseIterable.swift @@ -14,7 +14,7 @@ import SwiftUI import Vexil -// Convenience for case iterable +/// Convenience for case iterable public extension FlagPicker where Value: CaseIterable, SelectionValue == Value, Content == DefaultFlagPickerContent { init(configuration: FlagControlConfiguration) { @@ -27,7 +27,7 @@ public extension FlagPicker where Value: CaseIterable, SelectionValue == Value, public extension FlagPicker { init( - configuration: FlagControlConfiguration + configuration: FlagControlConfiguration, ) where Value == Wrapped?, SelectionValue == Wrapped?, Content == DefaultFlagPickerContent { self.init(configuration: configuration, selection: \.wrapped) { DefaultFlagPickerContent([nil as Wrapped?] + Array(Wrapped.allCases)) diff --git a/Sources/Vexillographer/FlagControl/FlagPicker.swift b/Sources/Vexillographer/FlagControl/FlagPicker.swift index d908f34..6c83ce2 100644 --- a/Sources/Vexillographer/FlagControl/FlagPicker.swift +++ b/Sources/Vexillographer/FlagControl/FlagPicker.swift @@ -14,7 +14,7 @@ import SwiftUI import Vexil -// A picker +/// A picker public struct FlagPicker: View { private var name: String @@ -26,7 +26,7 @@ public struct FlagPicker, selection: WritableKeyPath, - @ViewBuilder content: () -> Content + @ViewBuilder content: () -> Content, ) { self.name = configuration.name _value = configuration.$value diff --git a/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift b/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift index d5c0193..80529bd 100644 --- a/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift +++ b/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift @@ -14,14 +14,14 @@ import SwiftUI import Vexil -// TextField convenience for floating point +/// TextField convenience for floating point extension FlagTextField where Value.BoxedValueType: BinaryFloatingPoint { init(configuration: FlagControlConfiguration) { self = Self( configuration: configuration, formatted: \.asString, - editingFormat: { $0 } + editingFormat: { $0 }, ) #if os(iOS) || os(tvOS) .keyboardType(.decimalPad) @@ -59,7 +59,7 @@ extension FlagTextField { self = Self( configuration: configuration, formatted: \.asStringOrEmpty, - editingFormat: { $0 } + editingFormat: { $0 }, ) #if os(iOS) || os(tvOS) .keyboardType(.decimalPad) @@ -91,7 +91,7 @@ extension FlagControlConfiguration: OptionalFloatingPointFlagTextFieldRepresenta FlagTextField( configuration: self, formatted: \.asStringOrEmpty, - editingFormat: { $0 } + editingFormat: { $0 }, ) #if os(iOS) || os(tvOS) .keyboardType(.decimalPad) diff --git a/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift b/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift index 6d4d21d..befd298 100644 --- a/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift +++ b/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift @@ -14,14 +14,14 @@ import SwiftUI import Vexil -// TextField convenience for integer +/// TextField convenience for integer extension FlagTextField where Value.BoxedValueType: BinaryInteger { init(configuration: FlagControlConfiguration) { self = Self( configuration: configuration, formatted: \.asString, - editingFormat: { $0.filter(\.isNumber) } + editingFormat: { $0.filter(\.isNumber) }, ) #if os(iOS) || os(tvOS) .keyboardType(.numberPad) @@ -59,7 +59,7 @@ extension FlagTextField { self = Self( configuration: configuration, formatted: \.asStringOrEmpty, - editingFormat: { $0.filter(\.isNumber) } + editingFormat: { $0.filter(\.isNumber) }, ) #if os(iOS) || os(tvOS) .keyboardType(.numberPad) @@ -90,7 +90,7 @@ extension FlagControlConfiguration: OptionalIntegerFlagTextFieldRepresentable wh FlagTextField( configuration: self, formatted: \.asStringOrEmpty, - editingFormat: { $0.filter(\.isNumber) } + editingFormat: { $0.filter(\.isNumber) }, ) #if os(iOS) || os(tvOS) .keyboardType(.numberPad) diff --git a/Sources/Vexillographer/FlagControl/FlagTextField+String.swift b/Sources/Vexillographer/FlagControl/FlagTextField+String.swift index cd91f6d..17510b6 100644 --- a/Sources/Vexillographer/FlagControl/FlagTextField+String.swift +++ b/Sources/Vexillographer/FlagControl/FlagTextField+String.swift @@ -14,7 +14,7 @@ import SwiftUI import Vexil -// TextField convenience for string +/// TextField convenience for string extension FlagTextField where Value.BoxedValueType == String { init(configuration: FlagControlConfiguration) { diff --git a/Sources/Vexillographer/FlagControl/FlagTextField.swift b/Sources/Vexillographer/FlagControl/FlagTextField.swift index 2187c0a..4f95764 100644 --- a/Sources/Vexillographer/FlagControl/FlagTextField.swift +++ b/Sources/Vexillographer/FlagControl/FlagTextField.swift @@ -14,9 +14,9 @@ import SwiftUI import Vexil -// A text field -// - want to dismiss on scroll? -// - want to have confirm/cancel? +/// A text field +/// - want to dismiss on scroll? +/// - want to have confirm/cancel? struct FlagTextField: View { private var name: String @@ -41,7 +41,7 @@ struct FlagTextField: View { formatted: WritableKeyPath, placeholder: String = "", format: @escaping (String) -> String = { $0 }, - editingFormat: @escaping (String) -> String = { $0 } + editingFormat: @escaping (String) -> String = { $0 }, ) { self.name = configuration.name _value = configuration.$value @@ -85,11 +85,11 @@ struct FlagTextField: View { .focused($isFocused) } - // Can this be computed key path? + /// Can this be computed key path? var text: Binding { Binding( get: { cachedText ?? value[keyPath: formatted] }, - set: { cachedText = $0 } + set: { cachedText = $0 }, ) } diff --git a/Sources/Vexillographer/FlagControl/FlagToggle.swift b/Sources/Vexillographer/FlagControl/FlagToggle.swift index 91e3527..beebf0f 100644 --- a/Sources/Vexillographer/FlagControl/FlagToggle.swift +++ b/Sources/Vexillographer/FlagControl/FlagToggle.swift @@ -14,7 +14,7 @@ import SwiftUI import Vexil -// A toggle +/// A toggle public struct FlagToggle: View where Value.BoxedValueType == Bool { private var name: String diff --git a/Sources/Vexillographer/FlagControl/RowContent.swift b/Sources/Vexillographer/FlagControl/RowContent.swift index 438e2a4..a3bbd2f 100644 --- a/Sources/Vexillographer/FlagControl/RowContent.swift +++ b/Sources/Vexillographer/FlagControl/RowContent.swift @@ -13,7 +13,7 @@ import SwiftUI -// UI helper +/// UI helper struct RowContent: View { var label: String diff --git a/Sources/Vexillographer/FlagPole/FlagItem.swift b/Sources/Vexillographer/FlagPole/FlagItem.swift index 16cda23..cfc15cb 100644 --- a/Sources/Vexillographer/FlagPole/FlagItem.swift +++ b/Sources/Vexillographer/FlagPole/FlagItem.swift @@ -30,7 +30,9 @@ struct FlagItem: FlagPoleItem { flag.keyPath } - var name: String { flag.name } + var name: String { + flag.name + } func makeContent() -> any View { FlagItemContent(wigwag: flag) diff --git a/Sources/Vexillographer/FlagPole/FlagPoleItem.swift b/Sources/Vexillographer/FlagPole/FlagPoleItem.swift index 27e385b..f40408a 100644 --- a/Sources/Vexillographer/FlagPole/FlagPoleItem.swift +++ b/Sources/Vexillographer/FlagPole/FlagPoleItem.swift @@ -26,7 +26,9 @@ protocol FlagPoleItem { extension FlagPoleItem { @MainActor - var content: AnyView { AnyView(makeContent()) } + var content: AnyView { + AnyView(makeContent()) + } } extension FlagPoleItem { diff --git a/Sources/Vexillographer/FlagPole/FlagPoleVisitor.swift b/Sources/Vexillographer/FlagPole/FlagPoleVisitor.swift index bad8f09..94320bd 100644 --- a/Sources/Vexillographer/FlagPole/FlagPoleVisitor.swift +++ b/Sources/Vexillographer/FlagPole/FlagPoleVisitor.swift @@ -38,7 +38,7 @@ class FlagPoleVisitor: FlagVisitor { keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, - wigwag: () -> FlagWigwag + wigwag: () -> FlagWigwag, ) { appendToGroupOrRoot(FlagItem(wigwag())) } diff --git a/Sources/Vexillographer/Utilities/OptionalProtocol.swift b/Sources/Vexillographer/Utilities/OptionalProtocol.swift index 695d6e4..ccfa149 100644 --- a/Sources/Vexillographer/Utilities/OptionalProtocol.swift +++ b/Sources/Vexillographer/Utilities/OptionalProtocol.swift @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -// Is this still needed +/// Is this still needed protocol OptionalProtocol { associatedtype Wrapped var wrapped: Wrapped? { get set } diff --git a/Sources/Vexillographer/View+FlagPole.swift b/Sources/Vexillographer/View+FlagPole.swift index eda2391..7c59a2e 100644 --- a/Sources/Vexillographer/View+FlagPole.swift +++ b/Sources/Vexillographer/View+FlagPole.swift @@ -18,7 +18,7 @@ public extension View { func flagPole( _ flagPole: FlagPole, - editableSource: (any FlagValueSource)? = nil + editableSource: (any FlagValueSource)? = nil, ) -> some View { modifier(FlagPoleModifier(flagPole: flagPole, editableSource: editableSource)) } diff --git a/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift b/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift index 5471b1a..005feb9 100644 --- a/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift +++ b/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift @@ -20,7 +20,7 @@ import XCTest final class EquatableFlagContainerMacroTests: XCTestCase { - func testGeneratesWhenEmpty() throws { + func testGeneratesWhenEmpty() { assertMacroExpansion( """ @FlagContainer @@ -62,11 +62,11 @@ final class EquatableFlagContainerMacroTests: XCTestCase { """, macros: [ "FlagContainer": FlagContainerMacro.self, - ] + ], ) } - func testExpandsInternal() throws { + func testExpandsInternal() { assertMacroExpansion( """ @FlagContainer @@ -166,11 +166,11 @@ final class EquatableFlagContainerMacroTests: XCTestCase { macros: [ "FlagContainer": FlagContainerMacro.self, "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsPublic() throws { + func testExpandsPublic() { assertMacroExpansion( """ @FlagContainer @@ -244,11 +244,11 @@ final class EquatableFlagContainerMacroTests: XCTestCase { macros: [ "FlagContainer": FlagContainerMacro.self, "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsPublicExtension() throws { + func testExpandsPublicExtension() { assertMacroExpansion( """ public extension SomeContainer { @@ -325,11 +325,11 @@ final class EquatableFlagContainerMacroTests: XCTestCase { macros: [ "FlagContainer": FlagContainerMacro.self, "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsButAlreadyConforming() throws { + func testExpandsButAlreadyConforming() { assertMacroExpansion( """ @FlagContainer @@ -402,11 +402,11 @@ final class EquatableFlagContainerMacroTests: XCTestCase { macros: [ "FlagContainer": FlagContainerMacro.self, "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsVisitorAndEquatableImplementation() throws { + func testExpandsVisitorAndEquatableImplementation() { assertMacroExpansion( """ @FlagContainer @@ -499,11 +499,11 @@ final class EquatableFlagContainerMacroTests: XCTestCase { """, macros: [ "FlagContainer": FlagContainerMacro.self, - ] + ], ) } - func testExpandsVisitorAndEquatablePublicImplementation() throws { + func testExpandsVisitorAndEquatablePublicImplementation() { assertMacroExpansion( """ @FlagContainer @@ -596,7 +596,7 @@ final class EquatableFlagContainerMacroTests: XCTestCase { """, macros: [ "FlagContainer": FlagContainerMacro.self, - ] + ], ) } diff --git a/Tests/VexilMacroTests/FlagContainerMacroTests.swift b/Tests/VexilMacroTests/FlagContainerMacroTests.swift index bea368f..6cbadb3 100644 --- a/Tests/VexilMacroTests/FlagContainerMacroTests.swift +++ b/Tests/VexilMacroTests/FlagContainerMacroTests.swift @@ -20,7 +20,7 @@ import XCTest final class FlagContainerMacroTests: XCTestCase { - func testExpandsDefault() throws { + func testExpandsDefault() { assertMacroExpansion( """ @FlagContainer @@ -62,11 +62,11 @@ final class FlagContainerMacroTests: XCTestCase { """, macros: [ "FlagContainer": FlagContainerMacro.self, - ] + ], ) } - func testExpandsPublic() throws { + func testExpandsPublic() { assertMacroExpansion( """ @FlagContainer @@ -108,11 +108,11 @@ final class FlagContainerMacroTests: XCTestCase { """, macros: [ "FlagContainer": FlagContainerMacro.self, - ] + ], ) } - func testExpandsButAlreadyConforming() throws { + func testExpandsButAlreadyConforming() { assertMacroExpansion( """ @FlagContainer @@ -154,13 +154,13 @@ final class FlagContainerMacroTests: XCTestCase { """, macros: [ "FlagContainer": FlagContainerMacro.self, - ] + ], ) } // MARK: - Swift 6 specific tests - func testExpandsVisitorImplementation() throws { + func testExpandsVisitorImplementation() { assertMacroExpansion( """ @FlagContainer @@ -253,7 +253,7 @@ final class FlagContainerMacroTests: XCTestCase { """, macros: [ "FlagContainer": FlagContainerMacro.self, - ] + ], ) } diff --git a/Tests/VexilMacroTests/FlagGroupMacroTests.swift b/Tests/VexilMacroTests/FlagGroupMacroTests.swift index 22c0ebd..5a94e10 100644 --- a/Tests/VexilMacroTests/FlagGroupMacroTests.swift +++ b/Tests/VexilMacroTests/FlagGroupMacroTests.swift @@ -20,7 +20,7 @@ import XCTest final class FlagGroupMacroTests: XCTestCase { - func testExpands() throws { + func testExpands() { assertMacroExpansion( """ struct TestFlags { @@ -50,11 +50,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testExpandsPublic() throws { + func testExpandsPublic() { assertMacroExpansion( """ struct TestFlags { @@ -84,14 +84,14 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } // MARK: - Flag Group Detail Tests - func testExpandsName() throws { + func testExpandsName() { assertMacroExpansion( """ struct TestFlags { @@ -121,11 +121,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testHidden() throws { + func testHidden() { assertMacroExpansion( """ struct TestFlags { @@ -155,11 +155,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testDisplayNavigation() throws { + func testDisplayNavigation() { assertMacroExpansion( """ struct TestFlags { @@ -189,11 +189,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testDisplaySection() throws { + func testDisplaySection() { assertMacroExpansion( """ struct TestFlags { @@ -223,13 +223,13 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } // MARK: - Key Strategy Detection Tests - func testDetectsKeyStrategyMinimal() throws { + func testDetectsKeyStrategyMinimal() { assertMacroExpansion( """ struct TestFlags { @@ -259,11 +259,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testDetectsKeyStrategyFull() throws { + func testDetectsKeyStrategyFull() { assertMacroExpansion( """ struct TestFlags { @@ -293,14 +293,14 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } // MARK: - Key Strategy Tests - func testKeyStrategyDefault() throws { + func testKeyStrategyDefault() { assertMacroExpansion( """ struct TestFlags { @@ -330,11 +330,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testKeyStrategyKebabcase() throws { + func testKeyStrategyKebabcase() { assertMacroExpansion( """ struct TestFlags { @@ -364,11 +364,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testKeyStrategySnakecase() throws { + func testKeyStrategySnakecase() { assertMacroExpansion( """ struct TestFlags { @@ -398,11 +398,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testKeyStrategySkip() throws { + func testKeyStrategySkip() { assertMacroExpansion( """ struct TestFlags { @@ -432,11 +432,11 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } - func testKeyStrategyCustomKey() throws { + func testKeyStrategyCustomKey() { assertMacroExpansion( """ struct TestFlags { @@ -466,7 +466,7 @@ final class FlagGroupMacroTests: XCTestCase { """, macros: [ "FlagGroup": FlagGroupMacro.self, - ] + ], ) } diff --git a/Tests/VexilMacroTests/FlagMacroTests.swift b/Tests/VexilMacroTests/FlagMacroTests.swift index 54118bd..0a2c7d4 100644 --- a/Tests/VexilMacroTests/FlagMacroTests.swift +++ b/Tests/VexilMacroTests/FlagMacroTests.swift @@ -22,7 +22,7 @@ final class FlagMacroTests: XCTestCase { // MARK: - Type Tests - func testExpandsOptional() throws { + func testExpandsOptional() { assertMacroExpansion( """ struct TestFlags { @@ -53,11 +53,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsPublic() throws { + func testExpandsPublic() { assertMacroExpansion( """ struct TestFlags { @@ -88,14 +88,14 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } // MARK: - Property Initialisation Tests - func testExpandsBoolPropertyInitialization() throws { + func testExpandsBoolPropertyInitialization() { assertMacroExpansion( """ struct TestFlags { @@ -126,11 +126,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsDoublePropertyInitialization() throws { + func testExpandsDoublePropertyInitialization() { assertMacroExpansion( """ struct TestFlags { @@ -161,11 +161,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsStringPropertyInitialization() throws { + func testExpandsStringPropertyInitialization() { assertMacroExpansion( """ struct TestFlags { @@ -196,11 +196,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsEnumPropertyInitialization() throws { + func testExpandsEnumPropertyInitialization() { assertMacroExpansion( """ struct TestFlags { @@ -231,11 +231,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsTypePropertyInitialization() throws { + func testExpandsTypePropertyInitialization() { assertMacroExpansion( """ struct TestFlags { @@ -266,11 +266,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testExpandsForceUnwrapPropertyInitialization() throws { + func testExpandsForceUnwrapPropertyInitialization() { assertMacroExpansion( """ struct TestFlags { @@ -301,13 +301,13 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } // MARK: - Argument Tests - func testExpandsName() throws { + func testExpandsName() { assertMacroExpansion( """ struct TestFlags { @@ -338,11 +338,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testHiddenDescription() throws { + func testHiddenDescription() { assertMacroExpansion( """ struct TestFlags { @@ -373,11 +373,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testHiddenDescriptionExplicit() throws { + func testHiddenDescriptionExplicit() { assertMacroExpansion( """ struct TestFlags { @@ -408,14 +408,14 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } // MARK: - Key Strategy Detection Tests - func testDetectsKeyStrategyMinimal() throws { + func testDetectsKeyStrategyMinimal() { assertMacroExpansion( """ struct TestFlags { @@ -446,11 +446,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testDetectsKeyStrategyFull() throws { + func testDetectsKeyStrategyFull() { assertMacroExpansion( """ struct TestFlags { @@ -481,14 +481,14 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } // MARK: - Key Strategy Tests - func testKeyStrategyDefault() throws { + func testKeyStrategyDefault() { assertMacroExpansion( """ struct TestFlags { @@ -519,11 +519,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testKeyStrategyKebabcase() throws { + func testKeyStrategyKebabcase() { assertMacroExpansion( """ struct TestFlags { @@ -554,11 +554,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testKeyStrategySnakecase() throws { + func testKeyStrategySnakecase() { assertMacroExpansion( """ struct TestFlags { @@ -589,11 +589,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testKeyStrategyCustomKey() throws { + func testKeyStrategyCustomKey() { assertMacroExpansion( """ struct TestFlags { @@ -624,11 +624,11 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } - func testKeyStrategyCustomKeyPath() throws { + func testKeyStrategyCustomKeyPath() { assertMacroExpansion( """ struct TestFlags { @@ -659,7 +659,7 @@ final class FlagMacroTests: XCTestCase { """, macros: [ "Flag": FlagMacro.self, - ] + ], ) } diff --git a/Tests/VexilTests/BoxedFlagValueDecodingTests.swift b/Tests/VexilTests/BoxedFlagValueDecodingTests.swift index c3e33f2..2c73219 100644 --- a/Tests/VexilTests/BoxedFlagValueDecodingTests.swift +++ b/Tests/VexilTests/BoxedFlagValueDecodingTests.swift @@ -15,7 +15,7 @@ import Foundation import Testing @testable import Vexil -@Suite("BoxedFlagValue decoding", .tags(.boxing, .codable)) +@Suite(.tags(.boxing, .codable)) struct BoxedFlagValueDecodingTests { private let decoder: JSONDecoder = { @@ -28,15 +28,15 @@ struct BoxedFlagValueDecodingTests { // MARK: - Boolean Flag Values - @Test("Decodes boolean true") - func booleanTrueFlagValue() throws { + @Test + func `Decodes boolean true`() throws { let input = #"{"b":true}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .bool(true)) } - @Test("Decodes boolean false") - func booleanFalseFlagValue() throws { + @Test + func `Decodes boolean false`() throws { let input = #"{"b":false}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .bool(false)) @@ -45,8 +45,8 @@ struct BoxedFlagValueDecodingTests { // MARK: - String Flag Values - @Test("Decodes string") - func stringFlagValue() throws { + @Test + func `Decodes string`() throws { let input = #"{"s":"Test String"}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .string("Test String")) @@ -55,8 +55,8 @@ struct BoxedFlagValueDecodingTests { // MARK: - Data Values - @Test("Decodes data") - func dataFlagValue() throws { + @Test + func `Decodes data`() throws { let input = #"{"d":"VGVzdCBzdHJpbmc="}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .data(Data("Test string".utf8))) @@ -65,22 +65,22 @@ struct BoxedFlagValueDecodingTests { // MARK: - Number Flag Values - @Test("Decodes integer") - func intFlagValue() throws { + @Test + func `Decodes integer`() throws { let input = #"{"i":1234}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .integer(1234)) } - @Test("Decodes double") - func doubleFlagValue() throws { + @Test + func `Decodes double`() throws { let input = #"{"r":123.456}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .double(123.456)) } - @Test("Decodes float") - func floatFlagValue() throws { + @Test + func `Decodes float`() throws { let input = #"{"f":123.456}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .float(123.456)) @@ -89,8 +89,8 @@ struct BoxedFlagValueDecodingTests { // MARK: - Wrapping Types - @Test("Decodes nil") - func optionalNoFlagValue() throws { + @Test + func `Decodes nil`() throws { let input = #"{"n":null}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .none) @@ -99,15 +99,15 @@ struct BoxedFlagValueDecodingTests { // MARK: - Collection Types - @Test("Decodes array") - func arrayFlagValue() throws { + @Test + func `Decodes array`() throws { let input = #"{"a":[{"i":123},{"i":456},{"i":789}]}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .array([ .integer(123), .integer(456), .integer(789) ])) } - @Test("Decodes dictionary") - func dictionaryFlagValue() throws { + @Test + func `Decodes dictionary`() throws { let input = #"{"o":{"one":{"i":123},"three":{"i":789},"two":{"i":456}}}"#.utf8 let decoded = try decoder.decode(BoxedFlagValue.self, from: Data(input)) #expect(decoded == .dictionary([ "one": .integer(123), "two": .integer(456), "three": .integer(789) ])) diff --git a/Tests/VexilTests/BoxedFlagValueEncodingTests.swift b/Tests/VexilTests/BoxedFlagValueEncodingTests.swift index 20f1229..0c37327 100644 --- a/Tests/VexilTests/BoxedFlagValueEncodingTests.swift +++ b/Tests/VexilTests/BoxedFlagValueEncodingTests.swift @@ -15,7 +15,7 @@ import Foundation import Testing @testable import Vexil -@Suite("BoxedFlagValue encoding", .tags(.boxing, .codable)) +@Suite(.tags(.boxing, .codable)) struct BoxedFlagValueEncodingTests { private let encoder: JSONEncoder = { @@ -29,16 +29,16 @@ struct BoxedFlagValueEncodingTests { // MARK: - Boolean Flag Values - @Test("Encodes boolean true") - func booleanTrueFlagValue() throws { + @Test + func `Encodes boolean true`() throws { let input = BoxedFlagValue.bool(true) let expected = #"{"b":true}"#.utf8 let encoded = try encoder.encode(input) #expect(encoded == Data(expected)) } - @Test("Encodes boolean false") - func booleanFalseFlagValue() throws { + @Test + func `Encodes boolean false`() throws { let input = BoxedFlagValue.bool(false) let expected = #"{"b":false}"#.utf8 let encoded = try encoder.encode(input) @@ -48,8 +48,8 @@ struct BoxedFlagValueEncodingTests { // MARK: - String Flag Values - @Test("Encodes string") - func stringFlagValue() throws { + @Test + func `Encodes string`() throws { let input = BoxedFlagValue.string("Test String") let expected = #"{"s":"Test String"}"#.utf8 let encoded = try encoder.encode(input) @@ -59,8 +59,8 @@ struct BoxedFlagValueEncodingTests { // MARK: - Data Values - @Test("Encodes data") - func dataFlagValue() throws { + @Test + func `Encodes data`() throws { let input = BoxedFlagValue.data(Data("Test string".utf8)) let expected = #"{"d":"VGVzdCBzdHJpbmc="}"#.utf8 let encoded = try encoder.encode(input) @@ -70,24 +70,24 @@ struct BoxedFlagValueEncodingTests { // MARK: - Number Flag Values - @Test("Encodes integer") - func intFlagValue() throws { + @Test + func `Encodes integer`() throws { let input = BoxedFlagValue.integer(1234) let expected = #"{"i":1234}"#.utf8 let encoded = try encoder.encode(input) #expect(encoded == Data(expected)) } - @Test("Encodes double") - func doubleFlagValue() throws { + @Test + func `Encodes double`() throws { let input = BoxedFlagValue.double(123.456) let expected = #"{"r":123.456}"#.utf8 let encoded = try encoder.encode(input) #expect(encoded == Data(expected)) } - @Test("Encodes float") - func floatFlagValue() throws { + @Test + func `Encodes float`() throws { let input = BoxedFlagValue.float(123.456) let expected = #"{"f":123.456}"#.utf8 let encoded = try encoder.encode(input) @@ -97,8 +97,8 @@ struct BoxedFlagValueEncodingTests { // MARK: - Wrapping Types - @Test("Encodes nil") - func optionalNoFlagValue() throws { + @Test + func `Encodes nil`() throws { let input = BoxedFlagValue.none let expected = #"{"n":null}"#.utf8 let encoded = try encoder.encode(input) @@ -108,16 +108,16 @@ struct BoxedFlagValueEncodingTests { // MARK: - Collection Types - @Test("Encodes array") - func arrayFlagValue() throws { + @Test + func `Encodes array`() throws { let input = BoxedFlagValue.array([ .integer(123), .integer(456), .integer(789) ]) let expected = #"{"a":[{"i":123},{"i":456},{"i":789}]}"#.utf8 let encoded = try encoder.encode(input) #expect(encoded == Data(expected)) } - @Test("Encodes dictionary") - func dictionaryFlagValue() throws { + @Test + func `Encodes dictionary`() throws { let input = BoxedFlagValue.dictionary([ "one": .integer(123), "two": .integer(456), "three": .integer(789) ]) let expected = #"{"o":{"one":{"i":123},"three":{"i":789},"two":{"i":456}}}"#.utf8 let encoded = try encoder.encode(input) diff --git a/Tests/VexilTests/EquatableTests.swift b/Tests/VexilTests/EquatableTests.swift index afc5fd2..221e2c2 100644 --- a/Tests/VexilTests/EquatableTests.swift +++ b/Tests/VexilTests/EquatableTests.swift @@ -18,19 +18,19 @@ import Combine import Testing @testable import Vexil -@Suite("Equatable Tests", .tags(.pole)) +@Suite(.tags(.pole)) struct EquatableTests { // MARK: - Tests - @Test("Subsequent snapshots are equal", .tags(.snapshot)) - func snapshotEqual() { + @Test(.tags(.snapshot)) + func `Subsequent snapshots are equal`() { let pole = FlagPole(hoist: DoubleSubgroupFlags.self, sources: []) #expect(pole.emptySnapshot() == pole.emptySnapshot()) } - @Test("Snapshots with different contents are not equal", .tags(.snapshot)) - func snapshotNotEqual() { + @Test(.tags(.snapshot)) + func `Snapshots with different contents are not equal`() { let pole = FlagPole(hoist: DoubleSubgroupFlags.self, sources: []) let first = pole.emptySnapshot() let second = pole.emptySnapshot() @@ -38,14 +38,14 @@ struct EquatableTests { #expect(first != second) } - @Test("Computed flag groups are equal") - func groupEquality() { + @Test + func `Computed flag groups are equal`() { let pole = FlagPole(hoist: TestFlags.self, sources: []) #expect(pole.subgroup == pole.subgroup) } - @Test("Computed flags are equal") - func flagEquality() { + @Test + func `Computed flags are equal`() { let pole = FlagPole(hoist: TestFlags.self, sources: []) #expect(pole.topLevelFlag == pole.topLevelFlag) } @@ -181,7 +181,7 @@ private struct DoubleSubgroupFlags { } -// Support for empty Flag Containers +/// Support for empty Flag Containers @FlagContainer private struct EmptyFlags { // Intentionally left blank diff --git a/Tests/VexilTests/FlagDetailTests.swift b/Tests/VexilTests/FlagDetailTests.swift index 8c1f88b..059c4c8 100644 --- a/Tests/VexilTests/FlagDetailTests.swift +++ b/Tests/VexilTests/FlagDetailTests.swift @@ -14,11 +14,10 @@ import Testing import Vexil -@Suite("Flag Details") struct FlagDetailTests { - @Test("Captures details") - func capturesFlagDetails() throws { + @Test + func `Captures details`() { let pole = FlagPole(hoist: TestFlags.self, sources: []) #expect(pole.$topLevelFlag.key == "top-level-flag") diff --git a/Tests/VexilTests/FlagPoleTests.swift b/Tests/VexilTests/FlagPoleTests.swift index 6df7981..8e738b8 100644 --- a/Tests/VexilTests/FlagPoleTests.swift +++ b/Tests/VexilTests/FlagPoleTests.swift @@ -15,14 +15,13 @@ import Foundation import Testing @testable import Vexil -@Suite("Flag Pole") struct FlagPoleTests { #if !os(Linux) - @Test("Sets default sources", .tags(.pole)) - func setsDefaultSources() throws { + @Test(.tags(.pole)) + func `Sets default sources`() throws { let pole = FlagPole(hoist: TestFlags.self) #expect(pole._sources.count == 1) @@ -34,8 +33,8 @@ struct FlagPoleTests { #else - @Test("Sets default sources", .tags(.pole)) - func setsDefaultSources() throws { + @Test(.tags(.pole)) + func `sets default sources`() { let pole = FlagPole(hoist: TestFlags.self) #expect(pole._sources.isEmpty) } diff --git a/Tests/VexilTests/FlagValueBoxingTests.swift b/Tests/VexilTests/FlagValueBoxingTests.swift index c406d65..2744660 100644 --- a/Tests/VexilTests/FlagValueBoxingTests.swift +++ b/Tests/VexilTests/FlagValueBoxingTests.swift @@ -15,44 +15,44 @@ import Foundation import Testing @testable import Vexil -@Suite("Flag Value Boxing", .tags(.boxing)) +@Suite(.tags(.boxing)) struct FlagValueBoxingTests { // MARK: - Boolean Flag Values - @Test("Boxes boolean true") - func booleanTrueFlagValue() { + @Test + func `Boxes boolean true`() { #expect(true.boxedFlagValue == .bool(true)) } - @Test("Boxes boolean false") - func booleanFalseFlagValue() { + @Test + func `Boxes boolean false`() { #expect(false.boxedFlagValue == .bool(false)) } // MARK: - String Flag Values - @Test("Boxes string") - func stringFlagValue() { + @Test + func `Boxes string`() { #expect("Test String".boxedFlagValue == .string("Test String")) } - @Test("Boxes URL") - func urlStringFlagValue() { - #expect(URL(string: "https://google.com/")!.boxedFlagValue == .string("https://google.com/")) + @Test + func `Boxes URL`() { + #expect(URL(string: "https://google.com/")?.boxedFlagValue == .string("https://google.com/")) } // MARK: - Data and Date Types - @Test("Boxes data") - func dataFlagValue() { + @Test + func `Boxes data`() { #expect(Data("Test string".utf8).boxedFlagValue == .data(Data("Test string".utf8))) } - @Test("Boxes date") - func dateFlagValue() { + @Test + func `Boxes date`() { let input = Date() let formatter = ISO8601DateFormatter() formatter.formatOptions = [ .withInternetDateTime, .withFractionalSeconds ] @@ -63,74 +63,74 @@ struct FlagValueBoxingTests { // MARK: - Integer Flag Values - @Test("Boxes integer") - func intFlagValue() { + @Test + func `Boxes integer`() { #expect(123.boxedFlagValue == .integer(123)) } - @Test("Boxes 8-bit integer") - func int8FlagValue() { + @Test + func `Boxes 8-bit integer`() { #expect(Int8(12).boxedFlagValue == .integer(12)) } - @Test("Boxes 16-bit integer") - func int16FlagValue() { + @Test + func `Boxes 16-bit integer`() { #expect(Int16(123).boxedFlagValue == .integer(123)) } - @Test("Boxes 32-bit integer") - func int32FlagValue() { + @Test + func `Boxes 32-bit integer`() { #expect(Int32(123).boxedFlagValue == .integer(123)) } - @Test("Boxes 64-bit integer") - func int64FlagValue() { + @Test + func `Boxes 64-bit integer`() { #expect(Int64(123).boxedFlagValue == .integer(123)) } - @Test("Boxes unsigned integer") - func uintFlagValue() { + @Test + func `Boxes unsigned integer`() { #expect(UInt(123).boxedFlagValue == .integer(123)) } - @Test("Boxes 8-bit unsigned integer") - func uint8FlagValue() { + @Test + func `Boxes 8-bit unsigned integer`() { #expect(UInt8(123).boxedFlagValue == .integer(123)) } - @Test("Boxes 16-bit unsigned integer") - func uint16FlagValue() { + @Test + func `Boxes 16-bit unsigned integer`() { #expect(UInt16(123).boxedFlagValue == .integer(123)) } - @Test("Boxes 32-bit unsigned integer") - func uint32FlagValue() { + @Test + func `Boxes 32-bit unsigned integer`() { #expect(UInt32(123).boxedFlagValue == .integer(123)) } - @Test("Boxes 64-bit unsigned integer") - func uint64FlagValue() { + @Test + func `Boxes 64-bit unsigned integer`() { #expect(UInt64(123).boxedFlagValue == .integer(123)) } // MARK: - Floating Point Flag Values - @Test("Boxes float") - func floatFlagValue() { + @Test + func `Boxes float`() { #expect(Float(123.456).boxedFlagValue == .float(123.456)) } - @Test("Boxes double") - func doubleFlagValue() { + @Test + func `Boxes double`() { #expect(123.456.boxedFlagValue == .double(123.456)) } // MARK: - Wrapping Types - @Test("Boxes raw representable") - func rawRepresentableFlagValue() { + @Test + func `Boxes raw representable`() { #expect(TestStruct(rawValue: 123).boxedFlagValue == .integer(123)) struct TestStruct: RawRepresentable, FlagValue, Equatable { @@ -138,37 +138,37 @@ struct FlagValueBoxingTests { } } - @Test("Boxes optional") - func optionalSomeFlagValue() { + @Test + func `Boxes optional`() { #expect(Int?.some(123)?.boxedFlagValue == .integer(123)) } - @Test("Boxes nil") - func optionalNoFlagValue() { + @Test + func `Boxes nil`() { #expect(Int?.none.boxedFlagValue == BoxedFlagValue.none) } // MARK: - Collection Types - @Test("Boxes array") - func arrayFlagValue() { + @Test + func `Boxes array`() { #expect([ 123, 456, 789 ].boxedFlagValue == .array([ .integer(123), .integer(456), .integer(789) ])) } - @Test("Boxes dictionary") - func dictionaryFlagValue() { + @Test + func `Boxes dictionary`() { #expect( [ "one": 123, "two": 456, "three": 789 ].boxedFlagValue - == .dictionary([ "one": .integer(123), "two": .integer(456), "three": .integer(789) ]) + == .dictionary([ "one": .integer(123), "two": .integer(456), "three": .integer(789) ]), ) } // MARK: - Codable Types - @Test("Boxes codable", .tags(.codable)) - func codableFlagValue() throws { + @Test(.tags(.codable)) + func `Boxes codable`() throws { let input = TestStruct() let encoder = JSONEncoder() encoder.outputFormatting = .sortedKeys diff --git a/Tests/VexilTests/FlagValueCompilationTests.swift b/Tests/VexilTests/FlagValueCompilationTests.swift index b154dcf..c6b3c6e 100644 --- a/Tests/VexilTests/FlagValueCompilationTests.swift +++ b/Tests/VexilTests/FlagValueCompilationTests.swift @@ -27,13 +27,13 @@ import Testing /// from `Bool` we'd expect to see the second line of /// `testBooleanFlagValue` fail to compile /// -@Suite("Flag Value Compilation", .tags(.pole)) +@Suite(.tags(.pole)) struct FlagValueCompilationTests { // MARK: - Boolean Flag Values - @Test("Compiles boolean") - func booleanFlagValue() { + @Test + func `Compiles boolean`() { let pole = FlagPole(hoist: BooleanTestFlags.self, sources: []) #expect(pole.flag) } @@ -41,14 +41,14 @@ struct FlagValueCompilationTests { // MARK: - String Flag Values - @Test("Compiles string") - func stringFlagValue() { + @Test + func `Compiles string`() { let pole = FlagPole(hoist: StringTestFlags.self, sources: []) #expect(pole.flag == "Test") } - @Test("Compiles URL") - func urlFlagValue() { + @Test + func `Compiles URL`() { let pole = FlagPole(hoist: URLTestFlags.self, sources: []) #expect(pole.flag == URL(string: "https://google.com/")!) } @@ -56,14 +56,14 @@ struct FlagValueCompilationTests { // MARK: - Data and Date Flag Values - @Test("Compiles data") - func dataFlagValue() { + @Test + func `Compiles data`() { let pole = FlagPole(hoist: DataTestFlags.self, sources: []) #expect(pole.flag == Data("hello".utf8)) } - @Test("Compiles date", .tags(.source)) - func dateFlagValue() { + @Test(.tags(.source)) + func `Compiles date`() { // We need to use a source here to ensure that the expected value is *exactly* what it was let source = TestSource() let pole = FlagPole(hoist: DateTestFlags.self, sources: [ source ]) @@ -73,7 +73,7 @@ struct FlagValueCompilationTests { let flagValueSourceID = UUID().uuidString let flagValueSourceName: String = "Test" let value = Date.now - func flagValue(key: String) -> Value? where Value: FlagValue { + func flagValue(key: String) -> Value? { value as? Value } @@ -90,62 +90,62 @@ struct FlagValueCompilationTests { // MARK: - Integer Flag Values - @Test("Compiles integer") - func intFlagValue() { + @Test + func `Compiles integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 8-bit integer") - func int8FlagValue() { + @Test + func `Compiles 8-bit integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 16-bit integer") - func int16FlagValue() { + @Test + func `Compiles 16-bit integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 32-bit integer") - func int32FlagValue() { + @Test + func `Compiles 32-bit integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 64-bit integer") - func int64FlagValue() { + @Test + func `Compiles 64-bit integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles unsigned integer") - func uIntFlagValue() { + @Test + func `Compiles unsigned integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 8-bit unsigned integer") - func uint8FlagValue() { + @Test + func `Compiles 8-bit unsigned integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 16-bit unsigned integer") - func uint16FlagValue() { + @Test + func `Compiles 16-bit unsigned integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 32-bit unsigned integer") - func uint32FlagValue() { + @Test + func `Compiles 32-bit unsigned integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } - @Test("Compiles 64-bit unsigned integer") - func uint64FlagValue() { + @Test + func `Compiles 64-bit unsigned integer`() { let pole = FlagPole(hoist: IntTestFlags.self, sources: []) #expect(pole.flag == 123) } @@ -153,14 +153,14 @@ struct FlagValueCompilationTests { // MARK: - Floating Point Flag Values - @Test("Compiles float") - func floatFlagValue() { + @Test + func `Compiles float`() { let pole = FlagPole(hoist: FloatTestFlags.self, sources: []) #expect(pole.flag == 123.23) } - @Test("Compiles double") - func doubleFlagValue() { + @Test + func `Compiles double`() { let pole = FlagPole(hoist: FloatTestFlags.self, sources: []) #expect(pole.flag == 123.23) } @@ -168,20 +168,20 @@ struct FlagValueCompilationTests { // MARK: - Wrapping Types - @Test("Compiles raw representable") - func rawRepresentableFlagValue() { + @Test + func `Compiles raw representable`() { let pole = FlagPole(hoist: RawRepresentableTestFlags.self, sources: []) #expect(pole.flag == RawRepresentableTestStruct(rawValue: "Test")) } - @Test("Compiles optional") - func optionalFlagValue() { + @Test + func `Compiles optional`() { let pole = FlagPole(hoist: OptionalValueTestFlags.self, sources: []) #expect(pole.flag == "Test") } - @Test("Compiles nil") - func optionalNoFlagValue() { + @Test + func `Compiles nil`() { let pole = FlagPole(hoist: OptionalNoValueTestFlags.self, sources: []) #expect(pole.flag == nil) } @@ -189,14 +189,14 @@ struct FlagValueCompilationTests { // MARK: - Collection Types - @Test("Compiles array") - func arrayFlagValue() { + @Test + func `Compiles array`() { let pole = FlagPole(hoist: ArrayTestFlags.self, sources: []) #expect(pole.flag == [ 123, 456, 789 ]) } - @Test("Compiles dictionary") - func dictionaryFlagValue() { + @Test + func `Compiles dictionary`() { let pole = FlagPole(hoist: DictionaryTestFlags.self, sources: []) #expect(pole.flag == [ "First": 123, "Second": 456, "Third": 789 ]) } @@ -204,8 +204,8 @@ struct FlagValueCompilationTests { // MARK: - Codable Types - @Test("Compiles codable") - func codableFlagValue() { + @Test + func `Compiles codable`() { let pole = FlagPole(hoist: CodableTestFlags.self, sources: []) #expect(pole.flag == CodableTestStruct()) } @@ -249,13 +249,13 @@ private struct DataTestFlags { } @FlagContainer(generateEquatable: false) -private struct IntTestFlags where Value: FlagValue & ExpressibleByIntegerLiteral { +private struct IntTestFlags { @Flag("Test flag") var flag: Value = 123 } @FlagContainer(generateEquatable: false) -private struct FloatTestFlags where Value: FlagValue & ExpressibleByFloatLiteral { +private struct FloatTestFlags { @Flag("Test flag") var flag: Value = 123.23 } diff --git a/Tests/VexilTests/FlagValueDictionaryTests.swift b/Tests/VexilTests/FlagValueDictionaryTests.swift index db4a8e1..83c6c55 100644 --- a/Tests/VexilTests/FlagValueDictionaryTests.swift +++ b/Tests/VexilTests/FlagValueDictionaryTests.swift @@ -15,13 +15,13 @@ import Foundation import Testing @testable import Vexil -@Suite("FlagValueDictionary", .tags(.dictionary)) +@Suite(.tags(.dictionary)) struct FlagValueDictionaryTests { // MARK: - Reading Values - @Test("Gets flag value when FlagValueSource", .tags(.pole)) - func readsValues() { + @Test(.tags(.pole)) + func `Gets flag value when FlagValueSource`() { let source: FlagValueDictionary = [ "top-level-flag": .bool(true), ] @@ -34,8 +34,8 @@ struct FlagValueDictionaryTests { // MARK: - Writing Values - @Test("Sets flag value when FlagValueSource", .tags(.pole, .saving)) - func writesValues() throws { + @Test(.tags(.pole, .saving)) + func `Sets flag value when FlagValueSource`() throws { let source = FlagValueDictionary() let flagPole = FlagPole(hoist: TestFlags.self, sources: [ source ]) @@ -51,36 +51,36 @@ struct FlagValueDictionaryTests { // MARK: - Equatable Tests - @Test("Supports Equatable") - func equatable() { + @Test + func `Supports Equatable`() { let identifier1 = UUID().uuidString let original = FlagValueDictionary( id: identifier1, storage: [ "top-level-flag": .bool(true), - ] + ], ) let same = FlagValueDictionary( id: identifier1, storage: [ "top-level-flag": .bool(true), - ] + ], ) let differentContent = FlagValueDictionary( id: identifier1, storage: [ "top-level-flag": .bool(false), - ] + ], ) let differentIdentifier = FlagValueDictionary( id: UUID().uuidString, storage: [ "top-level-flag": .bool(true), - ] + ], ) let originalValues = original.allValues @@ -96,8 +96,8 @@ struct FlagValueDictionaryTests { // MARK: - Codable Tests - @Test("Supports Codable", .tags(.codable)) - func codable() throws { + @Test(.tags(.codable)) + func `Supports Codable`() throws { // BoxedFlagValue's Codable support is more heavily tested in it's tests let source: FlagValueDictionary = [ "bool-flag": .bool(true), diff --git a/Tests/VexilTests/FlagValueSourceTests.swift b/Tests/VexilTests/FlagValueSourceTests.swift index c46a809..d4343b4 100644 --- a/Tests/VexilTests/FlagValueSourceTests.swift +++ b/Tests/VexilTests/FlagValueSourceTests.swift @@ -15,11 +15,11 @@ import Foundation import Testing @testable import Vexil -@Suite("FlagValueSource", .tags(.pole, .source)) +@Suite(.tags(.pole, .source)) struct FlagValueSourceTests { - @Test("Reads values from source") - func readsFromSource() { + @Test + func `Reads values from source`() { let accessedKeys = Lock(initialState: [String]()) let values = [ "test-flag": true, @@ -44,8 +44,8 @@ struct FlagValueSourceTests { #expect(keys.last == "test-flag") } - @Test("Writes values to source", .tags(.snapshot)) - func writesToSource() throws { + @Test(.tags(.snapshot)) + func `Writes values to source`() throws { let setEvents = Lock(initialState: [TestSetSource.Event]()) let source = TestSetSource { event in setEvents.withLock { @@ -69,8 +69,8 @@ struct FlagValueSourceTests { #expect(events.last?.1 == false) } - @Test("Copies between sources", .tags(.copying, .dictionary)) - func copies() throws { + @Test(.tags(.copying, .dictionary)) + func `Copies between sources`() throws { // GIVEN two dictionaries let source = FlagValueDictionary([ @@ -91,8 +91,8 @@ struct FlagValueSourceTests { } - @Test("Removes from source", .tags(.removing)) - func removesAll() throws { + @Test(.tags(.removing)) + func `Removes from source`() throws { // GIVEN a dictionary with some values let source = FlagValueDictionary([ @@ -148,7 +148,7 @@ private final class TestGetSource: FlagValueSource { self.subject = subject } - func flagValue(key: String) -> Value? where Value: FlagValue { + func flagValue(key: String) -> Value? { subject(key) return values[key] as? Value } @@ -174,7 +174,7 @@ private final class TestSetSource: FlagValueSource { self.subject = subject } - func flagValue(key: String) -> Value? where Value: FlagValue { + func flagValue(key: String) -> Value? { nil } diff --git a/Tests/VexilTests/FlagValueUnboxingTests.swift b/Tests/VexilTests/FlagValueUnboxingTests.swift index 85d8655..d5da912 100644 --- a/Tests/VexilTests/FlagValueUnboxingTests.swift +++ b/Tests/VexilTests/FlagValueUnboxingTests.swift @@ -15,51 +15,51 @@ import Foundation import Testing @testable import Vexil -@Suite("Flag Value Unboxing", .tags(.boxing)) +@Suite(.tags(.boxing)) struct FlagValueUnboxingTests { // MARK: - Boolean Flag Values - @Test("Unboxes boolean", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.bool(true), .bool(false), .none ], - [ true, false, nil ] + [ true, false, nil ], )) - func booleanFlagValues(boxed: BoxedFlagValue, unboxed: Bool?) { + func `Unboxes boolean`(boxed: BoxedFlagValue, unboxed: Bool?) { #expect(Bool(boxedFlagValue: boxed) == unboxed) } // MARK: - String Flag Values - @Test("Unboxes string", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.string("Test String"), .none ], - [ "Test String", nil ] + [ "Test String", nil ], )) - func stringFlagValues(boxed: BoxedFlagValue, unboxed: String?) { + func `Unboxes string`(boxed: BoxedFlagValue, unboxed: String?) { #expect(String(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes URL", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.string("https://google.com/"), .none ], - [ URL(string: "https://google.com/")!, nil ] + [ URL(string: "https://google.com/")!, nil ], )) - func urlStringFlagValues(boxed: BoxedFlagValue, unboxed: URL?) { + func `Unboxes URL`(boxed: BoxedFlagValue, unboxed: URL?) { #expect(URL(boxedFlagValue: boxed) == unboxed) } // MARK: - Data and Date Types - @Test("Unboxes data", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.data(Data("Test string".utf8)), .none ], - [ Data("Test string".utf8), nil ] + [ Data("Test string".utf8), nil ], )) - func dataFlagValues(boxed: BoxedFlagValue, unboxed: Data?) { + func `Unboxes data`(boxed: BoxedFlagValue, unboxed: Data?) { #expect(Data(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes date") - func dateFlagValues() throws { + @Test + func `Unboxes date`() throws { let expected = Date() let formatter = ISO8601DateFormatter() formatter.formatOptions = [ .withInternetDateTime, .withFractionalSeconds ] @@ -81,118 +81,118 @@ struct FlagValueUnboxingTests { // MARK: - Integer Flag Values - @Test("Unboxes integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(123), .none ], - [ 123, nil ] + [ 123, nil ], )) - func intFlagValues(boxed: BoxedFlagValue, unboxed: Int?) { + func `Unboxes integer`(boxed: BoxedFlagValue, unboxed: Int?) { #expect(Int(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 8-bit integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(12), .none ], - [ 12, nil ] + [ 12, nil ], )) - func int8FlagValues(boxed: BoxedFlagValue, unboxed: Int8?) { + func `Unboxes 8-bit integer`(boxed: BoxedFlagValue, unboxed: Int8?) { #expect(Int8(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 16-bit integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(123), .none ], - [ 123, nil ] + [ 123, nil ], )) - func int16FlagValues(boxed: BoxedFlagValue, unboxed: Int16?) { + func `Unboxes 16-bit integer`(boxed: BoxedFlagValue, unboxed: Int16?) { #expect(Int16(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 32-bit integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(123), .none ], - [ 123, nil ] + [ 123, nil ], )) - func int32FlagValues(boxed: BoxedFlagValue, unboxed: Int32?) { + func `Unboxes 32-bit integer`(boxed: BoxedFlagValue, unboxed: Int32?) { #expect(Int32(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 64-bit integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(123), .none ], - [ 123, nil ] + [ 123, nil ], )) - func int64FlagValues(boxed: BoxedFlagValue, unboxed: Int64?) { + func `Unboxes 64-bit integer`(boxed: BoxedFlagValue, unboxed: Int64?) { #expect(Int64(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes unsigned integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(123), .none ], - [ 123, nil ] + [ 123, nil ], )) - func uintFlagValues(boxed: BoxedFlagValue, unboxed: UInt?) { + func `Unboxes unsigned integer`(boxed: BoxedFlagValue, unboxed: UInt?) { #expect(UInt(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 8-bit unsigned integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(12), .none ], - [ 12, nil ] + [ 12, nil ], )) - func uint8FlagValues(boxed: BoxedFlagValue, unboxed: UInt8?) { + func `Unboxes 8-bit unsigned integer`(boxed: BoxedFlagValue, unboxed: UInt8?) { #expect(UInt8(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 16-bit unsigned integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(12), .none ], - [ 12, nil ] + [ 12, nil ], )) - func uint16FlagValues(boxed: BoxedFlagValue, unboxed: UInt16?) { + func `Unboxes 16-bit unsigned integer`(boxed: BoxedFlagValue, unboxed: UInt16?) { #expect(UInt16(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 32-bit unsigned integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(12), .none ], - [ 12, nil ] + [ 12, nil ], )) - func uint32FlagValues(boxed: BoxedFlagValue, unboxed: UInt32?) { + func `Unboxes 32-bit unsigned integer`(boxed: BoxedFlagValue, unboxed: UInt32?) { #expect(UInt32(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes 64-bit unsigned integer", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(12), .none ], - [ 12, nil ] + [ 12, nil ], )) - func uint64FlagValues(boxed: BoxedFlagValue, unboxed: UInt64?) { + func `Unboxes 64-bit unsigned integer`(boxed: BoxedFlagValue, unboxed: UInt64?) { #expect(UInt64(boxedFlagValue: boxed) == unboxed) } // MARK: - Floating Point Flag Values - @Test("Unboxes float", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.float(123.456), .double(123.456), .none ], - [ 123.456, 123.456, nil ] + [ 123.456, 123.456, nil ], )) - func floatFlagValues(boxed: BoxedFlagValue, unboxed: Float?) { + func `Unboxes float`(boxed: BoxedFlagValue, unboxed: Float?) { #expect(Float(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes double", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.double(123.456), .none ], - [ 123.456, nil ] + [ 123.456, nil ], )) - func doubleFlagValues(boxed: BoxedFlagValue, unboxed: Double?) { + func `Unboxes double`(boxed: BoxedFlagValue, unboxed: Double?) { #expect(Double(boxedFlagValue: boxed) == unboxed) } // MARK: - Wrapping Types - @Test("Unboxes raw representable", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.integer(123), .none ], - [ TestRawRepresentable(rawValue: 123), nil ] + [ TestRawRepresentable(rawValue: 123), nil ], )) - private func rawRepresentableFlagValue(boxed: BoxedFlagValue, unboxed: TestRawRepresentable?) { + private func `Unboxes raw representable`(boxed: BoxedFlagValue, unboxed: TestRawRepresentable?) { #expect(TestRawRepresentable(boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes optional") - func optionalFlagValues() { + @Test + func `Unboxes optional`() { #expect(Int?(boxedFlagValue: .integer(123)) == Int?.some(123)) #expect(Int?(boxedFlagValue: .none) == Int?.none) } @@ -200,27 +200,27 @@ struct FlagValueUnboxingTests { // MARK: - Collection Types - @Test("Unboxes array", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.array([ .integer(123), .integer(456), .integer(789) ]), .none ], - [ [ 123, 456, 789 ], nil ] + [ [ 123, 456, 789 ], nil ], )) - func arrayFlagValues(boxed: BoxedFlagValue, unboxed: [Int]?) { + func `Unboxes array`(boxed: BoxedFlagValue, unboxed: [Int]?) { #expect([Int](boxedFlagValue: boxed) == unboxed) } - @Test("Unboxes dictionary", arguments: zip( + @Test(arguments: zip( [ BoxedFlagValue.dictionary([ "one": .integer(123), "two": .integer(456), "three": .integer(789) ]), .none ], - [ [ "one": 123, "two": 456, "three": 789 ], nil ] + [ [ "one": 123, "two": 456, "three": 789 ], nil ], )) - func dictionaryFlagValues(boxed: BoxedFlagValue, unboxed: [String: Int]?) { + func `Unboxes dictionary`(boxed: BoxedFlagValue, unboxed: [String: Int]?) { #expect([String: Int](boxedFlagValue: boxed) == unboxed) } // MARK: - Codable Types - @Test("Unboxes codable") - private func codableFlagValue() throws { + @Test + private func `Unboxes codable`() throws { let expected = TestCodable() let data = try JSONEncoder().encode(Wrapper(wrapped: expected)) diff --git a/Tests/VexilTests/KeyEncodingTests.swift b/Tests/VexilTests/KeyEncodingTests.swift index 5774caf..89bbd39 100644 --- a/Tests/VexilTests/KeyEncodingTests.swift +++ b/Tests/VexilTests/KeyEncodingTests.swift @@ -14,11 +14,11 @@ import Testing import Vexil -@Suite("Key Encoding", .tags(.pole)) +@Suite(.tags(.pole)) struct KeyEncodingTests { - @Test("Encodes with kebab-case") - func kebabcase() { + @Test + func `Encodes with kebab-case`() { let config = VexilConfiguration(codingPathStrategy: .kebabcase, prefix: nil, separator: ".") let pole = FlagPole(hoist: TestFlags.self, configuration: config, sources: []) @@ -31,8 +31,8 @@ struct KeyEncodingTests { #expect(pole.oneFlagGroup.twoFlagGroup.flagGroupThree.$standard.key == "one-flag-group.two.standard") } - @Test("Encodes with snake_case") - func snakecase() { + @Test + func `Encodes with snake_case`() { let config = VexilConfiguration(codingPathStrategy: .snakecase, prefix: nil, separator: ".") let pole = FlagPole(hoist: TestFlags.self, configuration: config, sources: []) @@ -45,8 +45,8 @@ struct KeyEncodingTests { #expect(pole.oneFlagGroup.twoFlagGroup.flagGroupThree.$standard.key == "one_flag_group.two.standard") } - @Test("Encodes with prefix") - func prefix() { + @Test + func `Encodes with prefix`() { let config = VexilConfiguration(codingPathStrategy: .kebabcase, prefix: "prefix", separator: ".") let pole = FlagPole(hoist: TestFlags.self, configuration: config, sources: []) @@ -59,8 +59,8 @@ struct KeyEncodingTests { #expect(pole.oneFlagGroup.twoFlagGroup.flagGroupThree.$standard.key == "prefix.one-flag-group.two.standard") } - @Test("Encodes with custom separator") - func customSeparator() { + @Test + func `Encodes with custom separator`() { let config = VexilConfiguration(codingPathStrategy: .kebabcase, prefix: "prefix", separator: "/") let pole = FlagPole(hoist: TestFlags.self, configuration: config, sources: []) diff --git a/Tests/VexilTests/PublisherTests.swift b/Tests/VexilTests/PublisherTests.swift index 3c32d5a..fa75157 100644 --- a/Tests/VexilTests/PublisherTests.swift +++ b/Tests/VexilTests/PublisherTests.swift @@ -209,7 +209,7 @@ private final class TestSource: FlagValueSource { self.continuation = continuation } - func flagValue(key: String) -> Value? where Value: FlagValue { + func flagValue(key: String) -> Value? { nil } diff --git a/Tests/VexilTests/SnapshotTests.swift b/Tests/VexilTests/SnapshotTests.swift index 296e8a1..5875dd0 100644 --- a/Tests/VexilTests/SnapshotTests.swift +++ b/Tests/VexilTests/SnapshotTests.swift @@ -14,11 +14,11 @@ import Testing import Vexil -@Suite("Snapshots", .tags(.pole, .snapshot)) +@Suite(.tags(.pole, .snapshot)) struct SnapshotTests { - @Test("Reads from snapshot") - func snapshotReading() { + @Test + func `Reads from snapshot`() { let pole = FlagPole(hoist: TestFlags.self, sources: []) let snapshot = pole.emptySnapshot() @@ -27,8 +27,8 @@ struct SnapshotTests { #expect(snapshot.subgroup.doubleSubgroup.thirdLevelFlag == false) } - @Test("Writes to snapshot") - func snapshotWriting() { + @Test + func `Writes to snapshot`() { let pole = FlagPole(hoist: TestFlags.self, sources: []) let snapshot = pole.emptySnapshot() snapshot.topLevelFlag = true @@ -42,8 +42,8 @@ struct SnapshotTests { // MARK: - Taking Snapshots - @Test("Takes empty snapshot") - func emptySnapshot() { + @Test + func `Takes empty snapshot`() { let pole = FlagPole(hoist: TestFlags.self, sources: []) // craft a snapshot @@ -64,8 +64,8 @@ struct SnapshotTests { #expect(snapshot.subgroup.doubleSubgroup.thirdLevelFlag == false) } - @Test("Snapshots reflect current sources") - func currentSources() { + @Test + func `Snapshots reflect current sources`() { let pole = FlagPole(hoist: TestFlags.self, sources: []) // craft a snapshot @@ -96,8 +96,8 @@ struct SnapshotTests { #expect(empty.subgroup.doubleSubgroup.thirdLevelFlag == false) } - @Test("Snapshots specific source", .tags(.dictionary)) - func specificSource() throws { + @Test(.tags(.dictionary)) + func `Snapshots specific source`() { // GIVEN a FlagPole and a dictionary that is not a part it let pole = FlagPole(hoist: TestFlags.self, sources: []) diff --git a/Tests/VexilTests/UserDefaultsDecodingTests.swift b/Tests/VexilTests/UserDefaultsDecodingTests.swift index 4db70dc..28512b8 100644 --- a/Tests/VexilTests/UserDefaultsDecodingTests.swift +++ b/Tests/VexilTests/UserDefaultsDecodingTests.swift @@ -17,20 +17,20 @@ import Foundation import Testing @testable import Vexil -@Suite("UserDefaults Decoding", .tags(.userDefaults)) +@Suite(.tags(.userDefaults)) final class UserDefaultsDecodingTests { // MARK: - Decoding Missing Values - @Test("Decodes missing value as nil") - func missing() { + @Test + func `Decodes missing value as nil`() { withUserDefaults(#function) { defaults in #expect(defaults.flagValue(key: "test") as Bool? == nil) } } - @Test("Decodes unset value as nil") - func unset() { + @Test + func `Decodes unset value as nil`() { withUserDefaults(#function) { defaults in defaults.set(true, forKey: "test") defaults.removeObject(forKey: "test") @@ -41,40 +41,40 @@ final class UserDefaultsDecodingTests { // MARK: - Decoding Boolean Types - @Test("Decodes boolean true") - func booleanTrue() { + @Test + func `Decodes boolean true`() { withUserDefaults(#function) { defaults in defaults.set(true, forKey: "test") #expect(defaults.flagValue(key: "test") == true) } } - @Test("Decodes boolean false") - func booleanFalse() { + @Test + func `Decodes boolean false`() { withUserDefaults(#function) { defaults in defaults.set(false, forKey: "test") #expect(defaults.flagValue(key: "test") == false) } } - @Test("Decodes integer as boolean") - func booleanInteger() { + @Test + func `Decodes integer as boolean`() { withUserDefaults(#function) { defaults in defaults.set(1, forKey: "test") #expect(defaults.flagValue(key: "test") == true) } } - @Test("Decodes double as boolean") - func booleanDouble() { + @Test + func `Decodes double as boolean`() { withUserDefaults(#function) { defaults in defaults.set(1.0, forKey: "test") #expect(defaults.flagValue(key: "test") == true) } } - @Test("Decodes string as boolean") - func booleanString() { + @Test + func `Decodes string as boolean`() { withUserDefaults(#function) { defaults in defaults.set("t", forKey: "test") #expect(defaults.flagValue(key: "test") == true) @@ -84,16 +84,16 @@ final class UserDefaultsDecodingTests { // MARK: - Decoding String Types - @Test("Decodes string") - func string() { + @Test + func `Decodes string`() { withUserDefaults(#function) { defaults in defaults.set("abcd1234", forKey: "test") #expect(defaults.flagValue(key: "test") == "abcd1234") } } - @Test("Decodes URL") - func url() { + @Test + func `Decodes URL`() { withUserDefaults(#function) { defaults in defaults.set("https://google.com/", forKey: "test") #expect(defaults.flagValue(key: "test") == URL(string: "https://google.com/")!) @@ -103,32 +103,32 @@ final class UserDefaultsDecodingTests { // MARK: - Decoding Float / Double Types - @Test("Decodes double") - func double() { + @Test + func `Decodes double`() { withUserDefaults(#function) { defaults in defaults.set(123.456, forKey: "test") #expect(defaults.flagValue(key: "test") == 123.456) } } - @Test("Decodes float") - func float() { + @Test + func `Decodes float`() { withUserDefaults(#function) { defaults in defaults.set(Float(123.456), forKey: "test") #expect(defaults.flagValue(key: "test") == Float(123.456)) } } - @Test("Decodes integer as double") - func doubleinteger() { + @Test + func `Decodes integer as double`() { withUserDefaults(#function) { defaults in defaults.set(1, forKey: "test") #expect(defaults.flagValue(key: "test") == 1.0) } } - @Test("Decodes string as double") - func doubleString() { + @Test + func `Decodes string as double`() { withUserDefaults(#function) { defaults in defaults.set("1.23456789", forKey: "test") #expect(defaults.flagValue(key: "test") == 1.23456789) @@ -138,96 +138,96 @@ final class UserDefaultsDecodingTests { // MARK: - Decoding Integer Types - @Test("Decodes integer") - func int() { + @Test + func `Decodes integer`() { withUserDefaults(#function) { defaults in defaults.set(1234, forKey: "test") #expect(defaults.flagValue(key: "test") == 1234) } } - @Test("Decodes 8-bit integer") - func int8() { + @Test + func `Decodes 8-bit integer`() { withUserDefaults(#function) { defaults in defaults.set(Int8(12), forKey: "test") #expect(defaults.flagValue(key: "test") == Int8(12)) } } - @Test("Decodes 16-bit integer") - func int16() { + @Test + func `Decodes 16-bit integer`() { withUserDefaults(#function) { defaults in defaults.set(Int16(1234), forKey: "test") #expect(defaults.flagValue(key: "test") == Int16(1234)) } } - @Test("Decodes 32-bit integer") - func int32() { + @Test + func `Decodes 32-bit integer`() { withUserDefaults(#function) { defaults in defaults.set(Int32(1234), forKey: "test") #expect(defaults.flagValue(key: "test") == Int32(1234)) } } - @Test("Decodes 64-bit integer") - func int64() { + @Test + func `Decodes 64-bit integer`() { withUserDefaults(#function) { defaults in defaults.set(Int64(1234), forKey: "test") #expect(defaults.flagValue(key: "test") == Int64(1234)) } } - @Test("Decodes unsigned integer") - func uint() { + @Test + func `Decodes unsigned integer`() { withUserDefaults(#function) { defaults in defaults.set(UInt(1234), forKey: "test") #expect(defaults.flagValue(key: "test") == UInt(1234)) } } - @Test("Decodes 8-bit unsigned integer") - func uint8() { + @Test + func `Decodes 8-bit unsigned integer`() { withUserDefaults(#function) { defaults in defaults.set(UInt8(12), forKey: "test") #expect(defaults.flagValue(key: "test") == UInt8(12)) } } - @Test("Decodes 16-bit unsigned integer") - func uint16() { + @Test + func `Decodes 16-bit unsigned integer`() { withUserDefaults(#function) { defaults in defaults.set(UInt16(1234), forKey: "test") #expect(defaults.flagValue(key: "test") == UInt16(1234)) } } - @Test("Decodes 32-bit unsigned integer") - func uint32() { + @Test + func `Decodes 32-bit unsigned integer`() { withUserDefaults(#function) { defaults in defaults.set(UInt32(1234), forKey: "test") #expect(defaults.flagValue(key: "test") == UInt32(1234)) } } - @Test("Decodes 64-bit unsigned integer") - func uint64() { + @Test + func `Decodes 64-bit unsigned integer`() { withUserDefaults(#function) { defaults in defaults.set(UInt64(1234), forKey: "test") #expect(defaults.flagValue(key: "test") == UInt64(1234)) } } - @Test("Decodes string as integer") - func intString() { + @Test + func `Decodes string as integer`() { withUserDefaults(#function) { defaults in defaults.set("1234", forKey: "test") #expect(defaults.flagValue(key: "test") == 1234) } } - @Test("Decodes string as unsigned integer") - func uintString() { + @Test + func `Decodes string as unsigned integer`() { withUserDefaults(#function) { defaults in defaults.set("1234", forKey: "test") #expect(defaults.flagValue(key: "test") == UInt(1234)) @@ -237,8 +237,8 @@ final class UserDefaultsDecodingTests { // MARK: - Wrapping Types - @Test("Decodes raw representable string") - func rawRepresentableString() { + @Test + func `Decodes raw representable string`() { withUserDefaults(#function) { defaults in defaults.set("Test Value", forKey: "test") #expect(defaults.flagValue(key: "test") == TestStruct(rawValue: "Test Value")) @@ -249,8 +249,8 @@ final class UserDefaultsDecodingTests { } } - @Test("Decodes raw representable boolean") - func rawRepresentableBool() { + @Test + func `Decodes raw representable boolean`() { withUserDefaults(#function) { defaults in defaults.set(true, forKey: "test") #expect(defaults.flagValue(key: "test") == TestStruct(rawValue: true)) @@ -263,32 +263,32 @@ final class UserDefaultsDecodingTests { // double optionals here because flagValue(key:) returns an optional, so Value is inferred as "String?" or "Bool?" - @Test("Decodes optional boolean") - func optionalBool() { + @Test + func `Decodes optional boolean`() { withUserDefaults(#function) { defaults in defaults.set(true, forKey: "test") #expect(defaults.flagValue(key: "test") == Bool??.some(true)) } } - @Test("Decodes optional string") - func optionalString() { + @Test + func `Decodes optional string`() { withUserDefaults(#function) { defaults in defaults.set("Test Value", forKey: "test") #expect(defaults.flagValue(key: "test") == String??.some("Test Value")) } } - @Test("Decodes nil") - func optionalNil() { + @Test + func `Decodes nil`() { withUserDefaults(#function) { defaults in defaults.removeObject(forKey: "test") #expect(defaults.flagValue(key: "test") == String??.none) } } - @Test("Decodes string as optional boolean") - func optionalBoolString() { + @Test + func `Decodes string as optional boolean`() { withUserDefaults(#function) { defaults in defaults.set("t", forKey: "test") defaults.synchronize() @@ -298,16 +298,16 @@ final class UserDefaultsDecodingTests { // MARK: - Array Tests - @Test("Decodes string array") - func stringArray() { + @Test + func `Decodes string array`() { withUserDefaults(#function) { defaults in defaults.set([ "abc", "123" ], forKey: "test") #expect(defaults.flagValue(key: "test") == [ "abc", "123" ]) } } - @Test("Decodes integer array") - func integerArray() { + @Test + func `Decodes integer array`() { withUserDefaults(#function) { defaults in defaults.set([ 234, -123 ], forKey: "test") #expect(defaults.flagValue(key: "test") == [ 234, -123 ]) @@ -317,16 +317,16 @@ final class UserDefaultsDecodingTests { // MARK: - Dictionary Tests - @Test("Decodes string dictionary") - func stringDictionary() { + @Test + func `Decodes string dictionary`() { withUserDefaults(#function) { defaults in defaults.set([ "key1": "value1", "key2": "value2" ], forKey: "test") #expect(defaults.flagValue(key: "test") == [ "key1": "value1", "key2": "value2" ]) } } - @Test("Decodes integer dictionary") - func integerDictionary() { + @Test + func `Decodes integer dictionary`() { withUserDefaults(#function) { defaults in defaults.set([ "key1": 123, "key2": -987 ], forKey: "test") #expect(defaults.flagValue(key: "test") == [ "key1": 123, "key2": -987 ]) @@ -336,8 +336,8 @@ final class UserDefaultsDecodingTests { // MARK: - Codable Tests - @Test("Decodes codable") - func codable() { + @Test + func `Decodes codable`() { struct MyStruct: FlagValue, Codable, Equatable { let property1: String let property2: Int @@ -370,8 +370,8 @@ final class UserDefaultsDecodingTests { } } - @Test("Decodes enum") - func enumeration() throws { + @Test + func `Decodes enum`() throws { enum MyEnum: String, FlagValue, Equatable { case one case two diff --git a/Tests/VexilTests/UserDefaultsEncodingTests.swift b/Tests/VexilTests/UserDefaultsEncodingTests.swift index 1cd3de9..bb8bd42 100644 --- a/Tests/VexilTests/UserDefaultsEncodingTests.swift +++ b/Tests/VexilTests/UserDefaultsEncodingTests.swift @@ -17,7 +17,7 @@ import Foundation import Testing @testable import Vexil -@Suite("UserDefaults Encoding", .tags(.userDefaults)) +@Suite(.tags(.userDefaults)) final class UserDefaultsEncodingTests { private let defaults: UserDefaults @@ -33,8 +33,8 @@ final class UserDefaultsEncodingTests { // MARK: - Removing Values - @Test("Unsets values") - func unsets() throws { + @Test + func `Unsets values`() throws { try withUserDefaults(#function) { defaults in defaults.set(true, forKey: "test") #expect(defaults.object(forKey: "test") != nil) @@ -47,16 +47,16 @@ final class UserDefaultsEncodingTests { // MARK: - Decoding Boolean Types - @Test("Encodes boolean true") - func booleanTrue() throws { + @Test + func `Encodes boolean true`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(true, key: "test") #expect(defaults.bool(forKey: "test") == true) } } - @Test("Encodes boolean false") - func booleanFalse() throws { + @Test + func `Encodes boolean false`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(false, key: "test") #expect(defaults.bool(forKey: "test") == false) @@ -66,16 +66,16 @@ final class UserDefaultsEncodingTests { // MARK: - Decoding String Types - @Test("Encodes string") - func string() throws { + @Test + func `Encodes string`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue("abcd1234", key: "test") #expect(defaults.string(forKey: "test") == "abcd1234") } } - @Test("Encodes URL") - func url() throws { + @Test + func `Encodes URL`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(URL(string: "https://google.com/")!, key: "test") #expect(defaults.string(forKey: "test") == "https://google.com/") @@ -85,8 +85,8 @@ final class UserDefaultsEncodingTests { // MARK: - Encoding Float / Double Types - @Test("Encodes double") - func double() throws { + @Test + func `Encodes double`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(123.456, key: "test") #expect(defaults.double(forKey: "test") == 123.456) @@ -103,80 +103,80 @@ final class UserDefaultsEncodingTests { // MARK: - Encoding Integer Types - @Test("Encodes integer") - func int() throws { + @Test + func `Encodes integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(1234, key: "test") #expect(defaults.integer(forKey: "test") == 1234) } } - @Test("Encodes 8-bit integer") - func int8() throws { + @Test + func `Encodes 8-bit integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(Int8(12), key: "test") #expect(defaults.integer(forKey: "test") == Int8(12)) } } - @Test("Encodes 16-bit integer") - func int16() throws { + @Test + func `Encodes 16-bit integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(Int16(1234), key: "test") #expect(defaults.integer(forKey: "test") == Int16(1234)) } } - @Test("Encodes 32-bit integer") - func int32() throws { + @Test + func `Encodes 32-bit integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(Int32(1234), key: "test") #expect(defaults.integer(forKey: "test") == Int32(1234)) } } - @Test("Encodes 64-bit integer") - func int64() throws { + @Test + func `Encodes 64-bit integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(Int64(1234), key: "test") #expect(defaults.integer(forKey: "test") == Int64(1234)) } } - @Test("Encodes unsigned integer") - func uint() throws { + @Test + func `Encodes unsigned integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(UInt(1234), key: "test") #expect(defaults.integer(forKey: "test") == UInt(1234)) } } - @Test("Encodes 8-bit unsigned integer") - func uint8() throws { + @Test + func `Encodes 8-bit unsigned integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(UInt8(12), key: "test") #expect(defaults.integer(forKey: "test") == UInt8(12)) } } - @Test("Encodes 16-bit unsigned integer") - func uint16() throws { + @Test + func `Encodes 16-bit unsigned integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(UInt16(1234), key: "test") #expect(defaults.integer(forKey: "test") == UInt16(1234)) } } - @Test("Encodes 32-bit unsigned integer") - func uint32() throws { + @Test + func `Encodes 32-bit unsigned integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(UInt32(1234), key: "test") #expect(defaults.integer(forKey: "test") == UInt32(1234)) } } - @Test("Encodes 64-bit unsigned integer") - func uint64() throws { + @Test + func `Encodes 64-bit unsigned integer`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(UInt64(1234), key: "test") #expect(defaults.integer(forKey: "test") == UInt64(1234)) @@ -186,8 +186,8 @@ final class UserDefaultsEncodingTests { // MARK: - Wrapping Types - @Test("Encodes raw representable") - func rawRepresentable() throws { + @Test + func `Encodes raw representable`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue(TestStruct(rawValue: "Test Value"), key: "test") #expect(defaults.string(forKey: "test") == "Test Value") @@ -198,8 +198,8 @@ final class UserDefaultsEncodingTests { } } - @Test("Encodes optional") - func optional() throws { + @Test + func `Encodes optional`() throws { try withUserDefaults(#function) { defaults in let value: String? = "Test Value" @@ -208,8 +208,8 @@ final class UserDefaultsEncodingTests { } } - @Test("Encodes nil") - func none() throws { + @Test + func `Encodes nil`() throws { try withUserDefaults(#function) { defaults in let value: String? = nil @@ -221,16 +221,16 @@ final class UserDefaultsEncodingTests { // MARK: - Array Tests - @Test("Encodes string array") - func stringArray() throws { + @Test + func `Encodes string array`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue([ "abc", "123" ], key: "test") #expect(defaults.stringArray(forKey: "test") == [ "abc", "123" ]) } } - @Test("Encodes integer array") - func integerArray() throws { + @Test + func `Encodes integer array`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue([ 234, -123 ], key: "test") #expect(defaults.array(forKey: "test") as? [Int] == [ 234, -123 ]) @@ -240,16 +240,16 @@ final class UserDefaultsEncodingTests { // MARK: - Dictionary Tests - @Test("Encodes string dictionary") - func stringDictionary() throws { + @Test + func `Encodes string dictionary`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue([ "key1": "value1", "key2": "value2" ], key: "test") #expect(defaults.dictionary(forKey: "test") as? [String: String] == [ "key1": "value1", "key2": "value2" ]) } } - @Test("Encodes integer dictionary") - func integerDictionary() throws { + @Test + func `Encodes integer dictionary`() throws { try withUserDefaults(#function) { defaults in try defaults.setFlagValue([ "key1": 123, "key2": -987 ], key: "test") #expect(defaults.dictionary(forKey: "test") as? [String: Int] == [ "key1": 123, "key2": -987 ]) @@ -258,8 +258,8 @@ final class UserDefaultsEncodingTests { // MARK: - Codable Tests - @Test("Encodes codable") - func codable() throws { + @Test + func `Encodes codable`() throws { struct MyStruct: FlagValue, Codable, Equatable { let property1: String let property2: Int diff --git a/Tests/VexilTests/VisitorTests.swift b/Tests/VexilTests/VisitorTests.swift index e7208d6..d3dff9f 100644 --- a/Tests/VexilTests/VisitorTests.swift +++ b/Tests/VexilTests/VisitorTests.swift @@ -14,11 +14,10 @@ import Testing import Vexil -@Suite("Visitors") struct VisitorTests { - @Test("Visits every expected element") - func visitsEveryElement() { + @Test + func `Visits every expected element`() { let pole = FlagPole(hoist: TestFlags.self, configuration: .init(codingPathStrategy: .kebabcase, prefix: nil, separator: "."), sources: []) let visitor = Visitor() pole.walk(visitor: visitor) @@ -43,7 +42,7 @@ struct VisitorTests { .endGroup("subgroup"), .endContainer(""), // root - ] + ], ) } } @@ -111,7 +110,7 @@ private final class Visitor: FlagVisitor { events.append(.endGroup(keyPath.key)) } - func visitFlag(keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, wigwag: () -> FlagWigwag) where Value: FlagValue { + func visitFlag(keyPath: FlagKeyPath, value: () -> Value?, defaultValue: Value, wigwag: () -> FlagWigwag) { events.append(.visitFlag(keyPath.key)) }