@@ -33,6 +33,7 @@ struct Nested : KeyPathIterable, Equatable {
33
33
struct ComplexNested : KeyPathIterable , Equatable {
34
34
var float : Float
35
35
let simple : Simple
36
+ let optional : Simple ?
36
37
let array : [ Simple ]
37
38
var dictionary : [ String : Simple ]
38
39
}
@@ -125,16 +126,22 @@ KeyPathIterableTests.test("SimpleNested") {
125
126
126
127
KeyPathIterableTests . test ( " ComplexNested " ) {
127
128
var x = ComplexNested ( float: 1 , simple: Simple ( w: 3 , b: 4 ) ,
129
+ optional: Simple ( w: 5 , b: 6 ) ,
128
130
array: [ Simple ( w: 5 , b: 6 ) , Simple ( w: 7 , b: 8 ) ] ,
129
131
dictionary: [ " foo " : Simple ( w: 1 , b: 2 ) ,
130
132
" bar " : Simple ( w: 3 , b: 4 ) ] )
131
133
expectEqual ( [ \ComplexNested . float, \ComplexNested . simple,
132
- \ComplexNested . array, \ComplexNested . dictionary] ,
134
+ \ComplexNested . optional, \ComplexNested . array,
135
+ \ComplexNested . dictionary] ,
133
136
x. allKeyPaths)
134
137
expectEqual ( [ \ComplexNested . float,
135
138
\ComplexNested . simple,
136
139
\ComplexNested . simple. w,
137
140
\ComplexNested . simple. b,
141
+ \ComplexNested . optional,
142
+ \ComplexNested . optional!,
143
+ \ComplexNested . optional!. w,
144
+ \ComplexNested . optional!. b,
138
145
\ComplexNested . array,
139
146
\ComplexNested . array [ 0 ] ,
140
147
\ComplexNested . array [ 0 ] . w,
@@ -153,6 +160,8 @@ KeyPathIterableTests.test("ComplexNested") {
153
160
expectEqual ( [ \ComplexNested . float,
154
161
\ComplexNested . simple. w,
155
162
\ComplexNested . simple. b,
163
+ \ComplexNested . optional!. w,
164
+ \ComplexNested . optional!. b,
156
165
\ComplexNested . array [ 0 ] . w,
157
166
\ComplexNested . array [ 0 ] . b,
158
167
\ComplexNested . array [ 1 ] . w,
@@ -175,6 +184,7 @@ KeyPathIterableTests.test("ComplexNested") {
175
184
}
176
185
// Check that recursively all `Float` properties have been mutated.
177
186
let expected = ComplexNested ( float: 2 , simple: Simple ( w: 3 , b: 4 ) ,
187
+ optional: Simple ( w: 5 , b: 6 ) ,
178
188
array: [ Simple ( w: 5 , b: 6 ) , Simple ( w: 7 , b: 8 ) ] ,
179
189
dictionary: [ " foo " : Simple ( w: 2 , b: 3 ) ,
180
190
" bar " : Simple ( w: 4 , b: 5 ) ] )
0 commit comments