Skip to content

Commit 694bb58

Browse files
committed
Update merge test case for PropertyList
1 parent 3438ace commit 694bb58

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

Sources/OpenSwiftUICore/Data/PropertyList.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,15 @@ package struct PropertyList: CustomStringConvertible {
202202
}
203203

204204
package mutating func merge(_ plist: PropertyList) {
205-
preconditionFailure("TODO")
205+
// preconditionFailure("TODO")
206+
207+
var copyCount = 0
208+
guard copyCount != 0 else {
209+
return
210+
}
211+
withUnsafeTuple(of: TupleType(Element.self), count: copyCount) { tuple in
212+
// TODO
213+
}
206214
}
207215

208216
package func merging(_ other: PropertyList) -> PropertyList {

Tests/OpenSwiftUICoreTests/Data/PropertyListTests.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct PropertyListTests {
104104
}
105105

106106
@Test
107-
func description() throws {
107+
func description() {
108108
var plist = PropertyList()
109109
#expect(plist.description == "[]")
110110

@@ -124,6 +124,24 @@ struct PropertyListTests {
124124
plist[IntKey.self] = value
125125
#expect(plist.description == "[\(IntKey.self) = \(value), \(BoolKey.self) = \(bool), \(BoolKey.self) = \(BoolKey.defaultValue)]")
126126
}
127+
128+
@Test
129+
func merging() {
130+
var plist1 = PropertyList()
131+
plist1[IntKey.self] = 42
132+
var plist2 = PropertyList()
133+
plist2[StringKey.self] = "Hello"
134+
135+
let plist3 = plist1.merging(plist2)
136+
let plist4 = plist2.merging(plist1)
137+
138+
#expect(plist3.description == #"""
139+
[StringKey = Hello, IntKey = 42]
140+
"""#)
141+
#expect(plist4.description == #"""
142+
[IntKey = 42, StringKey = Hello]
143+
"""#)
144+
}
127145
}
128146

129147
struct PropertyListTrackerTests {

Tests/OpenSwiftUISymbolDualTests/Data/PropertyListTests.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct PropertyListTests {
163163
}
164164

165165
@Test
166-
func description() throws {
166+
func description() {
167167
var plist = PropertyList(swiftUI: ())
168168
#expect(plist.swiftUI_description == "[]")
169169

@@ -183,6 +183,24 @@ struct PropertyListTests {
183183
plist[swiftUI: IntKey.self] = value
184184
#expect(plist.swiftUI_description == "[\(IntKey.self) = \(value), \(BoolKey.self) = \(bool), \(BoolKey.self) = \(BoolKey.defaultValue)]")
185185
}
186+
187+
@Test
188+
func merging() {
189+
var plist1 = PropertyList(swiftUI: ())
190+
plist1[swiftUI: IntKey.self] = 42
191+
var plist2 = PropertyList(swiftUI: ())
192+
plist2[swiftUI: StringKey.self] = "Hello"
193+
194+
let plist3 = plist1.swiftUI_merging(plist2)
195+
let plist4 = plist2.swiftUI_merging(plist1)
196+
197+
#expect(plist3.swiftUI_description == #"""
198+
[StringKey = Hello, IntKey = 42]
199+
"""#)
200+
#expect(plist4.swiftUI_description == #"""
201+
[IntKey = 42, StringKey = Hello]
202+
"""#)
203+
}
186204
}
187205

188206
extension PropertyList.Tracker {

0 commit comments

Comments
 (0)