From f875523b20c9c21b5bb9839c8e0990feb52f61dc Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Wed, 27 Jan 2021 13:52:03 +0000 Subject: [PATCH 01/42] Add basic Encodable support --- Sources/Partial/Partial+Encodable.swift | 7 ++ Sources/Partial/Partial.swift | 14 +++- .../Tests/PartialCodableTests.swift | 70 +++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 Sources/Partial/Partial+Encodable.swift create mode 100644 Tests/PartialTests/Tests/PartialCodableTests.swift diff --git a/Sources/Partial/Partial+Encodable.swift b/Sources/Partial/Partial+Encodable.swift new file mode 100644 index 00000000..6925d76a --- /dev/null +++ b/Sources/Partial/Partial+Encodable.swift @@ -0,0 +1,7 @@ +import Foundation + +public protocol PartialCodable: Codable { + associatedtype CodingKey: Swift.CodingKey + + static func encodeValue(_ value: Any, for keyPath: PartialKeyPath, to container: inout KeyedEncodingContainer) throws +} diff --git a/Sources/Partial/Partial.swift b/Sources/Partial/Partial.swift index fa882b3b..f67da7c2 100644 --- a/Sources/Partial/Partial.swift +++ b/Sources/Partial/Partial.swift @@ -3,7 +3,6 @@ import Foundation /// A struct that mirrors the properties of `Wrapped`, making each of the /// types optional. public struct Partial: PartialProtocol, CustomStringConvertible { - /// An error that can be thrown by the `value(for:)` function. public enum Error: Swift.Error { /// The key path has not been set. @@ -16,7 +15,7 @@ public struct Partial: PartialProtocol, CustomStringConvertible { } /// The values that have been set. - private var values: [PartialKeyPath: Any] = [:] + fileprivate var values: [PartialKeyPath: Any] = [:] /// Create an empty `Partial`. public init() {} @@ -51,5 +50,16 @@ public struct Partial: PartialProtocol, CustomStringConvertible { public mutating func removeValue(for keyPath: KeyPath) { values.removeValue(forKey: keyPath) } +} + +extension Partial: Encodable where Wrapped: PartialCodable { + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: Wrapped.CodingKey.self) + try values.forEach { pair in + let (keyPath, value) = pair + + try Wrapped.encodeValue(value, for: keyPath, to: &container) + } + } } diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/PartialCodableTests.swift new file mode 100644 index 00000000..24930277 --- /dev/null +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift @@ -0,0 +1,70 @@ +import Quick +import Nimble +import Foundation + +@testable +import Partial + +final class PartialCodableTests: QuickSpec { + override func spec() { + describe("PartialCodable") { + struct CodableType: Codable, PartialCodable, Hashable { + static func encodeValue( + _ value: Any, + for keyPath: PartialKeyPath, + to container: inout KeyedEncodingContainer + ) throws { + switch keyPath { + case \Self.foo: + try container.encode(value as! String, forKey: .foo) + case \Self.bar: + try container.encode(value as! Int, forKey: .bar) + default: + break + } + } + + let foo: String + let bar: Int + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.foo = "foo" + partial.bar = 123 + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.foo) == "foo" + expect(decodedValue.bar) == 123 + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + } +} From c24636e39b8da22250b3bb9bf1c93f5ff008dfd6 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Wed, 27 Jan 2021 14:00:29 +0000 Subject: [PATCH 02/42] Add new files to Xcode project --- Partial.xcodeproj/project.pbxproj | 18 ++++++++++++++++++ ...al+Encodable.swift => PartialCodable.swift} | 0 2 files changed, 18 insertions(+) rename Sources/Partial/{Partial+Encodable.swift => PartialCodable.swift} (100%) diff --git a/Partial.xcodeproj/project.pbxproj b/Partial.xcodeproj/project.pbxproj index dcf644f0..1b0024c1 100644 --- a/Partial.xcodeproj/project.pbxproj +++ b/Partial.xcodeproj/project.pbxproj @@ -42,6 +42,13 @@ D9A27B70228CBDD4001530A1 /* PartialConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A27B6C228CBDC5001530A1 /* PartialConvertible.swift */; }; D9C039B1224263610031B393 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9C039AF224263610031B393 /* Nimble.framework */; }; D9C039B4224263610031B393 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9C039B0224263610031B393 /* Quick.framework */; }; + D9C0662325C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; + D9C0662425C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; + D9C0662525C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; + D9C0662625C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; + D9C0663625C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */; }; + D9C0663725C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */; }; + D9C0663825C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */; }; D9E601CF2233E99D00B36B1E /* Partial.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9E601C62233E99D00B36B1E /* Partial.framework */; }; D9E601DE2233EBED00B36B1E /* Partial.swift in Sources */ = {isa = PBXBuildFile; fileRef = D91505C9221E04EB00EB5215 /* Partial.swift */; }; D9E601E02233EBED00B36B1E /* PartialBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D91505CD221E052600EB5215 /* PartialBuilder.swift */; }; @@ -109,6 +116,8 @@ D9A27B6C228CBDC5001530A1 /* PartialConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartialConvertible.swift; sourceTree = ""; }; D9C039AF224263610031B393 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = SOURCE_ROOT; }; D9C039B0224263610031B393 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = SOURCE_ROOT; }; + D9C0662225C1A95A00BD0509 /* PartialCodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialCodable.swift; sourceTree = ""; }; + D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartiallyBuiltTests.swift; sourceTree = ""; }; D9CA4437222FF3CD000E424B /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; }; D9D933B4223492FD00E94AAE /* Partial.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Partial.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D9E601C62233E99D00B36B1E /* Partial.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Partial.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -226,6 +235,7 @@ isa = PBXGroup; children = ( D91505C9221E04EB00EB5215 /* Partial.swift */, + D9C0662225C1A95A00BD0509 /* PartialCodable.swift */, D91505CD221E052600EB5215 /* PartialBuilder.swift */, D9F58EE122CA730B00931D29 /* Subscription.swift */, D9F58EE022CA730B00931D29 /* Weak.swift */, @@ -258,6 +268,7 @@ isa = PBXGroup; children = ( D9651AC622D26A53008DBB0E /* PartialTests.swift */, + D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */, D9651AD022D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift */, D9651ACA22D26EFB008DBB0E /* PartialBuilderTests.swift */, D9651AD422D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift */, @@ -571,6 +582,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D9C0662325C1A95A00BD0509 /* PartialCodable.swift in Sources */, D9F58EE622CA730B00931D29 /* Subscription.swift in Sources */, D91505CA221E04EB00EB5215 /* Partial.swift in Sources */, D9A27B6D228CBDC5001530A1 /* PartialConvertible.swift in Sources */, @@ -586,6 +598,7 @@ files = ( D9651AC022D24673008DBB0E /* StringWrapperWrapper.swift in Sources */, D9651ACB22D2788C008DBB0E /* PartialBuilderTests.swift in Sources */, + D9C0663625C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */, D9651AC322D24678008DBB0E /* StringWrapper.swift in Sources */, D992471922C15D6300A2B079 /* beNilWrappedInOptional.swift in Sources */, D9651AD122D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, @@ -599,6 +612,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D9C0662525C1A95A00BD0509 /* PartialCodable.swift in Sources */, D9F58EE822CA730B00931D29 /* Subscription.swift in Sources */, D9FFA6382235A407005D9A4D /* Partial.swift in Sources */, D9A27B6F228CBDD3001530A1 /* PartialConvertible.swift in Sources */, @@ -612,6 +626,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D9C0662425C1A95A00BD0509 /* PartialCodable.swift in Sources */, D9F58EE722CA730B00931D29 /* Subscription.swift in Sources */, D9E601DE2233EBED00B36B1E /* Partial.swift in Sources */, D9A27B6E228CBDD2001530A1 /* PartialConvertible.swift in Sources */, @@ -627,6 +642,7 @@ files = ( D9651AC122D24673008DBB0E /* StringWrapperWrapper.swift in Sources */, D9651ACC22D2788D008DBB0E /* PartialBuilderTests.swift in Sources */, + D9C0663725C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */, D9651AC422D24678008DBB0E /* StringWrapper.swift in Sources */, D992471A22C15D6500A2B079 /* beNilWrappedInOptional.swift in Sources */, D9651AD222D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, @@ -640,6 +656,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D9C0662625C1A95A00BD0509 /* PartialCodable.swift in Sources */, D9F58EE922CA730B00931D29 /* Subscription.swift in Sources */, D9FFA63B2235A408005D9A4D /* Partial.swift in Sources */, D9A27B70228CBDD4001530A1 /* PartialConvertible.swift in Sources */, @@ -655,6 +672,7 @@ files = ( D9651AC222D24673008DBB0E /* StringWrapperWrapper.swift in Sources */, D9651ACD22D2788E008DBB0E /* PartialBuilderTests.swift in Sources */, + D9C0663825C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */, D9651AC522D24679008DBB0E /* StringWrapper.swift in Sources */, D992471B22C15D6900A2B079 /* beNilWrappedInOptional.swift in Sources */, D9651AD322D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, diff --git a/Sources/Partial/Partial+Encodable.swift b/Sources/Partial/PartialCodable.swift similarity index 100% rename from Sources/Partial/Partial+Encodable.swift rename to Sources/Partial/PartialCodable.swift From 8a99ebbc1c6af9cd520da7654bcf327113eaf2c5 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Wed, 27 Jan 2021 19:00:47 +0000 Subject: [PATCH 03/42] Add support for decoding --- Sources/Partial/Partial.swift | 7 ++++++- Sources/Partial/PartialCodable.swift | 2 ++ .../Tests/PartialCodableTests.swift | 21 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Sources/Partial/Partial.swift b/Sources/Partial/Partial.swift index f67da7c2..4fc91f4f 100644 --- a/Sources/Partial/Partial.swift +++ b/Sources/Partial/Partial.swift @@ -52,7 +52,12 @@ public struct Partial: PartialProtocol, CustomStringConvertible { } } -extension Partial: Encodable where Wrapped: PartialCodable { +extension Partial: Codable where Wrapped: PartialCodable { + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: Wrapped.CodingKey.self) + values = try Wrapped.decodeValuesInContainer(container) + } + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: Wrapped.CodingKey.self) diff --git a/Sources/Partial/PartialCodable.swift b/Sources/Partial/PartialCodable.swift index 6925d76a..69cbfefc 100644 --- a/Sources/Partial/PartialCodable.swift +++ b/Sources/Partial/PartialCodable.swift @@ -4,4 +4,6 @@ public protocol PartialCodable: Codable { associatedtype CodingKey: Swift.CodingKey static func encodeValue(_ value: Any, for keyPath: PartialKeyPath, to container: inout KeyedEncodingContainer) throws + + static func decodeValuesInContainer(_ container: KeyedDecodingContainer) throws -> [PartialKeyPath: Any] } diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/PartialCodableTests.swift index 24930277..e68a31af 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift @@ -9,6 +9,15 @@ final class PartialCodableTests: QuickSpec { override func spec() { describe("PartialCodable") { struct CodableType: Codable, PartialCodable, Hashable { + static func decodeValuesInContainer(_ container: KeyedDecodingContainer) throws -> [PartialKeyPath: Any] { + var values: [PartialKeyPath: Any] = [:] + + values[\Self.foo] = try container.decodeIfPresent(String.self, forKey: .foo) + values[\Self.bar] = try container.decodeIfPresent(Int.self, forKey: .bar) + + return values + } + static func encodeValue( _ value: Any, for keyPath: PartialKeyPath, @@ -63,6 +72,18 @@ final class PartialCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.foo) == "foo" + expect(decodedValue.bar) == 123 + } catch { + fail("Should not throw: \(error)") + } + } } } } From bb1494396693e5869246f13ec02c0f9a6dc3e186 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Wed, 27 Jan 2021 20:08:57 +0000 Subject: [PATCH 04/42] Run all tests on Linux --- Tests/LinuxMain.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 2c74eaa1..cbfbd3af 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -4,9 +4,11 @@ import Quick @testable import PartialTests QCKMain([ - PartialTests.self, Partial_PartialConvertibleTests.self, - PartialBuilderTests.self, PartialBuilder_PartialConvertibleTests.self, PartialBuilderSubscriptionTests.self, + PartialBuilderTests.self, + PartialCodableTests.self, + PartialBuilderSubscriptionTests.self, + PartialTests.self, ]) From 4908a8bc758b9b66a208ddfb37e3c59d805e7eab Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Wed, 27 Jan 2021 20:09:08 +0000 Subject: [PATCH 05/42] Remove `Codable` requirement from `PartialCodable` --- Sources/Partial/PartialCodable.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Partial/PartialCodable.swift b/Sources/Partial/PartialCodable.swift index 69cbfefc..d7380350 100644 --- a/Sources/Partial/PartialCodable.swift +++ b/Sources/Partial/PartialCodable.swift @@ -1,6 +1,6 @@ import Foundation -public protocol PartialCodable: Codable { +public protocol PartialCodable { associatedtype CodingKey: Swift.CodingKey static func encodeValue(_ value: Any, for keyPath: PartialKeyPath, to container: inout KeyedEncodingContainer) throws From 3eb8bbff663f188563ddd9f91d65384477f627de Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Wed, 27 Jan 2021 20:12:02 +0000 Subject: [PATCH 06/42] Add PartiallyBuilt.swift to project --- Partial.xcodeproj/project.pbxproj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Partial.xcodeproj/project.pbxproj b/Partial.xcodeproj/project.pbxproj index 1b0024c1..49bdf50f 100644 --- a/Partial.xcodeproj/project.pbxproj +++ b/Partial.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + D909A5FB25C200850020D21B /* PartiallyBuilt.swift in Sources */ = {isa = PBXBuildFile; fileRef = D909A5FA25C200850020D21B /* PartiallyBuilt.swift */; }; + D909A5FC25C200850020D21B /* PartiallyBuilt.swift in Sources */ = {isa = PBXBuildFile; fileRef = D909A5FA25C200850020D21B /* PartiallyBuilt.swift */; }; + D909A5FD25C200850020D21B /* PartiallyBuilt.swift in Sources */ = {isa = PBXBuildFile; fileRef = D909A5FA25C200850020D21B /* PartiallyBuilt.swift */; }; + D909A5FE25C200850020D21B /* PartiallyBuilt.swift in Sources */ = {isa = PBXBuildFile; fileRef = D909A5FA25C200850020D21B /* PartiallyBuilt.swift */; }; D91505B9221E024900EB5215 /* Partial.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D91505AF221E024900EB5215 /* Partial.framework */; }; D91505C0221E024900EB5215 /* Partial.h in Headers */ = {isa = PBXBuildFile; fileRef = D91505B2221E024900EB5215 /* Partial.h */; settings = {ATTRIBUTES = (Public, ); }; }; D91505CA221E04EB00EB5215 /* Partial.swift in Sources */ = {isa = PBXBuildFile; fileRef = D91505C9221E04EB00EB5215 /* Partial.swift */; }; @@ -98,6 +102,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + D909A5FA25C200850020D21B /* PartiallyBuilt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartiallyBuilt.swift; sourceTree = ""; }; D91505AF221E024900EB5215 /* Partial.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Partial.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D91505B2221E024900EB5215 /* Partial.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Partial.h; sourceTree = ""; }; D91505B3221E024900EB5215 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -238,6 +243,7 @@ D9C0662225C1A95A00BD0509 /* PartialCodable.swift */, D91505CD221E052600EB5215 /* PartialBuilder.swift */, D9F58EE122CA730B00931D29 /* Subscription.swift */, + D909A5FA25C200850020D21B /* PartiallyBuilt.swift */, D9F58EE022CA730B00931D29 /* Weak.swift */, D9A27B6C228CBDC5001530A1 /* PartialConvertible.swift */, D92E76CF229D8A0D003EBC25 /* PartialProtocol.swift */, @@ -583,6 +589,7 @@ buildActionMask = 2147483647; files = ( D9C0662325C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D909A5FB25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE622CA730B00931D29 /* Subscription.swift in Sources */, D91505CA221E04EB00EB5215 /* Partial.swift in Sources */, D9A27B6D228CBDC5001530A1 /* PartialConvertible.swift in Sources */, @@ -613,6 +620,7 @@ buildActionMask = 2147483647; files = ( D9C0662525C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D909A5FD25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE822CA730B00931D29 /* Subscription.swift in Sources */, D9FFA6382235A407005D9A4D /* Partial.swift in Sources */, D9A27B6F228CBDD3001530A1 /* PartialConvertible.swift in Sources */, @@ -627,6 +635,7 @@ buildActionMask = 2147483647; files = ( D9C0662425C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D909A5FC25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE722CA730B00931D29 /* Subscription.swift in Sources */, D9E601DE2233EBED00B36B1E /* Partial.swift in Sources */, D9A27B6E228CBDD2001530A1 /* PartialConvertible.swift in Sources */, @@ -657,6 +666,7 @@ buildActionMask = 2147483647; files = ( D9C0662625C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D909A5FE25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE922CA730B00931D29 /* Subscription.swift in Sources */, D9FFA63B2235A408005D9A4D /* Partial.swift in Sources */, D9A27B70228CBDD4001530A1 /* PartialConvertible.swift in Sources */, From 020ef68952e6395006e14a71fa27762e76398fd1 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 16:18:07 +0000 Subject: [PATCH 07/42] Use function builder based API --- Sources/Partial/Partial.swift | 24 ++++++- Sources/Partial/PartialCodable.swift | 68 ++++++++++++++++++- .../Tests/PartialCodableTests.swift | 26 ++----- 3 files changed, 91 insertions(+), 27 deletions(-) diff --git a/Sources/Partial/Partial.swift b/Sources/Partial/Partial.swift index 4fc91f4f..82195575 100644 --- a/Sources/Partial/Partial.swift +++ b/Sources/Partial/Partial.swift @@ -55,16 +55,36 @@ public struct Partial: PartialProtocol, CustomStringConvertible { extension Partial: Codable where Wrapped: PartialCodable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: Wrapped.CodingKey.self) - values = try Wrapped.decodeValuesInContainer(container) + let collection = Wrapped.keyPathCodingKeyCollection + values = try container + .allKeys + .reduce(into: [PartialKeyPath: Any](), { values, codingKey in + guard let (value, keyPath) = try collection.decode(codingKey, in: container) else { return } + values[keyPath] = value + }) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: Wrapped.CodingKey.self) + let collection = Wrapped.keyPathCodingKeyCollection + try values.forEach { pair in let (keyPath, value) = pair - try Wrapped.encodeValue(value, for: keyPath, to: &container) + try collection.encode(value, forKey: keyPath, to: &container) } } } + +private extension KeyPath where Value: Encodable { + func encode(_ value: Any, forKey codingKey: CodingKey, to container: inout KeyedEncodingContainer< CodingKey>) throws { + try container.encode(value as! Value, forKey: codingKey) + } +} + +extension KeyPath { + var value: Value.Type { + Value.self + } +} diff --git a/Sources/Partial/PartialCodable.swift b/Sources/Partial/PartialCodable.swift index d7380350..d94aded3 100644 --- a/Sources/Partial/PartialCodable.swift +++ b/Sources/Partial/PartialCodable.swift @@ -1,9 +1,71 @@ import Foundation public protocol PartialCodable { - associatedtype CodingKey: Swift.CodingKey + associatedtype CodingKey: Swift.CodingKey & Equatable - static func encodeValue(_ value: Any, for keyPath: PartialKeyPath, to container: inout KeyedEncodingContainer) throws + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { get } +} + +public struct KeyPathCodingKeyCollection { + private typealias ValueEncoder = (_ value: Any, _ keyPath: PartialKeyPath ,_ container: inout KeyedEncodingContainer) throws -> Void + private typealias ValueDecoder = (_ codingKey: CodingKey,_ container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? + + private var valueEncoder: ValueEncoder = { _, _, _ in } + private var valueDecoder: ValueDecoder = { _, _ in nil } + + func encode(_ value: Any, forKey keyPath: PartialKeyPath, to container: inout KeyedEncodingContainer) throws { + try valueEncoder(value, keyPath, &container) + } + + func decode(_ codingKey: CodingKey, in container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? { + try valueDecoder(codingKey, container) + } + + public mutating func addPair(keyPath: KeyPath, codingKey: CodingKey) { + valueEncoder = { [valueEncoder] value, keyPathToEncode, container in + if keyPathToEncode == keyPath { + guard let value = value as? Value else { + // TODO: Throw + return + } + + try container.encode(value, forKey: codingKey) + } else { + try valueEncoder(value, keyPathToEncode, &container) + } + } + + valueDecoder = { [valueDecoder] codingKeyToDecode, container in + if codingKeyToDecode == codingKey { + if let decodedValue = try container.decodeIfPresent(Value.self, forKey: codingKey) { + return (decodedValue, keyPath) + } else { + return nil + } + } else { + return try valueDecoder(codingKeyToDecode, container) + } + } + } +} + +@_functionBuilder +public final class KeyPathCodingKeyCollectionBuilder { + static func buildBlock( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + return collection + } - static func decodeValuesInContainer(_ container: KeyedDecodingContainer) throws -> [PartialKeyPath: Any] + static func buildBlock( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + return collection + } } diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/PartialCodableTests.swift index e68a31af..a516e98f 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift @@ -9,28 +9,10 @@ final class PartialCodableTests: QuickSpec { override func spec() { describe("PartialCodable") { struct CodableType: Codable, PartialCodable, Hashable { - static func decodeValuesInContainer(_ container: KeyedDecodingContainer) throws -> [PartialKeyPath: Any] { - var values: [PartialKeyPath: Any] = [:] - - values[\Self.foo] = try container.decodeIfPresent(String.self, forKey: .foo) - values[\Self.bar] = try container.decodeIfPresent(Int.self, forKey: .bar) - - return values - } - - static func encodeValue( - _ value: Any, - for keyPath: PartialKeyPath, - to container: inout KeyedEncodingContainer - ) throws { - switch keyPath { - case \Self.foo: - try container.encode(value as! String, forKey: .foo) - case \Self.bar: - try container.encode(value as! Int, forKey: .bar) - default: - break - } + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.foo, CodingKeys.foo) + (\Self.bar, CodingKeys.bar) } let foo: String From 6129ec8638c0529577784906f8988af257649ca4 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 16:37:02 +0000 Subject: [PATCH 08/42] Remove unused extensions --- Sources/Partial/Partial.swift | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Sources/Partial/Partial.swift b/Sources/Partial/Partial.swift index 82195575..9f308b37 100644 --- a/Sources/Partial/Partial.swift +++ b/Sources/Partial/Partial.swift @@ -76,15 +76,3 @@ extension Partial: Codable where Wrapped: PartialCodable { } } } - -private extension KeyPath where Value: Encodable { - func encode(_ value: Any, forKey codingKey: CodingKey, to container: inout KeyedEncodingContainer< CodingKey>) throws { - try container.encode(value as! Value, forKey: codingKey) - } -} - -extension KeyPath { - var value: Value.Type { - Value.self - } -} From 3d77a2678cde4ab5b4997c6b55c08bc656c9438a Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 16:37:06 +0000 Subject: [PATCH 09/42] Fix code style --- Sources/Partial/PartialCodable.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Partial/PartialCodable.swift b/Sources/Partial/PartialCodable.swift index d94aded3..2a0cba6b 100644 --- a/Sources/Partial/PartialCodable.swift +++ b/Sources/Partial/PartialCodable.swift @@ -7,7 +7,7 @@ public protocol PartialCodable { } public struct KeyPathCodingKeyCollection { - private typealias ValueEncoder = (_ value: Any, _ keyPath: PartialKeyPath ,_ container: inout KeyedEncodingContainer) throws -> Void + private typealias ValueEncoder = (_ value: Any, _ keyPath: PartialKeyPath, _ container: inout KeyedEncodingContainer) throws -> Void private typealias ValueDecoder = (_ codingKey: CodingKey,_ container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? private var valueEncoder: ValueEncoder = { _, _, _ in } From 378842b6f246f15af93d03dd306f387ba9d9cbdf Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 17:00:39 +0000 Subject: [PATCH 10/42] Improve encoding/decoding performance --- Sources/Partial/PartialCodable.swift | 46 ++++++++++++---------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/Sources/Partial/PartialCodable.swift b/Sources/Partial/PartialCodable.swift index 2a0cba6b..9aedeed8 100644 --- a/Sources/Partial/PartialCodable.swift +++ b/Sources/Partial/PartialCodable.swift @@ -1,56 +1,48 @@ import Foundation public protocol PartialCodable { - associatedtype CodingKey: Swift.CodingKey & Equatable + associatedtype CodingKey: Swift.CodingKey & Hashable static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { get } } -public struct KeyPathCodingKeyCollection { - private typealias ValueEncoder = (_ value: Any, _ keyPath: PartialKeyPath, _ container: inout KeyedEncodingContainer) throws -> Void - private typealias ValueDecoder = (_ codingKey: CodingKey,_ container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? +public struct KeyPathCodingKeyCollection { + private typealias Encoder = (_ value: Any, _ container: inout KeyedEncodingContainer) throws -> Void + private typealias Decoder = (_ codingKey: CodingKey, _ container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? - private var valueEncoder: ValueEncoder = { _, _, _ in } - private var valueDecoder: ValueDecoder = { _, _ in nil } + private var encoders: [PartialKeyPath: Encoder] = [:] + private var decoders: [CodingKey: Decoder] = [:] func encode(_ value: Any, forKey keyPath: PartialKeyPath, to container: inout KeyedEncodingContainer) throws { - try valueEncoder(value, keyPath, &container) + try encoders[keyPath]?(value, &container) } func decode(_ codingKey: CodingKey, in container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? { - try valueDecoder(codingKey, container) + try decoders[codingKey]?(codingKey, container) } public mutating func addPair(keyPath: KeyPath, codingKey: CodingKey) { - valueEncoder = { [valueEncoder] value, keyPathToEncode, container in - if keyPathToEncode == keyPath { - guard let value = value as? Value else { - // TODO: Throw - return - } - - try container.encode(value, forKey: codingKey) - } else { - try valueEncoder(value, keyPathToEncode, &container) + encoders[keyPath] = { value, container in + guard let value = value as? Value else { + // TODO: Throw + return } + + try container.encode(value, forKey: codingKey) } - valueDecoder = { [valueDecoder] codingKeyToDecode, container in - if codingKeyToDecode == codingKey { - if let decodedValue = try container.decodeIfPresent(Value.self, forKey: codingKey) { - return (decodedValue, keyPath) - } else { - return nil - } + decoders[codingKey] = { codingKey, container in + if let decodedValue = try container.decodeIfPresent(Value.self, forKey: codingKey) { + return (decodedValue, keyPath) } else { - return try valueDecoder(codingKeyToDecode, container) + return nil } } } } @_functionBuilder -public final class KeyPathCodingKeyCollectionBuilder { +public final class KeyPathCodingKeyCollectionBuilder { static func buildBlock( _ pairA: (keyPath: KeyPath, codingKey: CodingKey) ) -> KeyPathCodingKeyCollection { From 05e93aadd65bade7907ce9136a805fa136b2e5db Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 17:21:30 +0000 Subject: [PATCH 11/42] Split Codable types in to own files --- .../KeyPathCodingKeyCollection.swift} | 29 ------------------- .../KeyPathCodingKeyCollectionBuilder.swift | 20 +++++++++++++ Sources/Partial/Codable/PartialCodable.swift | 28 ++++++++++++++++++ 3 files changed, 48 insertions(+), 29 deletions(-) rename Sources/Partial/{PartialCodable.swift => Codable/KeyPathCodingKeyCollection.swift} (55%) create mode 100644 Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift create mode 100644 Sources/Partial/Codable/PartialCodable.swift diff --git a/Sources/Partial/PartialCodable.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift similarity index 55% rename from Sources/Partial/PartialCodable.swift rename to Sources/Partial/Codable/KeyPathCodingKeyCollection.swift index 9aedeed8..2cae22ca 100644 --- a/Sources/Partial/PartialCodable.swift +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift @@ -1,11 +1,3 @@ -import Foundation - -public protocol PartialCodable { - associatedtype CodingKey: Swift.CodingKey & Hashable - - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { get } -} - public struct KeyPathCodingKeyCollection { private typealias Encoder = (_ value: Any, _ container: inout KeyedEncodingContainer) throws -> Void private typealias Decoder = (_ codingKey: CodingKey, _ container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? @@ -40,24 +32,3 @@ public struct KeyPathCodingKeyCollection { - static func buildBlock( - _ pairA: (keyPath: KeyPath, codingKey: CodingKey) - ) -> KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() - collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) - return collection - } - - static func buildBlock( - _ pairA: (keyPath: KeyPath, codingKey: CodingKey), - _ pairB: (keyPath: KeyPath, codingKey: CodingKey) - ) -> KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() - collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) - collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) - return collection - } -} diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift new file mode 100644 index 00000000..99ce5c1e --- /dev/null +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift @@ -0,0 +1,20 @@ +@_functionBuilder +public final class KeyPathCodingKeyCollectionBuilder { + static func buildBlock( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + return collection + } + + static func buildBlock( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + return collection + } +} diff --git a/Sources/Partial/Codable/PartialCodable.swift b/Sources/Partial/Codable/PartialCodable.swift new file mode 100644 index 00000000..1c3da028 --- /dev/null +++ b/Sources/Partial/Codable/PartialCodable.swift @@ -0,0 +1,28 @@ +/// A type that can provide a map of key paths and coding keys to enable +/// `Codable` conformance to `Partial`. +public protocol PartialCodable { + /// The `CodingKey` type used to encode and decode values. + /// + /// This type has the extra requirement of being `Hashable`. This conformance is + /// synthesized when using a `Hashable` type as the `RawValue` of a `CodingKey` `enum`. + associatedtype CodingKey: Swift.CodingKey & Hashable + + /// Generate and return a collection of key paths and coding key maps. + /// + /// The `KeyPathCodingKeyCollectionBuilder` result builder is provided to simplify the + /// implementation of this property, for example: + /// + /// ```swift + /// struct CodableType: Codable, PartialCodable, Hashable { + /// @KeyPathCodingKeyCollectionBuilder + /// static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + /// (\Self.foo, CodingKeys.foo) + /// (\Self.bar, CodingKeys.bar) + /// } + /// + /// let foo: String + /// let bar: Int + ///} + /// ``` + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { get } +} From 66955f5cdce8a57d237012d2edc90c8ba1b51a81 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 17:23:11 +0000 Subject: [PATCH 12/42] Replace `foo`/`bar` --- Sources/Partial/Codable/PartialCodable.swift | 8 ++++---- .../Tests/PartialCodableTests.swift | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Sources/Partial/Codable/PartialCodable.swift b/Sources/Partial/Codable/PartialCodable.swift index 1c3da028..070a5d5b 100644 --- a/Sources/Partial/Codable/PartialCodable.swift +++ b/Sources/Partial/Codable/PartialCodable.swift @@ -16,12 +16,12 @@ public protocol PartialCodable { /// struct CodableType: Codable, PartialCodable, Hashable { /// @KeyPathCodingKeyCollectionBuilder /// static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - /// (\Self.foo, CodingKeys.foo) - /// (\Self.bar, CodingKeys.bar) + /// (\Self.stringValue, CodingKeys.stringValue) + /// (\Self.intValue, CodingKeys.intValue) /// } /// - /// let foo: String - /// let bar: Int + /// let stringValue: String + /// let intValue: Int ///} /// ``` static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { get } diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/PartialCodableTests.swift index a516e98f..6d0e4f23 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift @@ -11,12 +11,12 @@ final class PartialCodableTests: QuickSpec { struct CodableType: Codable, PartialCodable, Hashable { @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - (\Self.foo, CodingKeys.foo) - (\Self.bar, CodingKeys.bar) + (\Self.stringValue, CodingKeys.foo) + (\Self.intValue, CodingKeys.intValue) } - let foo: String - let bar: Int + let stringValue: String + let intValue: Int } var partial: Partial! @@ -27,8 +27,8 @@ final class PartialCodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.foo = "foo" - partial.bar = 123 + partial.stringValue = "foo" + partial.intValue = 123 } context("the encoded data") { @@ -48,8 +48,8 @@ final class PartialCodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.foo) == "foo" - expect(decodedValue.bar) == 123 + expect(decodedValue.stringValue) == "foo" + expect(decodedValue.intValue) == 123 } catch { fail("Should not throw: \(error)") } @@ -60,8 +60,8 @@ final class PartialCodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.foo) == "foo" - expect(decodedValue.bar) == 123 + expect(decodedValue.stringValue) == "foo" + expect(decodedValue.intValue) == 123 } catch { fail("Should not throw: \(error)") } From 08b01a17a2cd96709fc7913b8a7185b0f17bfbc6 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 18:13:35 +0000 Subject: [PATCH 13/42] Fix test compilation --- Tests/PartialTests/Tests/PartialCodableTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/PartialCodableTests.swift index 6d0e4f23..b29ce794 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift @@ -11,7 +11,7 @@ final class PartialCodableTests: QuickSpec { struct CodableType: Codable, PartialCodable, Hashable { @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - (\Self.stringValue, CodingKeys.foo) + (\Self.stringValue, CodingKeys.stringValue) (\Self.intValue, CodingKeys.intValue) } From 4f8576e0b9ad64b0404af9279dd58eb46159a1e3 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 18:16:18 +0000 Subject: [PATCH 14/42] Generate KeyPathCodingKeyCollectionBuilder --- .../KeyPathCodingKeyCollectionBuilder.swift | 534 +++++++++++++++++- ...eyPathCodingKeyCollectionBuilder.swift.gyb | 81 +++ ...erate-KeyPathCodingKeyCollectionBuilder.sh | 4 + 3 files changed, 617 insertions(+), 2 deletions(-) create mode 100644 Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb create mode 100755 scripts/generate-KeyPathCodingKeyCollectionBuilder.sh diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift index 99ce5c1e..81a23bcf 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift @@ -1,6 +1,532 @@ +#if swift(>=5.4) +@resultBuilder +public final class KeyPathCodingKeyCollectionBuilder { + static func buildBlock< + ValueA: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable, + ValueN: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey), + _ pairN: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + collection.addPair(keyPath: pairN.keyPath, codingKey: pairN.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable, + ValueN: Codable, + ValueO: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey), + _ pairN: (keyPath: KeyPath, codingKey: CodingKey), + _ pairO: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + collection.addPair(keyPath: pairN.keyPath, codingKey: pairN.codingKey) + collection.addPair(keyPath: pairO.keyPath, codingKey: pairO.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable, + ValueN: Codable, + ValueO: Codable, + ValueP: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey), + _ pairN: (keyPath: KeyPath, codingKey: CodingKey), + _ pairO: (keyPath: KeyPath, codingKey: CodingKey), + _ pairP: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + collection.addPair(keyPath: pairN.keyPath, codingKey: pairN.codingKey) + collection.addPair(keyPath: pairO.keyPath, codingKey: pairO.codingKey) + collection.addPair(keyPath: pairP.keyPath, codingKey: pairP.codingKey) + return collection + } +} +#elseif swift(>=5.1) @_functionBuilder public final class KeyPathCodingKeyCollectionBuilder { - static func buildBlock( + static func buildBlock< + ValueA: Codable + >( _ pairA: (keyPath: KeyPath, codingKey: CodingKey) ) -> KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() @@ -8,7 +534,10 @@ public final class KeyPathCodingKeyCollectionBuilder( + static func buildBlock< + ValueA: Codable, + ValueB: Codable + >( _ pairA: (keyPath: KeyPath, codingKey: CodingKey), _ pairB: (keyPath: KeyPath, codingKey: CodingKey) ) -> KeyPathCodingKeyCollection { @@ -18,3 +547,4 @@ public final class KeyPathCodingKeyCollectionBuilder=5.4) +@resultBuilder +public final class KeyPathCodingKeyCollectionBuilder { +% # 16 is arbitrary, but there has to be a limit somewhere +% parameterCountList = range(16) +% for parameterCount in parameterCountList: +% parametersRange = range(parameterCount + 1) + static func buildBlock< +% for characterIndex in parametersRange: +% isLast = characterIndex == parametersRange[-1] +% character = string.ascii_uppercase[characterIndex] +% if isLast: + Value${character}: Codable +% else: + Value${character}: Codable, +% end +% end + >( +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] +% isLast = characterIndex == parametersRange[-1] +% if isLast: + _ pair${character}: (keyPath: KeyPath, codingKey: CodingKey) +% else: + _ pair${character}: (keyPath: KeyPath, codingKey: CodingKey), +% end +% end + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + collection.addPair(keyPath: pair${character}.keyPath, codingKey: pair${character}.codingKey) +% end + return collection + } +% if parameterCount != parameterCountList[-1]: + +% end +% end +} +#elseif swift(>=5.1) +@_functionBuilder +public final class KeyPathCodingKeyCollectionBuilder { +% parameterCountList = range(2) +% for parameterCount in parameterCountList: +% parametersRange = range(parameterCount + 1) + static func buildBlock< +% for characterIndex in parametersRange: +% isLast = characterIndex == parametersRange[-1] +% character = string.ascii_uppercase[characterIndex] +% if isLast: + Value${character}: Codable +% else: + Value${character}: Codable, +% end +% end + >( +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] +% isLast = characterIndex == parametersRange[-1] +% if isLast: + _ pair${character}: (keyPath: KeyPath, codingKey: CodingKey) +% else: + _ pair${character}: (keyPath: KeyPath, codingKey: CodingKey), +% end +% end + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + collection.addPair(keyPath: pair${character}.keyPath, codingKey: pair${character}.codingKey) +% end + return collection + } +% if parameterCount != parameterCountList[-1]: + +% end +% end +} +#endif diff --git a/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh b/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh new file mode 100755 index 00000000..83a65a87 --- /dev/null +++ b/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +GYB_FILE="Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift" +gyb --line-directive '' -o "$GYB_FILE" "$GYB_FILE.gyb" From 23a196522c9507f22e55ef5ed1a52a347358e12c Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 18:31:39 +0000 Subject: [PATCH 15/42] Generate tests --- .../Tests/PartialCodableTests.swift | 1522 ++++++++++++++++- .../Tests/PartialCodableTests.swift.gyb | 90 + ...erate-KeyPathCodingKeyCollectionBuilder.sh | 7 +- 3 files changed, 1582 insertions(+), 37 deletions(-) create mode 100644 Tests/PartialTests/Tests/PartialCodableTests.swift.gyb diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/PartialCodableTests.swift index b29ce794..59b316c9 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift @@ -8,62 +8,1514 @@ import Partial final class PartialCodableTests: QuickSpec { override func spec() { describe("PartialCodable") { - struct CodableType: Codable, PartialCodable, Hashable { - @KeyPathCodingKeyCollectionBuilder - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - (\Self.stringValue, CodingKeys.stringValue) - (\Self.intValue, CodingKeys.intValue) + context("with 1 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + } + + let stringA: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 2 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + } + + let stringA: String + let stringB: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 3 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + } + + let stringA: String + let stringB: String + let stringC: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() } - let stringValue: String - let intValue: Int + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 4 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + } catch { + fail("Should not throw: \(error)") + } + } + } + } } + context("with 5 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + } - var partial: Partial! + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + } - beforeEach { - partial = Partial() + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + } catch { + fail("Should not throw: \(error)") + } + } + } + } } + context("with 6 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + } + + var partial: Partial! - context("with complete value") { beforeEach { - partial.stringValue = "foo" - partial.intValue = 123 + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 7 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String } - context("the encoded data") { - var encodedData: Data! + var partial: Partial! + + beforeEach { + partial = Partial() + } + context("with complete value") { beforeEach { - let encoder = JSONEncoder() - encodedData = try? encoder.encode(partial) + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" } - it("should not be nil") { - expect(encodedData).toNot(beNil()) + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + } catch { + fail("Should not throw: \(error)") + } + } } + } + } + context("with 8 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + } - it("should be usable to decode Wrapped") { - do { - let decoder = JSONDecoder() - let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + var partial: Partial! - expect(decodedValue.stringValue) == "foo" - expect(decodedValue.intValue) == 123 - } catch { - fail("Should not throw: \(error)") + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + } catch { + fail("Should not throw: \(error)") + } } } + } + } + context("with 9 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 10 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 11 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 12 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 13 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 14 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + (\Self.stringN, CodingKeys.stringN) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + let stringN: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + partial.stringN = "Value N" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 15 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + (\Self.stringN, CodingKeys.stringN) + (\Self.stringO, CodingKeys.stringO) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + let stringN: String + let stringO: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + partial.stringN = "Value N" + partial.stringO = "Value O" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 16 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + (\Self.stringN, CodingKeys.stringN) + (\Self.stringO, CodingKeys.stringO) + (\Self.stringP, CodingKeys.stringP) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + let stringN: String + let stringO: String + let stringP: String + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + partial.stringN = "Value N" + partial.stringO = "Value O" + partial.stringP = "Value P" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" + } catch { + fail("Should not throw: \(error)") + } + } - it("should be usable to decode Partial") { - do { - let decoder = JSONDecoder() - let decodedValue = try decoder.decode(Partial.self, from: encodedData) + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringValue) == "foo" - expect(decodedValue.intValue) == 123 - } catch { - fail("Should not throw: \(error)") + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" + } catch { + fail("Should not throw: \(error)") + } } } } diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb new file mode 100644 index 00000000..2f1076e6 --- /dev/null +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb @@ -0,0 +1,90 @@ +% import string +import Quick +import Nimble +import Foundation + +@testable +import Partial + +final class PartialCodableTests: QuickSpec { + override func spec() { + describe("PartialCodable") { +% parameterCountList = range(16) +% for parameterCount in parameterCountList: +% parametersRange = range(parameterCount + 1) + context("with ${parameterCount + 1} property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + (\Self.string${character}, CodingKeys.string${character}) +% end + } + +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + let string${character}: String +% end + } + + var partial: Partial! + + beforeEach { + partial = Partial() + } + + context("with complete value") { + beforeEach { +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + partial.string${character} = "Value ${character}" +% end + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + expect(decodedValue.string${character}) == "Value ${character}" +% end + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + expect(decodedValue.string${character}) == "Value ${character}" +% end + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } +% end + } + } +} diff --git a/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh b/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh index 83a65a87..c6934002 100755 --- a/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh +++ b/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh @@ -1,4 +1,7 @@ #!/bin/sh -GYB_FILE="Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift" -gyb --line-directive '' -o "$GYB_FILE" "$GYB_FILE.gyb" +KeyPathCodingKeyCollectionBuilder_FILE="Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift" +PartialCodableTests_FILE="Tests/PartialTests/Tests/PartialCodableTests.swift" + +gyb --line-directive '' -o "$KeyPathCodingKeyCollectionBuilder_FILE" "$KeyPathCodingKeyCollectionBuilder_FILE.gyb" +gyb --line-directive '' -o "$PartialCodableTests_FILE" "$PartialCodableTests_FILE.gyb" From a771e36580130053756ae137f536ce196963da19 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 18:35:57 +0000 Subject: [PATCH 16/42] Check GYB has been run --- .github/workflows/tests.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 85ce8e05..95623596 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -130,3 +130,17 @@ jobs: - name: swift test run: swift test + + check-gyb-run: + name: Check GYB has been run + runs-on: macOS-latest + steps: + - uses: actions/checkout@v2 + + - name: Install GYB + run: brew install nshipster/formulae/gyb + + - run: ./scripts/generate-KeyPathCodingKeyCollectionBuilder.sh + + - name: Check GYB was run before commit + run: git diff --exit-code From 5640c608692eda57bdd4f9795b13c8b3c90d57d5 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 19:16:06 +0000 Subject: [PATCH 17/42] Add new files to Xcode project --- Partial.xcodeproj/project.pbxproj | 60 +++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/Partial.xcodeproj/project.pbxproj b/Partial.xcodeproj/project.pbxproj index 49bdf50f..1fd31461 100644 --- a/Partial.xcodeproj/project.pbxproj +++ b/Partial.xcodeproj/project.pbxproj @@ -44,12 +44,23 @@ D9A27B6E228CBDD2001530A1 /* PartialConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A27B6C228CBDC5001530A1 /* PartialConvertible.swift */; }; D9A27B6F228CBDD3001530A1 /* PartialConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A27B6C228CBDC5001530A1 /* PartialConvertible.swift */; }; D9A27B70228CBDD4001530A1 /* PartialConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A27B6C228CBDC5001530A1 /* PartialConvertible.swift */; }; + D9A4E47425D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47025D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift */; }; + D9A4E47525D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47025D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift */; }; + D9A4E47625D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47025D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift */; }; + D9A4E47725D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47025D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift */; }; + D9A4E47C25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47225D85C8E00F3E6D9 /* PartialCodable.swift */; }; + D9A4E47D25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47225D85C8E00F3E6D9 /* PartialCodable.swift */; }; + D9A4E47E25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47225D85C8E00F3E6D9 /* PartialCodable.swift */; }; + D9A4E47F25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47225D85C8E00F3E6D9 /* PartialCodable.swift */; }; + D9A4E48025D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */; }; + D9A4E48125D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */; }; + D9A4E48225D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */; }; + D9A4E48325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */; }; + D9A4E48925D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */; }; + D9A4E48A25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */; }; + D9A4E48B25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */; }; D9C039B1224263610031B393 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9C039AF224263610031B393 /* Nimble.framework */; }; D9C039B4224263610031B393 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9C039B0224263610031B393 /* Quick.framework */; }; - D9C0662325C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; - D9C0662425C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; - D9C0662525C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; - D9C0662625C1A95A00BD0509 /* PartialCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0662225C1A95A00BD0509 /* PartialCodable.swift */; }; D9C0663625C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */; }; D9C0663725C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */; }; D9C0663825C1A97400BD0509 /* PartiallyBuiltTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */; }; @@ -119,9 +130,14 @@ D9651AD422D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PartialBuilder+PartialConvertibleTests.swift"; sourceTree = ""; }; D992471422C15D1800A2B079 /* beNilWrappedInOptional.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = beNilWrappedInOptional.swift; sourceTree = ""; }; D9A27B6C228CBDC5001530A1 /* PartialConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartialConvertible.swift; sourceTree = ""; }; + D9A4E47025D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyPathCodingKeyCollectionBuilder.swift; sourceTree = ""; }; + D9A4E47125D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift.gyb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = KeyPathCodingKeyCollectionBuilder.swift.gyb; sourceTree = ""; }; + D9A4E47225D85C8E00F3E6D9 /* PartialCodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialCodable.swift; sourceTree = ""; }; + D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyPathCodingKeyCollection.swift; sourceTree = ""; }; + D9A4E48425D85CC700F3E6D9 /* PartialCodableTests.swift.gyb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PartialCodableTests.swift.gyb; sourceTree = ""; }; + D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialCodableTests.swift; sourceTree = ""; }; D9C039AF224263610031B393 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = SOURCE_ROOT; }; D9C039B0224263610031B393 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = Carthage/Build/iOS/Quick.framework; sourceTree = SOURCE_ROOT; }; - D9C0662225C1A95A00BD0509 /* PartialCodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialCodable.swift; sourceTree = ""; }; D9C0663525C1A97400BD0509 /* PartiallyBuiltTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartiallyBuiltTests.swift; sourceTree = ""; }; D9CA4437222FF3CD000E424B /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; }; D9D933B4223492FD00E94AAE /* Partial.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Partial.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -239,8 +255,8 @@ D930CF9322B0058A00121F2B /* Partial */ = { isa = PBXGroup; children = ( + D9A4E46F25D85C8E00F3E6D9 /* Codable */, D91505C9221E04EB00EB5215 /* Partial.swift */, - D9C0662225C1A95A00BD0509 /* PartialCodable.swift */, D91505CD221E052600EB5215 /* PartialBuilder.swift */, D9F58EE122CA730B00931D29 /* Subscription.swift */, D909A5FA25C200850020D21B /* PartiallyBuilt.swift */, @@ -278,6 +294,8 @@ D9651AD022D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift */, D9651ACA22D26EFB008DBB0E /* PartialBuilderTests.swift */, D9651AD422D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift */, + D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */, + D9A4E48425D85CC700F3E6D9 /* PartialCodableTests.swift.gyb */, D9F58ED822CA72F400931D29 /* PartialBuilderSubscriptionTests.swift */, ); path = Tests; @@ -291,6 +309,17 @@ path = Matchers; sourceTree = ""; }; + D9A4E46F25D85C8E00F3E6D9 /* Codable */ = { + isa = PBXGroup; + children = ( + D9A4E47025D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift */, + D9A4E47125D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift.gyb */, + D9A4E47225D85C8E00F3E6D9 /* PartialCodable.swift */, + D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */, + ); + path = Codable; + sourceTree = ""; + }; D9C039AE224263140031B393 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -588,12 +617,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D9C0662325C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D9A4E48025D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */, + D9A4E47425D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */, D909A5FB25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE622CA730B00931D29 /* Subscription.swift in Sources */, D91505CA221E04EB00EB5215 /* Partial.swift in Sources */, D9A27B6D228CBDC5001530A1 /* PartialConvertible.swift in Sources */, D91505CE221E052600EB5215 /* PartialBuilder.swift in Sources */, + D9A4E47C25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */, D9F58EE222CA730B00931D29 /* Weak.swift in Sources */, D92E76D0229D8A0D003EBC25 /* PartialProtocol.swift in Sources */, ); @@ -611,6 +642,7 @@ D9651AD122D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, D9651AD522D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift in Sources */, D9F58EDA22CA72F400931D29 /* PartialBuilderSubscriptionTests.swift in Sources */, + D9A4E48925D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */, D9651AC722D26A53008DBB0E /* PartialTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -619,12 +651,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D9C0662525C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D9A4E48225D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */, + D9A4E47625D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */, D909A5FD25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE822CA730B00931D29 /* Subscription.swift in Sources */, D9FFA6382235A407005D9A4D /* Partial.swift in Sources */, D9A27B6F228CBDD3001530A1 /* PartialConvertible.swift in Sources */, D9FFA63A2235A407005D9A4D /* PartialBuilder.swift in Sources */, + D9A4E47E25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */, D9F58EE422CA730B00931D29 /* Weak.swift in Sources */, D92E76D2229D8A67003EBC25 /* PartialProtocol.swift in Sources */, ); @@ -634,12 +668,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D9C0662425C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D9A4E48125D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */, + D9A4E47525D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */, D909A5FC25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE722CA730B00931D29 /* Subscription.swift in Sources */, D9E601DE2233EBED00B36B1E /* Partial.swift in Sources */, D9A27B6E228CBDD2001530A1 /* PartialConvertible.swift in Sources */, D9E601E02233EBED00B36B1E /* PartialBuilder.swift in Sources */, + D9A4E47D25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */, D9F58EE322CA730B00931D29 /* Weak.swift in Sources */, D92E76D1229D8A66003EBC25 /* PartialProtocol.swift in Sources */, ); @@ -657,6 +693,7 @@ D9651AD222D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, D9651AD622D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift in Sources */, D9F58EDB22CA72F400931D29 /* PartialBuilderSubscriptionTests.swift in Sources */, + D9A4E48A25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */, D9651AC822D26A53008DBB0E /* PartialTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -665,12 +702,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D9C0662625C1A95A00BD0509 /* PartialCodable.swift in Sources */, + D9A4E48325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */, + D9A4E47725D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift in Sources */, D909A5FE25C200850020D21B /* PartiallyBuilt.swift in Sources */, D9F58EE922CA730B00931D29 /* Subscription.swift in Sources */, D9FFA63B2235A408005D9A4D /* Partial.swift in Sources */, D9A27B70228CBDD4001530A1 /* PartialConvertible.swift in Sources */, D9FFA63D2235A408005D9A4D /* PartialBuilder.swift in Sources */, + D9A4E47F25D85C8E00F3E6D9 /* PartialCodable.swift in Sources */, D9F58EE522CA730B00931D29 /* Weak.swift in Sources */, D92E76D3229D8A67003EBC25 /* PartialProtocol.swift in Sources */, ); @@ -688,6 +727,7 @@ D9651AD322D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, D9651AD722D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift in Sources */, D9F58EDC22CA72F400931D29 /* PartialBuilderSubscriptionTests.swift in Sources */, + D9A4E48B25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */, D9651AC922D26A53008DBB0E /* PartialTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; From 592c3c8b7d99e41809c806d4f44b74dbe2e50054 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 20:15:33 +0000 Subject: [PATCH 18/42] Fix tests on Swift < 5.1 --- Tests/PartialTests/Tests/PartiallyBuiltTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/PartialTests/Tests/PartiallyBuiltTests.swift b/Tests/PartialTests/Tests/PartiallyBuiltTests.swift index db419ec7..7ea385e0 100644 --- a/Tests/PartialTests/Tests/PartiallyBuiltTests.swift +++ b/Tests/PartialTests/Tests/PartiallyBuiltTests.swift @@ -1,3 +1,4 @@ +#if swift(>=5.1) import Quick import Nimble @@ -47,3 +48,4 @@ final class PartiallyBuiltTests: QuickSpec { } } +#endif From dad66da8943e45752ed7896c5fd00dca6c7daf0d Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 23:42:52 +0000 Subject: [PATCH 19/42] Fix various linting issues --- .../Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift | 2 ++ .../Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb | 2 ++ Sources/Partial/PartialBuilder.swift | 4 ++-- Tests/PartialTests/Tests/PartialCodableTests.swift | 2 ++ Tests/PartialTests/Tests/PartialCodableTests.swift.gyb | 2 ++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift index 81a23bcf..933cecb6 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift @@ -1,3 +1,5 @@ +// This file is generated. Do not edit it. +// swiftlint:disable function_parameter_count file_length type_body_length #if swift(>=5.4) @resultBuilder public final class KeyPathCodingKeyCollectionBuilder { diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb index 592971aa..f798b13f 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb @@ -1,4 +1,6 @@ % import string +// This file is generated. Do not edit it. +// swiftlint:disable function_parameter_count file_length type_body_length #if swift(>=5.4) @resultBuilder public final class KeyPathCodingKeyCollectionBuilder { diff --git a/Sources/Partial/PartialBuilder.swift b/Sources/Partial/PartialBuilder.swift index 28a4331a..e52ab353 100644 --- a/Sources/Partial/PartialBuilder.swift +++ b/Sources/Partial/PartialBuilder.swift @@ -60,7 +60,7 @@ open class PartialBuilder: PartialProtocol, CustomStringConvertible { /// A collection of objects wrapping closures that will be notified when a change to a key path occurs private var keyPathSubscriptions: [PartialKeyPath: Set>] = [:] - + private var attachedSubscription: Subscription? /// Create an empty `PartialBuilder`. @@ -148,7 +148,7 @@ open class PartialBuilder: PartialProtocol, CustomStringConvertible { keyPathSubscriptions[keyPath]?.forEach { $0.wrapped?.notifyOfRemovable(oldValue: oldValue) } allChangesSubscriptions.forEach { $0.wrapped?.updateListener(keyPath, self) } } - + /// Creates a `PartialBuilder` for any `PartialConvertable` field in the type. It will automatically subscribe the original `PartialBuilder` to get updates made to the field's builder. /// /// - Parameter for: The `KeyPath` to create a `PartialBuilder` for. diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/PartialCodableTests.swift index 59b316c9..6f617e2e 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift @@ -1,3 +1,5 @@ +// This file is generated. Do not edit it. +// swiftlint:disable cyclomatic_complexity import Quick import Nimble import Foundation diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb index 2f1076e6..5fbb031c 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb @@ -1,4 +1,6 @@ % import string +// This file is generated. Do not edit it. +// swiftlint:disable cyclomatic_complexity import Quick import Nimble import Foundation From 3814dd722a249bbe9b9c830c0289d3a19afbf7b7 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 23:53:55 +0000 Subject: [PATCH 20/42] Exclude gyb files --- Package.swift | 4 ++-- Package@swift-5.2.swift | 4 ++-- Package@swift-5.3.swift | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index ab02f335..071d7eae 100644 --- a/Package.swift +++ b/Package.swift @@ -14,8 +14,8 @@ let package = Package( .package(url: "https://github.com/Quick/Nimble.git", from: "8.0.0"), ], targets: [ - .target(name: "Partial"), - .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"]), + .target(name: "Partial", exclude: ["Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb"]), + .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"], exclude: ["Tests/PartialCodableTests.swift.gyb"]), ], swiftLanguageVersions: [.v5] ) diff --git a/Package@swift-5.2.swift b/Package@swift-5.2.swift index 4613bcad..edc2d927 100644 --- a/Package@swift-5.2.swift +++ b/Package@swift-5.2.swift @@ -14,8 +14,8 @@ let package = Package( .package(url: "https://github.com/Quick/Nimble.git", from: "8.0.0"), ], targets: [ - .target(name: "Partial"), - .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"]), + .target(name: "Partial", exclude: ["Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb"]), + .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"], exclude: ["Tests/PartialCodableTests.swift.gyb"]), ], swiftLanguageVersions: [.v5] ) diff --git a/Package@swift-5.3.swift b/Package@swift-5.3.swift index af2e7ccf..af0a0017 100644 --- a/Package@swift-5.3.swift +++ b/Package@swift-5.3.swift @@ -18,8 +18,8 @@ let package = Package( .package(url: "https://github.com/Realm/SwiftLint", from: "0.32.0"), ], targets: [ - .target(name: "Partial"), - .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"]), + .target(name: "Partial", exclude: ["Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb"]), + .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"], exclude: ["Tests/PartialCodableTests.swift.gyb"]), .target( name: "DangerDependencies", dependencies: [ From 31298cd9ccd39e8639998b86ed29604b0b610a94 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 23:55:03 +0000 Subject: [PATCH 21/42] Update swiftlint to 0.42.0 --- Package.resolved | 12 ++++++------ Sources/Partial/Codable/PartialCodable.swift | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Package.resolved b/Package.resolved index 855c4d23..57981c6d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -87,8 +87,8 @@ "repositoryURL": "https://github.com/Realm/SwiftLint", "state": { "branch": null, - "revision": "4f8b7a5f480aad922beab9b3c674023e211bd177", - "version": "0.40.3" + "revision": "d53fc2664df92ef322bfa9ce5238d34f1461526a", + "version": "0.42.0" } }, { @@ -105,8 +105,8 @@ "repositoryURL": "https://github.com/drmohundro/SWXMLHash.git", "state": { "branch": null, - "revision": "a4931e5c3bafbedeb1601d3bb76bbe835c6d475a", - "version": "5.0.1" + "revision": "9183170d20857753d4f331b0ca63f73c60764bf3", + "version": "5.0.2" } }, { @@ -123,8 +123,8 @@ "repositoryURL": "https://github.com/jpsim/Yams.git", "state": { "branch": null, - "revision": "88caa2e6fffdbef2e91c2022d038576062042907", - "version": "4.0.0" + "revision": "9003d51672e516cc59297b7e96bff1dfdedcb4ea", + "version": "4.0.4" } } ] diff --git a/Sources/Partial/Codable/PartialCodable.swift b/Sources/Partial/Codable/PartialCodable.swift index 070a5d5b..c30506b1 100644 --- a/Sources/Partial/Codable/PartialCodable.swift +++ b/Sources/Partial/Codable/PartialCodable.swift @@ -22,7 +22,7 @@ public protocol PartialCodable { /// /// let stringValue: String /// let intValue: Int - ///} + /// } /// ``` static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { get } } From ee857282d06940a68c2208325847d6e373afa498 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sat, 13 Feb 2021 23:59:33 +0000 Subject: [PATCH 22/42] Throw error for invalid type --- Sources/Partial/Codable/KeyPathCodingKeyCollection.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift index 2cae22ca..31b8758a 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift @@ -1,4 +1,8 @@ public struct KeyPathCodingKeyCollection { + public enum EncodeError: Error { + case invalidType(value: Any, expectedType: Any.Type) + } + private typealias Encoder = (_ value: Any, _ container: inout KeyedEncodingContainer) throws -> Void private typealias Decoder = (_ codingKey: CodingKey, _ container: KeyedDecodingContainer) throws -> (Any, PartialKeyPath)? @@ -16,8 +20,7 @@ public struct KeyPathCodingKeyCollection(keyPath: KeyPath, codingKey: CodingKey) { encoders[keyPath] = { value, container in guard let value = value as? Value else { - // TODO: Throw - return + throw EncodeError.invalidType(value: value, expectedType: Value.self) } try container.encode(value, forKey: codingKey) From 4e282587964869578f79e708e3f88972be4945fb Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 00:01:39 +0000 Subject: [PATCH 23/42] Replace preconditionFailure with throw --- Sources/Partial/Partial.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/Partial/Partial.swift b/Sources/Partial/Partial.swift index 9f308b37..ce04c2d6 100644 --- a/Sources/Partial/Partial.swift +++ b/Sources/Partial/Partial.swift @@ -7,6 +7,12 @@ public struct Partial: PartialProtocol, CustomStringConvertible { public enum Error: Swift.Error { /// The key path has not been set. case keyPathNotSet(KeyPath) + + /// A value has been set to an unexpected type. + /// + /// - parameter value: The set value. + /// - parameter keyPath: The key path the value was set against. + case invalidType(value: Any, keyPath: KeyPath) } /// A textual representation of the Partial's values. @@ -33,7 +39,7 @@ public struct Partial: PartialProtocol, CustomStringConvertible { return value } - preconditionFailure("Value has been set, but is not of type \(Value.self): \(value)") + throw Error.invalidType(value: value, keyPath: keyPath) } /// Updates the stored value for the given key path. From e665b1593a1f176ecc0d06edc479522340d72c37 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 00:24:36 +0000 Subject: [PATCH 24/42] Add Codable conformance to PartialBuilder --- Package.swift | 9 +- Package@swift-5.2.swift | 9 +- Package@swift-5.3.swift | 9 +- Partial.xcodeproj/project.pbxproj | 30 +- Sources/Partial/PartialBuilder.swift | 12 + ...Tests.swift => Partial+CodableTests.swift} | 2 +- ...ift.gyb => Partial+CodableTests.swift.gyb} | 2 +- .../Tests/PartialBuilder+CodableTests.swift | 1527 +++++++++++++++++ .../PartialBuilder+CodableTests.swift.gyb | 92 + ...erate-KeyPathCodingKeyCollectionBuilder.sh | 4 +- 10 files changed, 1680 insertions(+), 16 deletions(-) rename Tests/PartialTests/Tests/{PartialCodableTests.swift => Partial+CodableTests.swift} (99%) rename Tests/PartialTests/Tests/{PartialCodableTests.swift.gyb => Partial+CodableTests.swift.gyb} (98%) create mode 100644 Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift create mode 100644 Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb diff --git a/Package.swift b/Package.swift index 071d7eae..594e89de 100644 --- a/Package.swift +++ b/Package.swift @@ -15,7 +15,14 @@ let package = Package( ], targets: [ .target(name: "Partial", exclude: ["Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb"]), - .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"], exclude: ["Tests/PartialCodableTests.swift.gyb"]), + .testTarget( + name: "PartialTests", + dependencies: ["Partial", "Quick", "Nimble"], + exclude: [ + "Tests/Partial+CodableTests.swift.gyb", + "Tests/PartialBuilder+CodableTests.swift.gyb", + ] + ), ], swiftLanguageVersions: [.v5] ) diff --git a/Package@swift-5.2.swift b/Package@swift-5.2.swift index edc2d927..3e8a57c6 100644 --- a/Package@swift-5.2.swift +++ b/Package@swift-5.2.swift @@ -15,7 +15,14 @@ let package = Package( ], targets: [ .target(name: "Partial", exclude: ["Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb"]), - .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"], exclude: ["Tests/PartialCodableTests.swift.gyb"]), + .testTarget( + name: "PartialTests", + dependencies: ["Partial", "Quick", "Nimble"], + exclude: [ + "Tests/Partial+CodableTests.swift.gyb", + "Tests/PartialBuilder+CodableTests.swift.gyb", + ] + ), ], swiftLanguageVersions: [.v5] ) diff --git a/Package@swift-5.3.swift b/Package@swift-5.3.swift index af0a0017..1dd41717 100644 --- a/Package@swift-5.3.swift +++ b/Package@swift-5.3.swift @@ -19,7 +19,14 @@ let package = Package( ], targets: [ .target(name: "Partial", exclude: ["Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb"]), - .testTarget(name: "PartialTests", dependencies: ["Partial", "Quick", "Nimble"], exclude: ["Tests/PartialCodableTests.swift.gyb"]), + .testTarget( + name: "PartialTests", + dependencies: ["Partial", "Quick", "Nimble"], + exclude: [ + "Tests/Partial+CodableTests.swift.gyb", + "Tests/PartialBuilder+CodableTests.swift.gyb", + ] + ), .target( name: "DangerDependencies", dependencies: [ diff --git a/Partial.xcodeproj/project.pbxproj b/Partial.xcodeproj/project.pbxproj index 27f144ac..a6c0e303 100644 --- a/Partial.xcodeproj/project.pbxproj +++ b/Partial.xcodeproj/project.pbxproj @@ -15,6 +15,12 @@ D92E76D1229D8A66003EBC25 /* PartialProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92E76CF229D8A0D003EBC25 /* PartialProtocol.swift */; }; D92E76D2229D8A67003EBC25 /* PartialProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92E76CF229D8A0D003EBC25 /* PartialProtocol.swift */; }; D92E76D3229D8A67003EBC25 /* PartialProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92E76CF229D8A0D003EBC25 /* PartialProtocol.swift */; }; + D92F168525D8A49E003E2D1C /* Partial+CodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92F168425D8A49E003E2D1C /* Partial+CodableTests.swift */; }; + D92F168625D8A49E003E2D1C /* Partial+CodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92F168425D8A49E003E2D1C /* Partial+CodableTests.swift */; }; + D92F168725D8A49E003E2D1C /* Partial+CodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92F168425D8A49E003E2D1C /* Partial+CodableTests.swift */; }; + D92F168925D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92F168825D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift */; }; + D92F168A25D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92F168825D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift */; }; + D92F168B25D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D92F168825D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift */; }; D9651AC022D24673008DBB0E /* StringWrapperWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9651ABF22D24673008DBB0E /* StringWrapperWrapper.swift */; }; D9651AC122D24673008DBB0E /* StringWrapperWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9651ABF22D24673008DBB0E /* StringWrapperWrapper.swift */; }; D9651AC222D24673008DBB0E /* StringWrapperWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9651ABF22D24673008DBB0E /* StringWrapperWrapper.swift */; }; @@ -52,9 +58,6 @@ D9A4E48125D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */; }; D9A4E48225D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */; }; D9A4E48325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */; }; - D9A4E48925D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */; }; - D9A4E48A25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */; }; - D9A4E48B25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */; }; D9A5673825D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A5673725D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift */; }; D9A5673925D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A5673725D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift */; }; D9A5673A25D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9A5673725D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift */; }; @@ -122,6 +125,9 @@ D91505C9221E04EB00EB5215 /* Partial.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Partial.swift; sourceTree = ""; }; D91505CD221E052600EB5215 /* PartialBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartialBuilder.swift; sourceTree = ""; }; D92E76CF229D8A0D003EBC25 /* PartialProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartialProtocol.swift; sourceTree = ""; }; + D92F168325D8A403003E2D1C /* PartialBuilder+CodableTests.swift.gyb */ = {isa = PBXFileReference; lastKnownFileType = text; path = "PartialBuilder+CodableTests.swift.gyb"; sourceTree = ""; }; + D92F168425D8A49E003E2D1C /* Partial+CodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Partial+CodableTests.swift"; sourceTree = ""; }; + D92F168825D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PartialBuilder+CodableTests.swift"; sourceTree = ""; }; D9651ABD22D24606008DBB0E /* StringWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringWrapper.swift; sourceTree = ""; }; D9651ABF22D24673008DBB0E /* StringWrapperWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringWrapperWrapper.swift; sourceTree = ""; }; D9651AC622D26A53008DBB0E /* PartialTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartialTests.swift; sourceTree = ""; }; @@ -134,8 +140,7 @@ D9A4E47125D85C8E00F3E6D9 /* KeyPathCodingKeyCollectionBuilder.swift.gyb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = KeyPathCodingKeyCollectionBuilder.swift.gyb; sourceTree = ""; }; D9A4E47225D85C8E00F3E6D9 /* PartialCodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialCodable.swift; sourceTree = ""; }; D9A4E47325D85C8E00F3E6D9 /* KeyPathCodingKeyCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyPathCodingKeyCollection.swift; sourceTree = ""; }; - D9A4E48425D85CC700F3E6D9 /* PartialCodableTests.swift.gyb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PartialCodableTests.swift.gyb; sourceTree = ""; }; - D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialCodableTests.swift; sourceTree = ""; }; + D9A4E48425D85CC700F3E6D9 /* Partial+CodableTests.swift.gyb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Partial+CodableTests.swift.gyb"; sourceTree = ""; }; D9A5673225D86BE600F7055F /* PartiallyBuilt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartiallyBuilt.swift; sourceTree = ""; }; D9A5673725D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartialBuilderSubscriptionTests.swift; sourceTree = ""; }; D9A5673B25D86C5400F7055F /* PartiallyBuiltTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PartiallyBuiltTests.swift; sourceTree = ""; }; @@ -292,10 +297,12 @@ D9651ACF22D278FC008DBB0E /* Tests */ = { isa = PBXGroup; children = ( + D92F168425D8A49E003E2D1C /* Partial+CodableTests.swift */, + D9A4E48425D85CC700F3E6D9 /* Partial+CodableTests.swift.gyb */, D9651AD022D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift */, + D92F168825D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift */, + D92F168325D8A403003E2D1C /* PartialBuilder+CodableTests.swift.gyb */, D9651AD422D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift */, - D9A4E48525D85CC700F3E6D9 /* PartialCodableTests.swift */, - D9A4E48425D85CC700F3E6D9 /* PartialCodableTests.swift.gyb */, D9A5673725D86C1F00F7055F /* PartialBuilderSubscriptionTests.swift */, D9651ACA22D26EFB008DBB0E /* PartialBuilderTests.swift */, D9A5673B25D86C5400F7055F /* PartiallyBuiltTests.swift */, @@ -652,9 +659,10 @@ D9651ACB22D2788C008DBB0E /* PartialBuilderTests.swift in Sources */, D9651AC322D24678008DBB0E /* StringWrapper.swift in Sources */, D992471922C15D6300A2B079 /* beNilWrappedInOptional.swift in Sources */, + D92F168525D8A49E003E2D1C /* Partial+CodableTests.swift in Sources */, + D92F168925D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift in Sources */, D9651AD122D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, D9651AD522D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift in Sources */, - D9A4E48925D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */, D9651AC722D26A53008DBB0E /* PartialTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -703,9 +711,10 @@ D9651ACC22D2788D008DBB0E /* PartialBuilderTests.swift in Sources */, D9651AC422D24678008DBB0E /* StringWrapper.swift in Sources */, D992471A22C15D6500A2B079 /* beNilWrappedInOptional.swift in Sources */, + D92F168625D8A49E003E2D1C /* Partial+CodableTests.swift in Sources */, + D92F168A25D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift in Sources */, D9651AD222D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, D9651AD622D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift in Sources */, - D9A4E48A25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */, D9651AC822D26A53008DBB0E /* PartialTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -737,9 +746,10 @@ D9651ACD22D2788E008DBB0E /* PartialBuilderTests.swift in Sources */, D9651AC522D24679008DBB0E /* StringWrapper.swift in Sources */, D992471B22C15D6900A2B079 /* beNilWrappedInOptional.swift in Sources */, + D92F168725D8A49E003E2D1C /* Partial+CodableTests.swift in Sources */, + D92F168B25D8A4A9003E2D1C /* PartialBuilder+CodableTests.swift in Sources */, D9651AD322D27BE7008DBB0E /* Partial+PartialConvertibleTests.swift in Sources */, D9651AD722D28374008DBB0E /* PartialBuilder+PartialConvertibleTests.swift in Sources */, - D9A4E48B25D85CC700F3E6D9 /* PartialCodableTests.swift in Sources */, D9651AC922D26A53008DBB0E /* PartialTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Sources/Partial/PartialBuilder.swift b/Sources/Partial/PartialBuilder.swift index e52ab353..619f2144 100644 --- a/Sources/Partial/PartialBuilder.swift +++ b/Sources/Partial/PartialBuilder.swift @@ -75,6 +75,11 @@ open class PartialBuilder: PartialProtocol, CustomStringConvertible { self.partial = partial } + public required init(from decoder: Decoder) throws where Wrapped: PartialCodable { + let container = try decoder.singleValueContainer() + partial = try container.decode(Partial.self) + } + /// Adds a closure that will be called when any key path has been updated. The closure will be called with the key /// path that was updated and this `PartialBuilder`. /// @@ -249,3 +254,10 @@ extension PartialBuilder { extension PartialBuilder.KeyPathUpdate.Kind: Equatable where Value: Equatable {} extension PartialBuilder.KeyPathUpdate: Equatable where Value: Equatable {} + +extension PartialBuilder: Codable where Wrapped: PartialCodable { + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(partial) + } +} diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift similarity index 99% rename from Tests/PartialTests/Tests/PartialCodableTests.swift rename to Tests/PartialTests/Tests/Partial+CodableTests.swift index 6f617e2e..c59cfcdc 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -9,7 +9,7 @@ import Partial final class PartialCodableTests: QuickSpec { override func spec() { - describe("PartialCodable") { + describe("Partial+Codable") { context("with 1 property") { struct CodableType: Codable, PartialCodable, Hashable { @KeyPathCodingKeyCollectionBuilder diff --git a/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb similarity index 98% rename from Tests/PartialTests/Tests/PartialCodableTests.swift.gyb rename to Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index 5fbb031c..01baec28 100644 --- a/Tests/PartialTests/Tests/PartialCodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -10,7 +10,7 @@ import Partial final class PartialCodableTests: QuickSpec { override func spec() { - describe("PartialCodable") { + describe("Partial+Codable") { % parameterCountList = range(16) % for parameterCount in parameterCountList: % parametersRange = range(parameterCount + 1) diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift new file mode 100644 index 00000000..29b26add --- /dev/null +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -0,0 +1,1527 @@ +// This file is generated. Do not edit it. +// swiftlint:disable cyclomatic_complexity +import Quick +import Nimble +import Foundation + +@testable +import Partial + +final class PartialBuilderCodableTests: QuickSpec { + override func spec() { + describe("PartialBuilder+Codable") { + context("with 1 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + } + + let stringA: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 2 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + } + + let stringA: String + let stringB: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 3 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + } + + let stringA: String + let stringB: String + let stringC: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 4 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 5 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 6 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 7 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 8 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 9 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 10 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 11 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 12 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 13 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 14 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + (\Self.stringN, CodingKeys.stringN) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + let stringN: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + partial.stringN = "Value N" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 15 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + (\Self.stringN, CodingKeys.stringN) + (\Self.stringO, CodingKeys.stringO) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + let stringN: String + let stringO: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + partial.stringN = "Value N" + partial.stringO = "Value O" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + context("with 16 property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + (\Self.stringA, CodingKeys.stringA) + (\Self.stringB, CodingKeys.stringB) + (\Self.stringC, CodingKeys.stringC) + (\Self.stringD, CodingKeys.stringD) + (\Self.stringE, CodingKeys.stringE) + (\Self.stringF, CodingKeys.stringF) + (\Self.stringG, CodingKeys.stringG) + (\Self.stringH, CodingKeys.stringH) + (\Self.stringI, CodingKeys.stringI) + (\Self.stringJ, CodingKeys.stringJ) + (\Self.stringK, CodingKeys.stringK) + (\Self.stringL, CodingKeys.stringL) + (\Self.stringM, CodingKeys.stringM) + (\Self.stringN, CodingKeys.stringN) + (\Self.stringO, CodingKeys.stringO) + (\Self.stringP, CodingKeys.stringP) + } + + let stringA: String + let stringB: String + let stringC: String + let stringD: String + let stringE: String + let stringF: String + let stringG: String + let stringH: String + let stringI: String + let stringJ: String + let stringK: String + let stringL: String + let stringM: String + let stringN: String + let stringO: String + let stringP: String + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { + partial.stringA = "Value A" + partial.stringB = "Value B" + partial.stringC = "Value C" + partial.stringD = "Value D" + partial.stringE = "Value E" + partial.stringF = "Value F" + partial.stringG = "Value G" + partial.stringH = "Value H" + partial.stringI = "Value I" + partial.stringJ = "Value J" + partial.stringK = "Value K" + partial.stringL = "Value L" + partial.stringM = "Value M" + partial.stringN = "Value N" + partial.stringO = "Value O" + partial.stringP = "Value P" + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } + } + } +} diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb new file mode 100644 index 00000000..4ded12d4 --- /dev/null +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -0,0 +1,92 @@ +% import string +// This file is generated. Do not edit it. +// swiftlint:disable cyclomatic_complexity +import Quick +import Nimble +import Foundation + +@testable +import Partial + +final class PartialBuilderCodableTests: QuickSpec { + override func spec() { + describe("PartialBuilder+Codable") { +% parameterCountList = range(16) +% for parameterCount in parameterCountList: +% parametersRange = range(parameterCount + 1) + context("with ${parameterCount + 1} property") { + struct CodableType: Codable, PartialCodable, Hashable { + @KeyPathCodingKeyCollectionBuilder + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + (\Self.string${character}, CodingKeys.string${character}) +% end + } + +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + let string${character}: String +% end + } + + var partial: PartialBuilder! + + beforeEach { + partial = PartialBuilder() + } + + context("with complete value") { + beforeEach { +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + partial.string${character} = "Value ${character}" +% end + } + + context("the encoded data") { + var encodedData: Data! + + beforeEach { + let encoder = JSONEncoder() + encodedData = try? encoder.encode(partial) + } + + it("should not be nil") { + expect(encodedData).toNot(beNil()) + } + + it("should be usable to decode Wrapped") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(CodableType.self, from: encodedData) + +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + expect(decodedValue.string${character}) == "Value ${character}" +% end + } catch { + fail("Should not throw: \(error)") + } + } + + it("should be usable to decode Partial") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(Partial.self, from: encodedData) + +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + expect(decodedValue.string${character}) == "Value ${character}" +% end + } catch { + fail("Should not throw: \(error)") + } + } + } + } + } +% end + } + } +} diff --git a/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh b/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh index c6934002..c4196e6a 100755 --- a/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh +++ b/scripts/generate-KeyPathCodingKeyCollectionBuilder.sh @@ -1,7 +1,9 @@ #!/bin/sh KeyPathCodingKeyCollectionBuilder_FILE="Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift" -PartialCodableTests_FILE="Tests/PartialTests/Tests/PartialCodableTests.swift" +PartialCodableTests_FILE="Tests/PartialTests/Tests/Partial+CodableTests.swift" +PartialBuilderCodableTests_FILE="Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift" gyb --line-directive '' -o "$KeyPathCodingKeyCollectionBuilder_FILE" "$KeyPathCodingKeyCollectionBuilder_FILE.gyb" gyb --line-directive '' -o "$PartialCodableTests_FILE" "$PartialCodableTests_FILE.gyb" +gyb --line-directive '' -o "$PartialBuilderCodableTests_FILE" "$PartialBuilderCodableTests_FILE.gyb" From f16d86cdad8d6ce822689bb34ed63cc28b8e4ec9 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 00:25:18 +0000 Subject: [PATCH 25/42] Add `decoded` function --- Sources/Partial/Partial.swift | 9 +++++++++ Sources/Partial/PartialBuilder.swift | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/Sources/Partial/Partial.swift b/Sources/Partial/Partial.swift index ce04c2d6..84b08820 100644 --- a/Sources/Partial/Partial.swift +++ b/Sources/Partial/Partial.swift @@ -82,3 +82,12 @@ extension Partial: Codable where Wrapped: PartialCodable { } } } + +extension Partial where Wrapped: PartialCodable & Codable { + public func decoded() throws -> Wrapped { + let encoder = JSONEncoder() + let data = try encoder.encode(self) + let decoder = JSONDecoder() + return try decoder.decode(Wrapped.self, from: data) + } +} diff --git a/Sources/Partial/PartialBuilder.swift b/Sources/Partial/PartialBuilder.swift index 619f2144..dea2dd69 100644 --- a/Sources/Partial/PartialBuilder.swift +++ b/Sources/Partial/PartialBuilder.swift @@ -261,3 +261,9 @@ extension PartialBuilder: Codable where Wrapped: PartialCodable { try container.encode(partial) } } + +extension PartialBuilder where Wrapped: PartialCodable & Codable { + public func decoded() throws -> Wrapped { + return try partial.decoded() + } +} From 45490471a56c2557d67abd438ad228d5a16627f4 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 00:52:34 +0000 Subject: [PATCH 26/42] Fix PartialBuilder on Swift < 5.3 --- Sources/Partial/PartialBuilder.swift | 8 +- .../Tests/PartialBuilder+CodableTests.swift | 328 ++++++++++++++++++ .../PartialBuilder+CodableTests.swift.gyb | 16 + 3 files changed, 351 insertions(+), 1 deletion(-) diff --git a/Sources/Partial/PartialBuilder.swift b/Sources/Partial/PartialBuilder.swift index dea2dd69..2e5cf88d 100644 --- a/Sources/Partial/PartialBuilder.swift +++ b/Sources/Partial/PartialBuilder.swift @@ -75,10 +75,12 @@ open class PartialBuilder: PartialProtocol, CustomStringConvertible { self.partial = partial } + #if swift(>=5.3) public required init(from decoder: Decoder) throws where Wrapped: PartialCodable { let container = try decoder.singleValueContainer() partial = try container.decode(Partial.self) } + #endif /// Adds a closure that will be called when any key path has been updated. The closure will be called with the key /// path that was updated and this `PartialBuilder`. @@ -255,7 +257,11 @@ extension PartialBuilder { extension PartialBuilder.KeyPathUpdate.Kind: Equatable where Value: Equatable {} extension PartialBuilder.KeyPathUpdate: Equatable where Value: Equatable {} -extension PartialBuilder: Codable where Wrapped: PartialCodable { +#if swift(>=5.3) +extension PartialBuilder: Decodable where Wrapped: PartialCodable {} +#endif + +extension PartialBuilder: Encodable where Wrapped: PartialCodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() try container.encode(partial) diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 29b26add..e8d1b6fa 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -64,6 +64,19 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -126,6 +139,20 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -193,6 +220,21 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -265,6 +307,22 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -342,6 +400,23 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -424,6 +499,24 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -511,6 +604,25 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -603,6 +715,26 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -700,6 +832,27 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -802,6 +955,28 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -909,6 +1084,29 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -1021,6 +1219,30 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -1138,6 +1360,31 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -1260,6 +1507,32 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -1387,6 +1660,33 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } @@ -1519,6 +1819,34 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 4ded12d4..98af9fa2 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -83,6 +83,22 @@ final class PartialBuilderCodableTests: QuickSpec { fail("Should not throw: \(error)") } } + + #if swift(>=5.3) + it("should be usable to decode PartialBuilder") { + do { + let decoder = JSONDecoder() + let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) + +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + expect(decodedValue.string${character}) == "Value ${character}" +% end + } catch { + fail("Should not throw: \(error)") + } + } + #endif } } } From e1c4466f2cacecce36f508b8d69da9de5b2c84c1 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 00:54:35 +0000 Subject: [PATCH 27/42] Fix compiler error --- Sources/Partial/Codable/KeyPathCodingKeyCollection.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift index 31b8758a..b7044741 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift @@ -19,11 +19,11 @@ public struct KeyPathCodingKeyCollection(keyPath: KeyPath, codingKey: CodingKey) { encoders[keyPath] = { value, container in - guard let value = value as? Value else { + guard let caseValue = value as? Value else { throw EncodeError.invalidType(value: value, expectedType: Value.self) } - try container.encode(value, forKey: codingKey) + try container.encode(caseValue, forKey: codingKey) } decoders[codingKey] = { codingKey, container in From b965769a6827e21ecb8782ab63422947bce28272 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:04:49 +0000 Subject: [PATCH 28/42] Fix Swift < 5.3 compilation --- .../Codable/KeyPathCodingKeyCollection.swift | 2 +- .../KeyPathCodingKeyCollectionBuilder.swift | 497 ++++++++++++++++++ ...eyPathCodingKeyCollectionBuilder.swift.gyb | 1 - .../Tests/Partial+CodableTests.swift | 2 + .../Tests/Partial+CodableTests.swift.gyb | 2 + .../Tests/PartialBuilder+CodableTests.swift | 2 + .../PartialBuilder+CodableTests.swift.gyb | 2 + 7 files changed, 506 insertions(+), 2 deletions(-) diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift index b7044741..e49c6360 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollection.swift @@ -14,7 +14,7 @@ public struct KeyPathCodingKeyCollection) throws -> (Any, PartialKeyPath)? { - try decoders[codingKey]?(codingKey, container) + return try decoders[codingKey]?(codingKey, container) } public mutating func addPair(keyPath: KeyPath, codingKey: CodingKey) { diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift index 933cecb6..79e58a76 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift @@ -548,5 +548,502 @@ public final class KeyPathCodingKeyCollectionBuilder( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable, + ValueN: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey), + _ pairN: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + collection.addPair(keyPath: pairN.keyPath, codingKey: pairN.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable, + ValueN: Codable, + ValueO: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey), + _ pairN: (keyPath: KeyPath, codingKey: CodingKey), + _ pairO: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + collection.addPair(keyPath: pairN.keyPath, codingKey: pairN.codingKey) + collection.addPair(keyPath: pairO.keyPath, codingKey: pairO.codingKey) + return collection + } + + static func buildBlock< + ValueA: Codable, + ValueB: Codable, + ValueC: Codable, + ValueD: Codable, + ValueE: Codable, + ValueF: Codable, + ValueG: Codable, + ValueH: Codable, + ValueI: Codable, + ValueJ: Codable, + ValueK: Codable, + ValueL: Codable, + ValueM: Codable, + ValueN: Codable, + ValueO: Codable, + ValueP: Codable + >( + _ pairA: (keyPath: KeyPath, codingKey: CodingKey), + _ pairB: (keyPath: KeyPath, codingKey: CodingKey), + _ pairC: (keyPath: KeyPath, codingKey: CodingKey), + _ pairD: (keyPath: KeyPath, codingKey: CodingKey), + _ pairE: (keyPath: KeyPath, codingKey: CodingKey), + _ pairF: (keyPath: KeyPath, codingKey: CodingKey), + _ pairG: (keyPath: KeyPath, codingKey: CodingKey), + _ pairH: (keyPath: KeyPath, codingKey: CodingKey), + _ pairI: (keyPath: KeyPath, codingKey: CodingKey), + _ pairJ: (keyPath: KeyPath, codingKey: CodingKey), + _ pairK: (keyPath: KeyPath, codingKey: CodingKey), + _ pairL: (keyPath: KeyPath, codingKey: CodingKey), + _ pairM: (keyPath: KeyPath, codingKey: CodingKey), + _ pairN: (keyPath: KeyPath, codingKey: CodingKey), + _ pairO: (keyPath: KeyPath, codingKey: CodingKey), + _ pairP: (keyPath: KeyPath, codingKey: CodingKey) + ) -> KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: pairA.keyPath, codingKey: pairA.codingKey) + collection.addPair(keyPath: pairB.keyPath, codingKey: pairB.codingKey) + collection.addPair(keyPath: pairC.keyPath, codingKey: pairC.codingKey) + collection.addPair(keyPath: pairD.keyPath, codingKey: pairD.codingKey) + collection.addPair(keyPath: pairE.keyPath, codingKey: pairE.codingKey) + collection.addPair(keyPath: pairF.keyPath, codingKey: pairF.codingKey) + collection.addPair(keyPath: pairG.keyPath, codingKey: pairG.codingKey) + collection.addPair(keyPath: pairH.keyPath, codingKey: pairH.codingKey) + collection.addPair(keyPath: pairI.keyPath, codingKey: pairI.codingKey) + collection.addPair(keyPath: pairJ.keyPath, codingKey: pairJ.codingKey) + collection.addPair(keyPath: pairK.keyPath, codingKey: pairK.codingKey) + collection.addPair(keyPath: pairL.keyPath, codingKey: pairL.codingKey) + collection.addPair(keyPath: pairM.keyPath, codingKey: pairM.codingKey) + collection.addPair(keyPath: pairN.keyPath, codingKey: pairN.codingKey) + collection.addPair(keyPath: pairO.keyPath, codingKey: pairO.codingKey) + collection.addPair(keyPath: pairP.keyPath, codingKey: pairP.codingKey) + return collection + } } #endif diff --git a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb index f798b13f..a6c02d0e 100644 --- a/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb +++ b/Sources/Partial/Codable/KeyPathCodingKeyCollectionBuilder.swift.gyb @@ -44,7 +44,6 @@ public final class KeyPathCodingKeyCollectionBuilder=5.1) @_functionBuilder public final class KeyPathCodingKeyCollectionBuilder { -% parameterCountList = range(2) % for parameterCount in parameterCountList: % parametersRange = range(parameterCount + 1) static func buildBlock< diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index c59cfcdc..cdea5ee3 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -1,4 +1,5 @@ // This file is generated. Do not edit it. +#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -1525,3 +1526,4 @@ final class PartialCodableTests: QuickSpec { } } } +#endif diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index 01baec28..0f0ba216 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -1,5 +1,6 @@ % import string // This file is generated. Do not edit it. +#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -90,3 +91,4 @@ final class PartialCodableTests: QuickSpec { } } } +#endif diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index e8d1b6fa..930d012e 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -1,4 +1,5 @@ // This file is generated. Do not edit it. +#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -1853,3 +1854,4 @@ final class PartialBuilderCodableTests: QuickSpec { } } } +#endif diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 98af9fa2..583fdd48 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -1,5 +1,6 @@ % import string // This file is generated. Do not edit it. +#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -106,3 +107,4 @@ final class PartialBuilderCodableTests: QuickSpec { } } } +#endif From c281b131e208e0cfe547c6878f2ffa16d688fff6 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:10:24 +0000 Subject: [PATCH 29/42] Fix test names --- Tests/LinuxMain.swift | 3 ++- Tests/PartialTests/Tests/Partial+CodableTests.swift | 2 +- Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index cbfbd3af..5e25c022 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -4,11 +4,12 @@ import Quick @testable import PartialTests QCKMain([ + Partial_CodableTests.self, Partial_PartialConvertibleTests.self, + PartialBuilder_CodableTests.self, PartialBuilder_PartialConvertibleTests.self, PartialBuilderSubscriptionTests.self, PartialBuilderTests.self, - PartialCodableTests.self, PartialBuilderSubscriptionTests.self, PartialTests.self, ]) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index cdea5ee3..ce5dd613 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -8,7 +8,7 @@ import Foundation @testable import Partial -final class PartialCodableTests: QuickSpec { +final class Partial_CodableTests: QuickSpec { override func spec() { describe("Partial+Codable") { context("with 1 property") { diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 930d012e..5c6cc7a4 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -8,7 +8,7 @@ import Foundation @testable import Partial -final class PartialBuilderCodableTests: QuickSpec { +final class Partial_BuilderCodableTests: QuickSpec { override func spec() { describe("PartialBuilder+Codable") { context("with 1 property") { From 8abd95abf29ec5479e33812333e28523e178511b Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:24:10 +0000 Subject: [PATCH 30/42] Run Codable tests on Swift 5.0 --- .../Tests/Partial+CodableTests.swift | 250 ++++++++++++++++- .../Tests/Partial+CodableTests.swift.gyb | 15 +- .../Tests/PartialBuilder+CodableTests.swift | 252 +++++++++++++++++- .../PartialBuilder+CodableTests.swift.gyb | 15 +- 4 files changed, 521 insertions(+), 11 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index ce5dd613..15d5e17f 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -1,5 +1,4 @@ // This file is generated. Do not edit it. -#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -13,10 +12,18 @@ final class Partial_CodableTests: QuickSpec { describe("Partial+Codable") { context("with 1 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + return collection + } + #endif let stringA: String } @@ -70,11 +77,20 @@ final class Partial_CodableTests: QuickSpec { } context("with 2 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) (\Self.stringB, CodingKeys.stringB) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + return collection + } + #endif let stringA: String let stringB: String @@ -132,12 +148,22 @@ final class Partial_CodableTests: QuickSpec { } context("with 3 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) (\Self.stringB, CodingKeys.stringB) (\Self.stringC, CodingKeys.stringC) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + return collection + } + #endif let stringA: String let stringB: String @@ -199,6 +225,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 4 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -206,6 +233,16 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringC, CodingKeys.stringC) (\Self.stringD, CodingKeys.stringD) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + return collection + } + #endif let stringA: String let stringB: String @@ -271,6 +308,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 5 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -279,6 +317,17 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringD, CodingKeys.stringD) (\Self.stringE, CodingKeys.stringE) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + return collection + } + #endif let stringA: String let stringB: String @@ -348,6 +397,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 6 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -357,6 +407,18 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringE, CodingKeys.stringE) (\Self.stringF, CodingKeys.stringF) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + return collection + } + #endif let stringA: String let stringB: String @@ -430,6 +492,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 7 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -440,6 +503,19 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringF, CodingKeys.stringF) (\Self.stringG, CodingKeys.stringG) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + return collection + } + #endif let stringA: String let stringB: String @@ -517,6 +593,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 8 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -528,6 +605,20 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringG, CodingKeys.stringG) (\Self.stringH, CodingKeys.stringH) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + return collection + } + #endif let stringA: String let stringB: String @@ -609,6 +700,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 9 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -621,6 +713,21 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringH, CodingKeys.stringH) (\Self.stringI, CodingKeys.stringI) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + return collection + } + #endif let stringA: String let stringB: String @@ -706,6 +813,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 10 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -719,6 +827,22 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringI, CodingKeys.stringI) (\Self.stringJ, CodingKeys.stringJ) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + return collection + } + #endif let stringA: String let stringB: String @@ -808,6 +932,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 11 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -822,6 +947,23 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringJ, CodingKeys.stringJ) (\Self.stringK, CodingKeys.stringK) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + return collection + } + #endif let stringA: String let stringB: String @@ -915,6 +1057,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 12 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -930,6 +1073,24 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringK, CodingKeys.stringK) (\Self.stringL, CodingKeys.stringL) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + return collection + } + #endif let stringA: String let stringB: String @@ -1027,6 +1188,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 13 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1043,6 +1205,25 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringL, CodingKeys.stringL) (\Self.stringM, CodingKeys.stringM) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + return collection + } + #endif let stringA: String let stringB: String @@ -1144,6 +1325,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 14 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1161,6 +1343,26 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringM, CodingKeys.stringM) (\Self.stringN, CodingKeys.stringN) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + collection.addPair(keyPath: \.stringN, codingKey: .stringN) + return collection + } + #endif let stringA: String let stringB: String @@ -1266,6 +1468,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 15 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1284,6 +1487,27 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringN, CodingKeys.stringN) (\Self.stringO, CodingKeys.stringO) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + collection.addPair(keyPath: \.stringN, codingKey: .stringN) + collection.addPair(keyPath: \.stringO, codingKey: .stringO) + return collection + } + #endif let stringA: String let stringB: String @@ -1393,6 +1617,7 @@ final class Partial_CodableTests: QuickSpec { } context("with 16 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1412,6 +1637,28 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringO, CodingKeys.stringO) (\Self.stringP, CodingKeys.stringP) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + collection.addPair(keyPath: \.stringN, codingKey: .stringN) + collection.addPair(keyPath: \.stringO, codingKey: .stringO) + collection.addPair(keyPath: \.stringP, codingKey: .stringP) + return collection + } + #endif let stringA: String let stringB: String @@ -1526,4 +1773,3 @@ final class Partial_CodableTests: QuickSpec { } } } -#endif diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index 0f0ba216..85ff40a5 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -1,6 +1,5 @@ % import string // This file is generated. Do not edit it. -#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -9,7 +8,7 @@ import Foundation @testable import Partial -final class PartialCodableTests: QuickSpec { +final class Partial_CodableTests: QuickSpec { override func spec() { describe("Partial+Codable") { % parameterCountList = range(16) @@ -17,6 +16,7 @@ final class PartialCodableTests: QuickSpec { % parametersRange = range(parameterCount + 1) context("with ${parameterCount + 1} property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { % for characterIndex in parametersRange: @@ -24,6 +24,16 @@ final class PartialCodableTests: QuickSpec { (\Self.string${character}, CodingKeys.string${character}) % end } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + collection.addPair(keyPath: \.string${character}, codingKey: .string${character}) +% end + return collection + } + #endif % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] @@ -91,4 +101,3 @@ final class PartialCodableTests: QuickSpec { } } } -#endif diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 5c6cc7a4..32d53b95 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -1,5 +1,4 @@ // This file is generated. Do not edit it. -#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -8,15 +7,23 @@ import Foundation @testable import Partial -final class Partial_BuilderCodableTests: QuickSpec { +final class PartialBuilder_CodableTests: QuickSpec { override func spec() { describe("PartialBuilder+Codable") { context("with 1 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + return collection + } + #endif let stringA: String } @@ -83,11 +90,20 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 2 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) (\Self.stringB, CodingKeys.stringB) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + return collection + } + #endif let stringA: String let stringB: String @@ -159,12 +175,22 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 3 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) (\Self.stringB, CodingKeys.stringB) (\Self.stringC, CodingKeys.stringC) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + return collection + } + #endif let stringA: String let stringB: String @@ -241,6 +267,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 4 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -248,6 +275,16 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringC, CodingKeys.stringC) (\Self.stringD, CodingKeys.stringD) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + return collection + } + #endif let stringA: String let stringB: String @@ -329,6 +366,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 5 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -337,6 +375,17 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringD, CodingKeys.stringD) (\Self.stringE, CodingKeys.stringE) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + return collection + } + #endif let stringA: String let stringB: String @@ -423,6 +472,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 6 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -432,6 +482,18 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringE, CodingKeys.stringE) (\Self.stringF, CodingKeys.stringF) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + return collection + } + #endif let stringA: String let stringB: String @@ -523,6 +585,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 7 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -533,6 +596,19 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringF, CodingKeys.stringF) (\Self.stringG, CodingKeys.stringG) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + return collection + } + #endif let stringA: String let stringB: String @@ -629,6 +705,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 8 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -640,6 +717,20 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringG, CodingKeys.stringG) (\Self.stringH, CodingKeys.stringH) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + return collection + } + #endif let stringA: String let stringB: String @@ -741,6 +832,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 9 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -753,6 +845,21 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringH, CodingKeys.stringH) (\Self.stringI, CodingKeys.stringI) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + return collection + } + #endif let stringA: String let stringB: String @@ -859,6 +966,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 10 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -872,6 +980,22 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringI, CodingKeys.stringI) (\Self.stringJ, CodingKeys.stringJ) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + return collection + } + #endif let stringA: String let stringB: String @@ -983,6 +1107,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 11 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -997,6 +1122,23 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringJ, CodingKeys.stringJ) (\Self.stringK, CodingKeys.stringK) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + return collection + } + #endif let stringA: String let stringB: String @@ -1113,6 +1255,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 12 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1128,6 +1271,24 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringK, CodingKeys.stringK) (\Self.stringL, CodingKeys.stringL) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + return collection + } + #endif let stringA: String let stringB: String @@ -1249,6 +1410,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 13 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1265,6 +1427,25 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringL, CodingKeys.stringL) (\Self.stringM, CodingKeys.stringM) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + return collection + } + #endif let stringA: String let stringB: String @@ -1391,6 +1572,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 14 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1408,6 +1590,26 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringM, CodingKeys.stringM) (\Self.stringN, CodingKeys.stringN) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + collection.addPair(keyPath: \.stringN, codingKey: .stringN) + return collection + } + #endif let stringA: String let stringB: String @@ -1539,6 +1741,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 15 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1557,6 +1760,27 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringN, CodingKeys.stringN) (\Self.stringO, CodingKeys.stringO) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + collection.addPair(keyPath: \.stringN, codingKey: .stringN) + collection.addPair(keyPath: \.stringO, codingKey: .stringO) + return collection + } + #endif let stringA: String let stringB: String @@ -1693,6 +1917,7 @@ final class Partial_BuilderCodableTests: QuickSpec { } context("with 16 property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { (\Self.stringA, CodingKeys.stringA) @@ -1712,6 +1937,28 @@ final class Partial_BuilderCodableTests: QuickSpec { (\Self.stringO, CodingKeys.stringO) (\Self.stringP, CodingKeys.stringP) } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() + collection.addPair(keyPath: \.stringA, codingKey: .stringA) + collection.addPair(keyPath: \.stringB, codingKey: .stringB) + collection.addPair(keyPath: \.stringC, codingKey: .stringC) + collection.addPair(keyPath: \.stringD, codingKey: .stringD) + collection.addPair(keyPath: \.stringE, codingKey: .stringE) + collection.addPair(keyPath: \.stringF, codingKey: .stringF) + collection.addPair(keyPath: \.stringG, codingKey: .stringG) + collection.addPair(keyPath: \.stringH, codingKey: .stringH) + collection.addPair(keyPath: \.stringI, codingKey: .stringI) + collection.addPair(keyPath: \.stringJ, codingKey: .stringJ) + collection.addPair(keyPath: \.stringK, codingKey: .stringK) + collection.addPair(keyPath: \.stringL, codingKey: .stringL) + collection.addPair(keyPath: \.stringM, codingKey: .stringM) + collection.addPair(keyPath: \.stringN, codingKey: .stringN) + collection.addPair(keyPath: \.stringO, codingKey: .stringO) + collection.addPair(keyPath: \.stringP, codingKey: .stringP) + return collection + } + #endif let stringA: String let stringB: String @@ -1854,4 +2101,3 @@ final class Partial_BuilderCodableTests: QuickSpec { } } } -#endif diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 583fdd48..51aaa404 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -1,6 +1,5 @@ % import string // This file is generated. Do not edit it. -#if swift(>=5.1) // swiftlint:disable cyclomatic_complexity import Quick import Nimble @@ -9,7 +8,7 @@ import Foundation @testable import Partial -final class PartialBuilderCodableTests: QuickSpec { +final class PartialBuilder_CodableTests: QuickSpec { override func spec() { describe("PartialBuilder+Codable") { % parameterCountList = range(16) @@ -17,6 +16,7 @@ final class PartialBuilderCodableTests: QuickSpec { % parametersRange = range(parameterCount + 1) context("with ${parameterCount + 1} property") { struct CodableType: Codable, PartialCodable, Hashable { + #if swift(>=5.1) @KeyPathCodingKeyCollectionBuilder static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { % for characterIndex in parametersRange: @@ -24,6 +24,16 @@ final class PartialBuilderCodableTests: QuickSpec { (\Self.string${character}, CodingKeys.string${character}) % end } + #else + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() +% for characterIndex in parametersRange: +% character = string.ascii_uppercase[characterIndex] + collection.addPair(keyPath: \.string${character}, codingKey: .string${character}) +% end + return collection + } + #endif % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] @@ -107,4 +117,3 @@ final class PartialBuilderCodableTests: QuickSpec { } } } -#endif From 31e72c411c73a4dd962ca90a93d895e8f256ecec Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:26:52 +0000 Subject: [PATCH 31/42] Fix tests on Swift 5.0 --- .../Tests/PartialBuilder+CodableTests.swift | 32 +++++++++---------- .../PartialBuilder+CodableTests.swift.gyb | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 32d53b95..9fb8e468 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -19,7 +19,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) return collection } @@ -98,7 +98,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) return collection @@ -184,7 +184,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -277,7 +277,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -377,7 +377,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -484,7 +484,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -598,7 +598,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -719,7 +719,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -847,7 +847,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -982,7 +982,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1124,7 +1124,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1273,7 +1273,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1429,7 +1429,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1592,7 +1592,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1762,7 +1762,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1939,7 +1939,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 51aaa404..2d63d850 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -26,7 +26,7 @@ final class PartialBuilder_CodableTests: QuickSpec { } #else static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + var collection = KeyPathCodingKeyCollection() % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] collection.addPair(keyPath: \.string${character}, codingKey: .string${character}) From 059d5215f863fde7d0c57c638a59f5019752667a Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:31:09 +0000 Subject: [PATCH 32/42] Swift 5.0 compilation fixes --- .../Tests/Partial+CodableTests.swift | 272 ++--- .../Tests/Partial+CodableTests.swift.gyb | 2 +- .../Tests/PartialBuilder+CodableTests.swift | 1088 ++++++++--------- .../PartialBuilder+CodableTests.swift.gyb | 8 +- 4 files changed, 685 insertions(+), 685 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index 15d5e17f..618ff32d 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -36,7 +36,7 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" + partial[\.stringA] = "Value A" } context("the encoded data") { @@ -104,8 +104,8 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" } context("the encoded data") { @@ -178,9 +178,9 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" } context("the encoded data") { @@ -258,10 +258,10 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" } context("the encoded data") { @@ -344,11 +344,11 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" } context("the encoded data") { @@ -436,12 +436,12 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" } context("the encoded data") { @@ -534,13 +534,13 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" } context("the encoded data") { @@ -638,14 +638,14 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" } context("the encoded data") { @@ -748,15 +748,15 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" } context("the encoded data") { @@ -864,16 +864,16 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" } context("the encoded data") { @@ -986,17 +986,17 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" } context("the encoded data") { @@ -1114,18 +1114,18 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" } context("the encoded data") { @@ -1248,19 +1248,19 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" } context("the encoded data") { @@ -1388,20 +1388,20 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" - partial.stringN = "Value N" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" + partial[\.stringN] = "Value N" } context("the encoded data") { @@ -1534,21 +1534,21 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" - partial.stringN = "Value N" - partial.stringO = "Value O" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" + partial[\.stringN] = "Value N" + partial[\.stringO] = "Value O" } context("the encoded data") { @@ -1686,22 +1686,22 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" - partial.stringN = "Value N" - partial.stringO = "Value O" - partial.stringP = "Value P" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" + partial[\.stringN] = "Value N" + partial[\.stringO] = "Value O" + partial[\.stringP] = "Value P" } context("the encoded data") { diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index 85ff40a5..abf27ae8 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -51,7 +51,7 @@ final class Partial_CodableTests: QuickSpec { beforeEach { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - partial.string${character} = "Value ${character}" + partial[\.string${character}] = "Value ${character}" % end } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 9fb8e468..191c8177 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -36,7 +36,7 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" + partial[\.stringA] = "Value A" } context("the encoded data") { @@ -56,7 +56,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" + expect(decodedValue[\.stringA]) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -67,7 +67,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" + expect(decodedValue[\.stringA]) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -79,7 +79,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" + expect(decodedValue[\.stringA]) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -117,8 +117,8 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" } context("the encoded data") { @@ -138,8 +138,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -150,8 +150,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -163,8 +163,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -205,9 +205,9 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" } context("the encoded data") { @@ -227,9 +227,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -240,9 +240,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -254,9 +254,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -300,10 +300,10 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" } context("the encoded data") { @@ -323,10 +323,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -337,10 +337,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -352,10 +352,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -402,11 +402,11 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" } context("the encoded data") { @@ -426,11 +426,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -441,11 +441,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -457,11 +457,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -511,12 +511,12 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" } context("the encoded data") { @@ -536,12 +536,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -552,12 +552,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -569,12 +569,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -627,13 +627,13 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" } context("the encoded data") { @@ -653,13 +653,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -670,13 +670,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -688,13 +688,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -750,14 +750,14 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" } context("the encoded data") { @@ -777,14 +777,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -795,14 +795,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -814,14 +814,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -880,15 +880,15 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" } context("the encoded data") { @@ -908,15 +908,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -927,15 +927,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -947,15 +947,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -1017,16 +1017,16 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" } context("the encoded data") { @@ -1046,16 +1046,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1066,16 +1066,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1087,16 +1087,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1161,17 +1161,17 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" } context("the encoded data") { @@ -1191,17 +1191,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1212,17 +1212,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1234,17 +1234,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1312,18 +1312,18 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" } context("the encoded data") { @@ -1343,18 +1343,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1365,18 +1365,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1388,18 +1388,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1470,19 +1470,19 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" } context("the encoded data") { @@ -1502,19 +1502,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1525,19 +1525,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1549,19 +1549,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1635,20 +1635,20 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" - partial.stringN = "Value N" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" + partial[\.stringN] = "Value N" } context("the encoded data") { @@ -1668,20 +1668,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1692,20 +1692,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1717,20 +1717,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1807,21 +1807,21 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" - partial.stringN = "Value N" - partial.stringO = "Value O" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" + partial[\.stringN] = "Value N" + partial[\.stringO] = "Value O" } context("the encoded data") { @@ -1841,21 +1841,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[\.stringO]) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1866,21 +1866,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[\.stringO]) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1892,21 +1892,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[\.stringO]) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1986,22 +1986,22 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.stringA = "Value A" - partial.stringB = "Value B" - partial.stringC = "Value C" - partial.stringD = "Value D" - partial.stringE = "Value E" - partial.stringF = "Value F" - partial.stringG = "Value G" - partial.stringH = "Value H" - partial.stringI = "Value I" - partial.stringJ = "Value J" - partial.stringK = "Value K" - partial.stringL = "Value L" - partial.stringM = "Value M" - partial.stringN = "Value N" - partial.stringO = "Value O" - partial.stringP = "Value P" + partial[\.stringA] = "Value A" + partial[\.stringB] = "Value B" + partial[\.stringC] = "Value C" + partial[\.stringD] = "Value D" + partial[\.stringE] = "Value E" + partial[\.stringF] = "Value F" + partial[\.stringG] = "Value G" + partial[\.stringH] = "Value H" + partial[\.stringI] = "Value I" + partial[\.stringJ] = "Value J" + partial[\.stringK] = "Value K" + partial[\.stringL] = "Value L" + partial[\.stringM] = "Value M" + partial[\.stringN] = "Value N" + partial[\.stringO] = "Value O" + partial[\.stringP] = "Value P" } context("the encoded data") { @@ -2021,22 +2021,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" - expect(decodedValue.stringP) == "Value P" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[\.stringO]) == "Value O" + expect(decodedValue[\.stringP]) == "Value P" } catch { fail("Should not throw: \(error)") } @@ -2047,22 +2047,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" - expect(decodedValue.stringP) == "Value P" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[\.stringO]) == "Value O" + expect(decodedValue[\.stringP]) == "Value P" } catch { fail("Should not throw: \(error)") } @@ -2074,22 +2074,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" - expect(decodedValue.stringP) == "Value P" + expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[\.stringO]) == "Value O" + expect(decodedValue[\.stringP]) == "Value P" } catch { fail("Should not throw: \(error)") } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 2d63d850..89f3639f 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -51,7 +51,7 @@ final class PartialBuilder_CodableTests: QuickSpec { beforeEach { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - partial.string${character} = "Value ${character}" + partial[\.string${character}] = "Value ${character}" % end } @@ -74,7 +74,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue.string${character}) == "Value ${character}" + expect(decodedValue[\.string${character}]) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") @@ -88,7 +88,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue.string${character}) == "Value ${character}" + expect(decodedValue[\.string${character}]) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") @@ -103,7 +103,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue.string${character}) == "Value ${character}" + expect(decodedValue[\.string${character}]) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") From a9d3cd75c99a25b931ccc6d3cb7462bfd56ccf26 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:35:31 +0000 Subject: [PATCH 33/42] Swift 5.0 compilation fixes --- .../Tests/Partial+CodableTests.swift | 272 ++--- .../Tests/Partial+CodableTests.swift.gyb | 2 +- .../Tests/PartialBuilder+CodableTests.swift | 1088 ++++++++--------- .../PartialBuilder+CodableTests.swift.gyb | 8 +- 4 files changed, 685 insertions(+), 685 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index 618ff32d..20bb9ad0 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -36,7 +36,7 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" + partial[keyPath: \.stringA] = "Value A" } context("the encoded data") { @@ -104,8 +104,8 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" } context("the encoded data") { @@ -178,9 +178,9 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" } context("the encoded data") { @@ -258,10 +258,10 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" } context("the encoded data") { @@ -344,11 +344,11 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" } context("the encoded data") { @@ -436,12 +436,12 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" } context("the encoded data") { @@ -534,13 +534,13 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" } context("the encoded data") { @@ -638,14 +638,14 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" } context("the encoded data") { @@ -748,15 +748,15 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" } context("the encoded data") { @@ -864,16 +864,16 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" } context("the encoded data") { @@ -986,17 +986,17 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" } context("the encoded data") { @@ -1114,18 +1114,18 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" } context("the encoded data") { @@ -1248,19 +1248,19 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" } context("the encoded data") { @@ -1388,20 +1388,20 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" - partial[\.stringN] = "Value N" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" + partial[keyPath: \.stringN] = "Value N" } context("the encoded data") { @@ -1534,21 +1534,21 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" - partial[\.stringN] = "Value N" - partial[\.stringO] = "Value O" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" + partial[keyPath: \.stringN] = "Value N" + partial[keyPath: \.stringO] = "Value O" } context("the encoded data") { @@ -1686,22 +1686,22 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" - partial[\.stringN] = "Value N" - partial[\.stringO] = "Value O" - partial[\.stringP] = "Value P" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" + partial[keyPath: \.stringN] = "Value N" + partial[keyPath: \.stringO] = "Value O" + partial[keyPath: \.stringP] = "Value P" } context("the encoded data") { diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index abf27ae8..fc333d2f 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -51,7 +51,7 @@ final class Partial_CodableTests: QuickSpec { beforeEach { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - partial[\.string${character}] = "Value ${character}" + partial[keyPath: \.string${character}] = "Value ${character}" % end } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 191c8177..26386fa6 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -36,7 +36,7 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" + partial[keyPath: \.stringA] = "Value A" } context("the encoded data") { @@ -56,7 +56,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringA]) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -67,7 +67,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringA]) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -79,7 +79,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringA]) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -117,8 +117,8 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" } context("the encoded data") { @@ -138,8 +138,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -150,8 +150,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -163,8 +163,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -205,9 +205,9 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" } context("the encoded data") { @@ -227,9 +227,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -240,9 +240,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -254,9 +254,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -300,10 +300,10 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" } context("the encoded data") { @@ -323,10 +323,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -337,10 +337,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -352,10 +352,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -402,11 +402,11 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" } context("the encoded data") { @@ -426,11 +426,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -441,11 +441,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -457,11 +457,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -511,12 +511,12 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" } context("the encoded data") { @@ -536,12 +536,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -552,12 +552,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -569,12 +569,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -627,13 +627,13 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" } context("the encoded data") { @@ -653,13 +653,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -670,13 +670,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -688,13 +688,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -750,14 +750,14 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" } context("the encoded data") { @@ -777,14 +777,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -795,14 +795,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -814,14 +814,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -880,15 +880,15 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" } context("the encoded data") { @@ -908,15 +908,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -927,15 +927,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -947,15 +947,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -1017,16 +1017,16 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" } context("the encoded data") { @@ -1046,16 +1046,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1066,16 +1066,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1087,16 +1087,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1161,17 +1161,17 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" } context("the encoded data") { @@ -1191,17 +1191,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1212,17 +1212,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1234,17 +1234,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1312,18 +1312,18 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" } context("the encoded data") { @@ -1343,18 +1343,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1365,18 +1365,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1388,18 +1388,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1470,19 +1470,19 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" } context("the encoded data") { @@ -1502,19 +1502,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1525,19 +1525,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1549,19 +1549,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1635,20 +1635,20 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" - partial[\.stringN] = "Value N" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" + partial[keyPath: \.stringN] = "Value N" } context("the encoded data") { @@ -1668,20 +1668,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1692,20 +1692,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1717,20 +1717,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1807,21 +1807,21 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" - partial[\.stringN] = "Value N" - partial[\.stringO] = "Value O" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" + partial[keyPath: \.stringN] = "Value N" + partial[keyPath: \.stringO] = "Value O" } context("the encoded data") { @@ -1841,21 +1841,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" - expect(decodedValue[\.stringO]) == "Value O" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringO]) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1866,21 +1866,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" - expect(decodedValue[\.stringO]) == "Value O" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringO]) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1892,21 +1892,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" - expect(decodedValue[\.stringO]) == "Value O" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringO]) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1986,22 +1986,22 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[\.stringA] = "Value A" - partial[\.stringB] = "Value B" - partial[\.stringC] = "Value C" - partial[\.stringD] = "Value D" - partial[\.stringE] = "Value E" - partial[\.stringF] = "Value F" - partial[\.stringG] = "Value G" - partial[\.stringH] = "Value H" - partial[\.stringI] = "Value I" - partial[\.stringJ] = "Value J" - partial[\.stringK] = "Value K" - partial[\.stringL] = "Value L" - partial[\.stringM] = "Value M" - partial[\.stringN] = "Value N" - partial[\.stringO] = "Value O" - partial[\.stringP] = "Value P" + partial[keyPath: \.stringA] = "Value A" + partial[keyPath: \.stringB] = "Value B" + partial[keyPath: \.stringC] = "Value C" + partial[keyPath: \.stringD] = "Value D" + partial[keyPath: \.stringE] = "Value E" + partial[keyPath: \.stringF] = "Value F" + partial[keyPath: \.stringG] = "Value G" + partial[keyPath: \.stringH] = "Value H" + partial[keyPath: \.stringI] = "Value I" + partial[keyPath: \.stringJ] = "Value J" + partial[keyPath: \.stringK] = "Value K" + partial[keyPath: \.stringL] = "Value L" + partial[keyPath: \.stringM] = "Value M" + partial[keyPath: \.stringN] = "Value N" + partial[keyPath: \.stringO] = "Value O" + partial[keyPath: \.stringP] = "Value P" } context("the encoded data") { @@ -2021,22 +2021,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" - expect(decodedValue[\.stringO]) == "Value O" - expect(decodedValue[\.stringP]) == "Value P" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringO]) == "Value O" + expect(decodedValue[keyPath: \.stringP]) == "Value P" } catch { fail("Should not throw: \(error)") } @@ -2047,22 +2047,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" - expect(decodedValue[\.stringO]) == "Value O" - expect(decodedValue[\.stringP]) == "Value P" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringO]) == "Value O" + expect(decodedValue[keyPath: \.stringP]) == "Value P" } catch { fail("Should not throw: \(error)") } @@ -2074,22 +2074,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[\.stringA]) == "Value A" - expect(decodedValue[\.stringB]) == "Value B" - expect(decodedValue[\.stringC]) == "Value C" - expect(decodedValue[\.stringD]) == "Value D" - expect(decodedValue[\.stringE]) == "Value E" - expect(decodedValue[\.stringF]) == "Value F" - expect(decodedValue[\.stringG]) == "Value G" - expect(decodedValue[\.stringH]) == "Value H" - expect(decodedValue[\.stringI]) == "Value I" - expect(decodedValue[\.stringJ]) == "Value J" - expect(decodedValue[\.stringK]) == "Value K" - expect(decodedValue[\.stringL]) == "Value L" - expect(decodedValue[\.stringM]) == "Value M" - expect(decodedValue[\.stringN]) == "Value N" - expect(decodedValue[\.stringO]) == "Value O" - expect(decodedValue[\.stringP]) == "Value P" + expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue[keyPath: \.stringO]) == "Value O" + expect(decodedValue[keyPath: \.stringP]) == "Value P" } catch { fail("Should not throw: \(error)") } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 89f3639f..9bb2447c 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -51,7 +51,7 @@ final class PartialBuilder_CodableTests: QuickSpec { beforeEach { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - partial[\.string${character}] = "Value ${character}" + partial[keyPath: \.string${character}] = "Value ${character}" % end } @@ -74,7 +74,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue[\.string${character}]) == "Value ${character}" + expect(decodedValue[keyPath: \.string${character}]) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") @@ -88,7 +88,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue[\.string${character}]) == "Value ${character}" + expect(decodedValue[keyPath: \.string${character}]) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") @@ -103,7 +103,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue[\.string${character}]) == "Value ${character}" + expect(decodedValue[keyPath: \.string${character}]) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") From 5c685b29acb4bc610d867a47b27e22fe1fdfae03 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:43:18 +0000 Subject: [PATCH 34/42] Tell GitHub how to highlight .swift.gyb files --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..c93c7bac --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.swift.gyb linguist-language=Swift From ad7479116224295e59a04b450cbd3de3c8d669c0 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:53:47 +0000 Subject: [PATCH 35/42] Remove subscript use (fix Swift < 5.2) --- .../Tests/Partial+CodableTests.swift | 272 ++--- .../Tests/Partial+CodableTests.swift.gyb | 2 +- .../Tests/PartialBuilder+CodableTests.swift | 1088 ++++++++--------- .../PartialBuilder+CodableTests.swift.gyb | 8 +- 4 files changed, 685 insertions(+), 685 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index 20bb9ad0..7c155fcc 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -36,7 +36,7 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" + partial.setValue("Value A", for: \.stringA) } context("the encoded data") { @@ -104,8 +104,8 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) } context("the encoded data") { @@ -178,9 +178,9 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) } context("the encoded data") { @@ -258,10 +258,10 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) } context("the encoded data") { @@ -344,11 +344,11 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) } context("the encoded data") { @@ -436,12 +436,12 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) } context("the encoded data") { @@ -534,13 +534,13 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) } context("the encoded data") { @@ -638,14 +638,14 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) } context("the encoded data") { @@ -748,15 +748,15 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) } context("the encoded data") { @@ -864,16 +864,16 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) } context("the encoded data") { @@ -986,17 +986,17 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) } context("the encoded data") { @@ -1114,18 +1114,18 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) } context("the encoded data") { @@ -1248,19 +1248,19 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) } context("the encoded data") { @@ -1388,20 +1388,20 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" - partial[keyPath: \.stringN] = "Value N" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) } context("the encoded data") { @@ -1534,21 +1534,21 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" - partial[keyPath: \.stringN] = "Value N" - partial[keyPath: \.stringO] = "Value O" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) + partial.setValue("Value O", for: \.stringO) } context("the encoded data") { @@ -1686,22 +1686,22 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" - partial[keyPath: \.stringN] = "Value N" - partial[keyPath: \.stringO] = "Value O" - partial[keyPath: \.stringP] = "Value P" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) + partial.setValue("Value O", for: \.stringO) + partial.setValue("Value P", for: \.stringP) } context("the encoded data") { diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index fc333d2f..4acb77d6 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -51,7 +51,7 @@ final class Partial_CodableTests: QuickSpec { beforeEach { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - partial[keyPath: \.string${character}] = "Value ${character}" + partial.setValue("Value ${character}", for: \.string${character}) % end } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 26386fa6..3c1d1a9b 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -36,7 +36,7 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" + partial.setValue("Value A", for: \.stringA) } context("the encoded data") { @@ -56,7 +56,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue.stringA) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -67,7 +67,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue.stringA) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -79,7 +79,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" + expect(decodedValue.stringA) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -117,8 +117,8 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) } context("the encoded data") { @@ -138,8 +138,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -150,8 +150,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -163,8 +163,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -205,9 +205,9 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) } context("the encoded data") { @@ -227,9 +227,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -240,9 +240,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -254,9 +254,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -300,10 +300,10 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) } context("the encoded data") { @@ -323,10 +323,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -337,10 +337,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -352,10 +352,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -402,11 +402,11 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) } context("the encoded data") { @@ -426,11 +426,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -441,11 +441,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -457,11 +457,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -511,12 +511,12 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) } context("the encoded data") { @@ -536,12 +536,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -552,12 +552,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -569,12 +569,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -627,13 +627,13 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) } context("the encoded data") { @@ -653,13 +653,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -670,13 +670,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -688,13 +688,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -750,14 +750,14 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) } context("the encoded data") { @@ -777,14 +777,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -795,14 +795,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -814,14 +814,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -880,15 +880,15 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) } context("the encoded data") { @@ -908,15 +908,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -927,15 +927,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -947,15 +947,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -1017,16 +1017,16 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) } context("the encoded data") { @@ -1046,16 +1046,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1066,16 +1066,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1087,16 +1087,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1161,17 +1161,17 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) } context("the encoded data") { @@ -1191,17 +1191,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1212,17 +1212,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1234,17 +1234,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1312,18 +1312,18 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) } context("the encoded data") { @@ -1343,18 +1343,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1365,18 +1365,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1388,18 +1388,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1470,19 +1470,19 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) } context("the encoded data") { @@ -1502,19 +1502,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1525,19 +1525,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1549,19 +1549,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1635,20 +1635,20 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" - partial[keyPath: \.stringN] = "Value N" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) } context("the encoded data") { @@ -1668,20 +1668,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1692,20 +1692,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1717,20 +1717,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1807,21 +1807,21 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" - partial[keyPath: \.stringN] = "Value N" - partial[keyPath: \.stringO] = "Value O" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) + partial.setValue("Value O", for: \.stringO) } context("the encoded data") { @@ -1841,21 +1841,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" - expect(decodedValue[keyPath: \.stringO]) == "Value O" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1866,21 +1866,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" - expect(decodedValue[keyPath: \.stringO]) == "Value O" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1892,21 +1892,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" - expect(decodedValue[keyPath: \.stringO]) == "Value O" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1986,22 +1986,22 @@ final class PartialBuilder_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial[keyPath: \.stringA] = "Value A" - partial[keyPath: \.stringB] = "Value B" - partial[keyPath: \.stringC] = "Value C" - partial[keyPath: \.stringD] = "Value D" - partial[keyPath: \.stringE] = "Value E" - partial[keyPath: \.stringF] = "Value F" - partial[keyPath: \.stringG] = "Value G" - partial[keyPath: \.stringH] = "Value H" - partial[keyPath: \.stringI] = "Value I" - partial[keyPath: \.stringJ] = "Value J" - partial[keyPath: \.stringK] = "Value K" - partial[keyPath: \.stringL] = "Value L" - partial[keyPath: \.stringM] = "Value M" - partial[keyPath: \.stringN] = "Value N" - partial[keyPath: \.stringO] = "Value O" - partial[keyPath: \.stringP] = "Value P" + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) + partial.setValue("Value O", for: \.stringO) + partial.setValue("Value P", for: \.stringP) } context("the encoded data") { @@ -2021,22 +2021,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(CodableType.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" - expect(decodedValue[keyPath: \.stringO]) == "Value O" - expect(decodedValue[keyPath: \.stringP]) == "Value P" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" } catch { fail("Should not throw: \(error)") } @@ -2047,22 +2047,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" - expect(decodedValue[keyPath: \.stringO]) == "Value O" - expect(decodedValue[keyPath: \.stringP]) == "Value P" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" } catch { fail("Should not throw: \(error)") } @@ -2074,22 +2074,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(PartialBuilder.self, from: encodedData) - expect(decodedValue[keyPath: \.stringA]) == "Value A" - expect(decodedValue[keyPath: \.stringB]) == "Value B" - expect(decodedValue[keyPath: \.stringC]) == "Value C" - expect(decodedValue[keyPath: \.stringD]) == "Value D" - expect(decodedValue[keyPath: \.stringE]) == "Value E" - expect(decodedValue[keyPath: \.stringF]) == "Value F" - expect(decodedValue[keyPath: \.stringG]) == "Value G" - expect(decodedValue[keyPath: \.stringH]) == "Value H" - expect(decodedValue[keyPath: \.stringI]) == "Value I" - expect(decodedValue[keyPath: \.stringJ]) == "Value J" - expect(decodedValue[keyPath: \.stringK]) == "Value K" - expect(decodedValue[keyPath: \.stringL]) == "Value L" - expect(decodedValue[keyPath: \.stringM]) == "Value M" - expect(decodedValue[keyPath: \.stringN]) == "Value N" - expect(decodedValue[keyPath: \.stringO]) == "Value O" - expect(decodedValue[keyPath: \.stringP]) == "Value P" + expect(decodedValue.stringA) == "Value A" + expect(decodedValue.stringB) == "Value B" + expect(decodedValue.stringC) == "Value C" + expect(decodedValue.stringD) == "Value D" + expect(decodedValue.stringE) == "Value E" + expect(decodedValue.stringF) == "Value F" + expect(decodedValue.stringG) == "Value G" + expect(decodedValue.stringH) == "Value H" + expect(decodedValue.stringI) == "Value I" + expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.stringK) == "Value K" + expect(decodedValue.stringL) == "Value L" + expect(decodedValue.stringM) == "Value M" + expect(decodedValue.stringN) == "Value N" + expect(decodedValue.stringO) == "Value O" + expect(decodedValue.stringP) == "Value P" } catch { fail("Should not throw: \(error)") } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 9bb2447c..4aae989d 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -51,7 +51,7 @@ final class PartialBuilder_CodableTests: QuickSpec { beforeEach { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - partial[keyPath: \.string${character}] = "Value ${character}" + partial.setValue("Value ${character}", for: \.string${character}) % end } @@ -74,7 +74,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue[keyPath: \.string${character}]) == "Value ${character}" + expect(decodedValue.string${character}) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") @@ -88,7 +88,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue[keyPath: \.string${character}]) == "Value ${character}" + expect(decodedValue.string${character}) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") @@ -103,7 +103,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue[keyPath: \.string${character}]) == "Value ${character}" + expect(decodedValue.string${character}) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") From b7b9a539989147ea3c32395c8ef0f5f08377fad9 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 01:57:42 +0000 Subject: [PATCH 36/42] Swift < 5.1 fixes --- .../Tests/PartialBuilder+CodableTests.swift | 272 +++++++++--------- .../PartialBuilder+CodableTests.swift.gyb | 2 +- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 3c1d1a9b..911295d8 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -67,7 +67,7 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -150,8 +150,8 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -240,9 +240,9 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -337,10 +337,10 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -441,11 +441,11 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -552,12 +552,12 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -670,13 +670,13 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -795,14 +795,14 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -927,15 +927,15 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -1066,16 +1066,16 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1212,17 +1212,17 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1365,18 +1365,18 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1525,19 +1525,19 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1692,20 +1692,20 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" + expect(try? decodedValue.value(for: \.stringN)) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1866,21 +1866,21 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" + expect(try? decodedValue.value(for: \.stringN)) == "Value N" + expect(try? decodedValue.value(for: \.stringO)) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -2047,22 +2047,22 @@ final class PartialBuilder_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" - expect(decodedValue.stringP) == "Value P" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" + expect(try? decodedValue.value(for: \.stringN)) == "Value N" + expect(try? decodedValue.value(for: \.stringO)) == "Value O" + expect(try? decodedValue.value(for: \.stringP)) == "Value P" } catch { fail("Should not throw: \(error)") } diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index 4aae989d..d35db330 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -88,7 +88,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue.string${character}) == "Value ${character}" + expect(try? decodedValue.value(for: \.string${character})) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") From c000dd4bbde559dd02bbe975a78c5b506bc33323 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 02:04:30 +0000 Subject: [PATCH 37/42] Swift < 5.1 fixes --- .../Tests/PartialBuilder+CodableTests.swift | 32 +++++++++---------- .../PartialBuilder+CodableTests.swift.gyb | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift index 911295d8..13d7864e 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift @@ -18,7 +18,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringA, CodingKeys.stringA) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) return collection @@ -97,7 +97,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringB, CodingKeys.stringB) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -183,7 +183,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringC, CodingKeys.stringC) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -276,7 +276,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringD, CodingKeys.stringD) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -376,7 +376,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringE, CodingKeys.stringE) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -483,7 +483,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringF, CodingKeys.stringF) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -597,7 +597,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringG, CodingKeys.stringG) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -718,7 +718,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringH, CodingKeys.stringH) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -846,7 +846,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringI, CodingKeys.stringI) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -981,7 +981,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringJ, CodingKeys.stringJ) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -1123,7 +1123,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringK, CodingKeys.stringK) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -1272,7 +1272,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringL, CodingKeys.stringL) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -1428,7 +1428,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringM, CodingKeys.stringM) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -1591,7 +1591,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringN, CodingKeys.stringN) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -1761,7 +1761,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringO, CodingKeys.stringO) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) @@ -1938,7 +1938,7 @@ final class PartialBuilder_CodableTests: QuickSpec { (\Self.stringP, CodingKeys.stringP) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) diff --git a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb index d35db330..b6ceea75 100644 --- a/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/PartialBuilder+CodableTests.swift.gyb @@ -25,7 +25,7 @@ final class PartialBuilder_CodableTests: QuickSpec { % end } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { var collection = KeyPathCodingKeyCollection() % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] From 045ce70bc415f6101e840969b2c6088ce15f3951 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 02:08:43 +0000 Subject: [PATCH 38/42] Swift < 5.1 fixes --- .../Tests/Partial+CodableTests.swift | 64 +++++++++---------- .../Tests/Partial+CodableTests.swift.gyb | 4 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index 7c155fcc..4dac74c1 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -18,8 +18,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringA, CodingKeys.stringA) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) return collection } @@ -84,8 +84,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringB, CodingKeys.stringB) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) return collection @@ -156,8 +156,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringC, CodingKeys.stringC) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -234,8 +234,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringD, CodingKeys.stringD) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -318,8 +318,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringE, CodingKeys.stringE) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -408,8 +408,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringF, CodingKeys.stringF) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -504,8 +504,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringG, CodingKeys.stringG) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -606,8 +606,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringH, CodingKeys.stringH) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -714,8 +714,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringI, CodingKeys.stringI) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -828,8 +828,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringJ, CodingKeys.stringJ) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -948,8 +948,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringK, CodingKeys.stringK) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1074,8 +1074,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringL, CodingKeys.stringL) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1206,8 +1206,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringM, CodingKeys.stringM) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1344,8 +1344,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringN, CodingKeys.stringN) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1488,8 +1488,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringO, CodingKeys.stringO) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) @@ -1638,8 +1638,8 @@ final class Partial_CodableTests: QuickSpec { (\Self.stringP, CodingKeys.stringP) } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() collection.addPair(keyPath: \.stringA, codingKey: .stringA) collection.addPair(keyPath: \.stringB, codingKey: .stringB) collection.addPair(keyPath: \.stringC, codingKey: .stringC) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index 4acb77d6..05887fc0 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -25,8 +25,8 @@ final class Partial_CodableTests: QuickSpec { % end } #else - static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { - var collection = KeyPathCodingKeyCollection() + static var keyPathCodingKeyCollection: KeyPathCodingKeyCollection { + var collection = KeyPathCodingKeyCollection() % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] collection.addPair(keyPath: \.string${character}, codingKey: .string${character}) From 7a238c86a10474fc0d58ccd53b2f27302c609975 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 02:11:35 +0000 Subject: [PATCH 39/42] Swift < 5.1 fixes --- .../Tests/Partial+CodableTests.swift | 272 +++++++++--------- .../Tests/Partial+CodableTests.swift.gyb | 2 +- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index 4dac74c1..a6ed0af4 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -67,7 +67,7 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" + expect(decodedValue.value(for: \.stringA)) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -137,8 +137,8 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -213,9 +213,9 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -295,10 +295,10 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -383,11 +383,11 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -477,12 +477,12 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -577,13 +577,13 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -683,14 +683,14 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -795,15 +795,15 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -913,16 +913,16 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(decodedValue.value(for: \.stringJ)) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1037,17 +1037,17 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(decodedValue.value(for: \.stringJ)) == "Value J" + expect(decodedValue.value(for: \.stringK)) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1167,18 +1167,18 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(decodedValue.value(for: \.stringJ)) == "Value J" + expect(decodedValue.value(for: \.stringK)) == "Value K" + expect(decodedValue.value(for: \.stringL)) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1303,19 +1303,19 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(decodedValue.value(for: \.stringJ)) == "Value J" + expect(decodedValue.value(for: \.stringK)) == "Value K" + expect(decodedValue.value(for: \.stringL)) == "Value L" + expect(decodedValue.value(for: \.stringM)) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1445,20 +1445,20 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(decodedValue.value(for: \.stringJ)) == "Value J" + expect(decodedValue.value(for: \.stringK)) == "Value K" + expect(decodedValue.value(for: \.stringL)) == "Value L" + expect(decodedValue.value(for: \.stringM)) == "Value M" + expect(decodedValue.value(for: \.stringN)) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1593,21 +1593,21 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(decodedValue.value(for: \.stringJ)) == "Value J" + expect(decodedValue.value(for: \.stringK)) == "Value K" + expect(decodedValue.value(for: \.stringL)) == "Value L" + expect(decodedValue.value(for: \.stringM)) == "Value M" + expect(decodedValue.value(for: \.stringN)) == "Value N" + expect(decodedValue.value(for: \.stringO)) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1747,22 +1747,22 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.stringA) == "Value A" - expect(decodedValue.stringB) == "Value B" - expect(decodedValue.stringC) == "Value C" - expect(decodedValue.stringD) == "Value D" - expect(decodedValue.stringE) == "Value E" - expect(decodedValue.stringF) == "Value F" - expect(decodedValue.stringG) == "Value G" - expect(decodedValue.stringH) == "Value H" - expect(decodedValue.stringI) == "Value I" - expect(decodedValue.stringJ) == "Value J" - expect(decodedValue.stringK) == "Value K" - expect(decodedValue.stringL) == "Value L" - expect(decodedValue.stringM) == "Value M" - expect(decodedValue.stringN) == "Value N" - expect(decodedValue.stringO) == "Value O" - expect(decodedValue.stringP) == "Value P" + expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(decodedValue.value(for: \.stringJ)) == "Value J" + expect(decodedValue.value(for: \.stringK)) == "Value K" + expect(decodedValue.value(for: \.stringL)) == "Value L" + expect(decodedValue.value(for: \.stringM)) == "Value M" + expect(decodedValue.value(for: \.stringN)) == "Value N" + expect(decodedValue.value(for: \.stringO)) == "Value O" + expect(decodedValue.value(for: \.stringP)) == "Value P" } catch { fail("Should not throw: \(error)") } diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index 05887fc0..8100ab8e 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -88,7 +88,7 @@ final class Partial_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue.string${character}) == "Value ${character}" + expect(decodedValue.value(for: \.string${character})) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") From 57f24cc45bf5d5ed689608aaaf22484a98888738 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 02:14:46 +0000 Subject: [PATCH 40/42] Test compilation fix --- .../Tests/Partial+CodableTests.swift | 272 +++++++++--------- .../Tests/Partial+CodableTests.swift.gyb | 2 +- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index a6ed0af4..c825b53c 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -67,7 +67,7 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" } catch { fail("Should not throw: \(error)") } @@ -137,8 +137,8 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" } catch { fail("Should not throw: \(error)") } @@ -213,9 +213,9 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" } catch { fail("Should not throw: \(error)") } @@ -295,10 +295,10 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" } catch { fail("Should not throw: \(error)") } @@ -383,11 +383,11 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" } catch { fail("Should not throw: \(error)") } @@ -477,12 +477,12 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" } catch { fail("Should not throw: \(error)") } @@ -577,13 +577,13 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" } catch { fail("Should not throw: \(error)") } @@ -683,14 +683,14 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" } catch { fail("Should not throw: \(error)") } @@ -795,15 +795,15 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" } catch { fail("Should not throw: \(error)") } @@ -913,16 +913,16 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" - expect(decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" } catch { fail("Should not throw: \(error)") } @@ -1037,17 +1037,17 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" - expect(decodedValue.value(for: \.stringJ)) == "Value J" - expect(decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" } catch { fail("Should not throw: \(error)") } @@ -1167,18 +1167,18 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" - expect(decodedValue.value(for: \.stringJ)) == "Value J" - expect(decodedValue.value(for: \.stringK)) == "Value K" - expect(decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" } catch { fail("Should not throw: \(error)") } @@ -1303,19 +1303,19 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" - expect(decodedValue.value(for: \.stringJ)) == "Value J" - expect(decodedValue.value(for: \.stringK)) == "Value K" - expect(decodedValue.value(for: \.stringL)) == "Value L" - expect(decodedValue.value(for: \.stringM)) == "Value M" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" } catch { fail("Should not throw: \(error)") } @@ -1445,20 +1445,20 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" - expect(decodedValue.value(for: \.stringJ)) == "Value J" - expect(decodedValue.value(for: \.stringK)) == "Value K" - expect(decodedValue.value(for: \.stringL)) == "Value L" - expect(decodedValue.value(for: \.stringM)) == "Value M" - expect(decodedValue.value(for: \.stringN)) == "Value N" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" + expect(try? decodedValue.value(for: \.stringN)) == "Value N" } catch { fail("Should not throw: \(error)") } @@ -1593,21 +1593,21 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" - expect(decodedValue.value(for: \.stringJ)) == "Value J" - expect(decodedValue.value(for: \.stringK)) == "Value K" - expect(decodedValue.value(for: \.stringL)) == "Value L" - expect(decodedValue.value(for: \.stringM)) == "Value M" - expect(decodedValue.value(for: \.stringN)) == "Value N" - expect(decodedValue.value(for: \.stringO)) == "Value O" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" + expect(try? decodedValue.value(for: \.stringN)) == "Value N" + expect(try? decodedValue.value(for: \.stringO)) == "Value O" } catch { fail("Should not throw: \(error)") } @@ -1747,22 +1747,22 @@ final class Partial_CodableTests: QuickSpec { let decoder = JSONDecoder() let decodedValue = try decoder.decode(Partial.self, from: encodedData) - expect(decodedValue.value(for: \.stringA)) == "Value A" - expect(decodedValue.value(for: \.stringB)) == "Value B" - expect(decodedValue.value(for: \.stringC)) == "Value C" - expect(decodedValue.value(for: \.stringD)) == "Value D" - expect(decodedValue.value(for: \.stringE)) == "Value E" - expect(decodedValue.value(for: \.stringF)) == "Value F" - expect(decodedValue.value(for: \.stringG)) == "Value G" - expect(decodedValue.value(for: \.stringH)) == "Value H" - expect(decodedValue.value(for: \.stringI)) == "Value I" - expect(decodedValue.value(for: \.stringJ)) == "Value J" - expect(decodedValue.value(for: \.stringK)) == "Value K" - expect(decodedValue.value(for: \.stringL)) == "Value L" - expect(decodedValue.value(for: \.stringM)) == "Value M" - expect(decodedValue.value(for: \.stringN)) == "Value N" - expect(decodedValue.value(for: \.stringO)) == "Value O" - expect(decodedValue.value(for: \.stringP)) == "Value P" + expect(try? decodedValue.value(for: \.stringA)) == "Value A" + expect(try? decodedValue.value(for: \.stringB)) == "Value B" + expect(try? decodedValue.value(for: \.stringC)) == "Value C" + expect(try? decodedValue.value(for: \.stringD)) == "Value D" + expect(try? decodedValue.value(for: \.stringE)) == "Value E" + expect(try? decodedValue.value(for: \.stringF)) == "Value F" + expect(try? decodedValue.value(for: \.stringG)) == "Value G" + expect(try? decodedValue.value(for: \.stringH)) == "Value H" + expect(try? decodedValue.value(for: \.stringI)) == "Value I" + expect(try? decodedValue.value(for: \.stringJ)) == "Value J" + expect(try? decodedValue.value(for: \.stringK)) == "Value K" + expect(try? decodedValue.value(for: \.stringL)) == "Value L" + expect(try? decodedValue.value(for: \.stringM)) == "Value M" + expect(try? decodedValue.value(for: \.stringN)) == "Value N" + expect(try? decodedValue.value(for: \.stringO)) == "Value O" + expect(try? decodedValue.value(for: \.stringP)) == "Value P" } catch { fail("Should not throw: \(error)") } diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index 8100ab8e..ec5ed782 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -88,7 +88,7 @@ final class Partial_CodableTests: QuickSpec { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - expect(decodedValue.value(for: \.string${character})) == "Value ${character}" + expect(try? decodedValue.value(for: \.string${character})) == "Value ${character}" % end } catch { fail("Should not throw: \(error)") From e177e28285a38b21f2abf791d25e5834fbf23502 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 02:24:00 +0000 Subject: [PATCH 41/42] Remove trailing whitespace --- .../Tests/Partial+CodableTests.swift | 272 +++++++++--------- .../Tests/Partial+CodableTests.swift.gyb | 2 +- 2 files changed, 137 insertions(+), 137 deletions(-) diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift b/Tests/PartialTests/Tests/Partial+CodableTests.swift index c825b53c..63f28cfb 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift @@ -36,7 +36,7 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) + partial.setValue("Value A", for: \.stringA) } context("the encoded data") { @@ -104,8 +104,8 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) } context("the encoded data") { @@ -178,9 +178,9 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) } context("the encoded data") { @@ -258,10 +258,10 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) } context("the encoded data") { @@ -344,11 +344,11 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) } context("the encoded data") { @@ -436,12 +436,12 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) } context("the encoded data") { @@ -534,13 +534,13 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) } context("the encoded data") { @@ -638,14 +638,14 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) } context("the encoded data") { @@ -748,15 +748,15 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) } context("the encoded data") { @@ -864,16 +864,16 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) - partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) } context("the encoded data") { @@ -986,17 +986,17 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) - partial.setValue("Value J", for: \.stringJ) - partial.setValue("Value K", for: \.stringK) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) } context("the encoded data") { @@ -1114,18 +1114,18 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) - partial.setValue("Value J", for: \.stringJ) - partial.setValue("Value K", for: \.stringK) - partial.setValue("Value L", for: \.stringL) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) } context("the encoded data") { @@ -1248,19 +1248,19 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) - partial.setValue("Value J", for: \.stringJ) - partial.setValue("Value K", for: \.stringK) - partial.setValue("Value L", for: \.stringL) - partial.setValue("Value M", for: \.stringM) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) } context("the encoded data") { @@ -1388,20 +1388,20 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) - partial.setValue("Value J", for: \.stringJ) - partial.setValue("Value K", for: \.stringK) - partial.setValue("Value L", for: \.stringL) - partial.setValue("Value M", for: \.stringM) - partial.setValue("Value N", for: \.stringN) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) } context("the encoded data") { @@ -1534,21 +1534,21 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) - partial.setValue("Value J", for: \.stringJ) - partial.setValue("Value K", for: \.stringK) - partial.setValue("Value L", for: \.stringL) - partial.setValue("Value M", for: \.stringM) - partial.setValue("Value N", for: \.stringN) - partial.setValue("Value O", for: \.stringO) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) + partial.setValue("Value O", for: \.stringO) } context("the encoded data") { @@ -1686,22 +1686,22 @@ final class Partial_CodableTests: QuickSpec { context("with complete value") { beforeEach { - partial.setValue("Value A", for: \.stringA) - partial.setValue("Value B", for: \.stringB) - partial.setValue("Value C", for: \.stringC) - partial.setValue("Value D", for: \.stringD) - partial.setValue("Value E", for: \.stringE) - partial.setValue("Value F", for: \.stringF) - partial.setValue("Value G", for: \.stringG) - partial.setValue("Value H", for: \.stringH) - partial.setValue("Value I", for: \.stringI) - partial.setValue("Value J", for: \.stringJ) - partial.setValue("Value K", for: \.stringK) - partial.setValue("Value L", for: \.stringL) - partial.setValue("Value M", for: \.stringM) - partial.setValue("Value N", for: \.stringN) - partial.setValue("Value O", for: \.stringO) - partial.setValue("Value P", for: \.stringP) + partial.setValue("Value A", for: \.stringA) + partial.setValue("Value B", for: \.stringB) + partial.setValue("Value C", for: \.stringC) + partial.setValue("Value D", for: \.stringD) + partial.setValue("Value E", for: \.stringE) + partial.setValue("Value F", for: \.stringF) + partial.setValue("Value G", for: \.stringG) + partial.setValue("Value H", for: \.stringH) + partial.setValue("Value I", for: \.stringI) + partial.setValue("Value J", for: \.stringJ) + partial.setValue("Value K", for: \.stringK) + partial.setValue("Value L", for: \.stringL) + partial.setValue("Value M", for: \.stringM) + partial.setValue("Value N", for: \.stringN) + partial.setValue("Value O", for: \.stringO) + partial.setValue("Value P", for: \.stringP) } context("the encoded data") { diff --git a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb index ec5ed782..51734637 100644 --- a/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb +++ b/Tests/PartialTests/Tests/Partial+CodableTests.swift.gyb @@ -51,7 +51,7 @@ final class Partial_CodableTests: QuickSpec { beforeEach { % for characterIndex in parametersRange: % character = string.ascii_uppercase[characterIndex] - partial.setValue("Value ${character}", for: \.string${character}) + partial.setValue("Value ${character}", for: \.string${character}) % end } From 79f8225c8eeed1329862567880cfc219f18f2c06 Mon Sep 17 00:00:00 2001 From: Joseph Duffy Date: Sun, 14 Feb 2021 21:16:20 +0000 Subject: [PATCH 42/42] Include all sources in Podspec --- Partial.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Partial.podspec b/Partial.podspec index b8824bd5..6d7b6c93 100644 --- a/Partial.podspec +++ b/Partial.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |spec| :git => "https://github.com/JosephDuffy/Partial.git", :tag => "v#{spec.version}" } - spec.source_files = "Sources/Partial/*.swift" + spec.source_files = "Sources/Partial/**/*.swift" spec.osx.deployment_target = "10.10" spec.ios.deployment_target = "8.0" spec.tvos.deployment_target = "9.0"