@@ -66,12 +66,12 @@ final class DatabaseAPITests {
66
66
67
67
// MARK: - DatabaseQuery
68
68
69
- var uint : UInt = 0
69
+ let uint : UInt = 0
70
70
let dataEventType : DataEventType = . value
71
- var child = " child "
72
- var childKey : String ? = " key "
73
- var value : Any ? = " value "
74
- var priority : Any ? = " priority "
71
+ let child = " child "
72
+ let childKey : String ? = " key "
73
+ let value : Any ? = " value "
74
+ let priority : Any ? = " priority "
75
75
76
76
var databaseHandle : DatabaseHandle = uint
77
77
var databaseQuery : DatabaseQuery = DatabaseQuery ( )
@@ -115,9 +115,9 @@ final class DatabaseAPITests {
115
115
#if swift(>=5.5)
116
116
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
117
117
// async/await is a Swift 5.5+ feature available on iOS 15+
118
- async {
118
+ Task {
119
119
do {
120
- let /* dataSnapshot */ _: DataSnapshot = try await databaseQuery . getData ( )
120
+ let /* dataSnapshot */ _: DataSnapshot = try await DatabaseQuery ( ) . getData ( )
121
121
} catch {
122
122
// ...
123
123
}
@@ -141,14 +141,10 @@ final class DatabaseAPITests {
141
141
#if swift(>=5.5)
142
142
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
143
143
// async/await is a Swift 5.5+ feature available on iOS 15+
144
- async {
145
- do {
146
- // observeSingleEvent(of eventType:)
147
- let _: ( DataSnapshot , String ? ) = try await databaseQuery
148
- . observeSingleEventAndPreviousSiblingKey ( of: dataEventType)
149
- } catch {
150
- // ...
151
- }
144
+ Task {
145
+ // observeSingleEvent(of eventType:)
146
+ let _: ( DataSnapshot , String ? ) = await DatabaseQuery ( )
147
+ . observeSingleEventAndPreviousSiblingKey ( of: dataEventType)
152
148
}
153
149
}
154
150
#endif // swift(>=5.5)
@@ -198,7 +194,7 @@ final class DatabaseAPITests {
198
194
// MARK: - DatabaseReference
199
195
200
196
let priorityAny : Any = " priority "
201
- var values = [ AnyHashable: Any] ( )
197
+ let values = [ AnyHashable: Any] ( )
202
198
var transactionResult = TransactionResult ( )
203
199
204
200
// Retreive Child DatabaseReference
@@ -217,10 +213,10 @@ final class DatabaseAPITests {
217
213
#if swift(>=5.5)
218
214
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
219
215
// async/await is a Swift 5.5+ feature available on iOS 15+
220
- async {
216
+ Task {
221
217
do {
222
218
// setValue(_ value:)
223
- databaseReference = try await databaseReference . setValue ( value)
219
+ let /* ref */ _ : DatabaseReference = try await DatabaseReference ( ) . setValue ( value)
224
220
} catch {
225
221
// ...
226
222
}
@@ -239,10 +235,11 @@ final class DatabaseAPITests {
239
235
#if swift(>=5.5)
240
236
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
241
237
// async/await is a Swift 5.5+ feature available on iOS 15+
242
- async {
238
+ Task {
243
239
do {
244
240
// setValue(_ value:andPriority priority:)
245
- databaseReference = try await databaseReference. setValue ( value, andPriority: priority)
241
+ let /* ref */ _: DatabaseReference = try await DatabaseReference ( )
242
+ . setValue ( value, andPriority: priority)
246
243
} catch {
247
244
// ...
248
245
}
@@ -262,9 +259,9 @@ final class DatabaseAPITests {
262
259
#if swift(>=5.5)
263
260
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
264
261
// async/await is a Swift 5.5+ feature available on iOS 15+
265
- async {
262
+ Task {
266
263
do {
267
- databaseReference = try await databaseReference . removeValue ( )
264
+ let /* ref */ _ : DatabaseReference = try await DatabaseReference ( ) . removeValue ( )
268
265
} catch {
269
266
// ...
270
267
}
@@ -284,10 +281,10 @@ final class DatabaseAPITests {
284
281
#if swift(>=5.5)
285
282
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
286
283
// async/await is a Swift 5.5+ feature available on iOS 15+
287
- async {
284
+ Task {
288
285
do {
289
286
// setPriority(_ priority:)
290
- databaseReference = try await databaseReference . setPriority ( priority)
287
+ let /* ref */ _ : DatabaseReference = try await DatabaseReference ( ) . setPriority ( priority)
291
288
} catch {
292
289
// ...
293
290
}
@@ -307,10 +304,11 @@ final class DatabaseAPITests {
307
304
#if swift(>=5.5)
308
305
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
309
306
// async/await is a Swift 5.5+ feature available on iOS 15+
310
- async {
307
+ Task {
311
308
do {
312
309
// updateChildValues(_ values:)
313
- databaseReference = try await databaseReference. updateChildValues ( values)
310
+ let /* ref */ _: DatabaseReference = try await DatabaseReference ( )
311
+ . updateChildValues ( values)
314
312
} catch {
315
313
// ...
316
314
}
@@ -362,14 +360,10 @@ final class DatabaseAPITests {
362
360
#if swift(>=5.5)
363
361
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
364
362
// async/await is a Swift 5.5+ feature available on iOS 15+
365
- async {
366
- do {
367
- // observeSingleEvent(of eventType:)
368
- let _: ( DataSnapshot , String ? ) = try await databaseReference
369
- . observeSingleEventAndPreviousSiblingKey ( of: dataEventType)
370
- } catch {
371
- // ...
372
- }
363
+ Task {
364
+ // observeSingleEvent(of eventType:)
365
+ let _: ( DataSnapshot , String ? ) = await DatabaseReference ( )
366
+ . observeSingleEventAndPreviousSiblingKey ( of: dataEventType)
373
367
}
374
368
}
375
369
#endif // swift(>=5.5)
@@ -400,9 +394,9 @@ final class DatabaseAPITests {
400
394
#if swift(>=5.5)
401
395
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
402
396
// async/await is a Swift 5.5+ feature available on iOS 15+
403
- async {
397
+ Task {
404
398
do {
405
- let /* dataSnapshot */ _: DataSnapshot = try await databaseReference . getData ( )
399
+ let /* dataSnapshot */ _: DataSnapshot = try await DatabaseReference ( ) . getData ( )
406
400
} catch {
407
401
// ...
408
402
}
@@ -444,10 +438,11 @@ final class DatabaseAPITests {
444
438
#if swift(>=5.5)
445
439
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
446
440
// async/await is a Swift 5.5+ feature available on iOS 15+
447
- async {
441
+ Task {
448
442
do {
449
443
// onDisconnectSetValue(_ value:)
450
- databaseReference = try await databaseReference. onDisconnectSetValue ( value)
444
+ let /* ref */ _: DatabaseReference = try await DatabaseReference ( )
445
+ . onDisconnectSetValue ( value)
451
446
} catch {
452
447
// ...
453
448
}
@@ -467,10 +462,10 @@ final class DatabaseAPITests {
467
462
#if swift(>=5.5)
468
463
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
469
464
// async/await is a Swift 5.5+ feature available on iOS 15+
470
- async {
465
+ Task {
471
466
do {
472
467
// onDisconnectSetValue(_ value:andPriority priority:)
473
- databaseReference = try await databaseReference . onDisconnectSetValue (
468
+ let /* ref */ _ : DatabaseReference = try await DatabaseReference ( ) . onDisconnectSetValue (
474
469
value,
475
470
andPriority: priority
476
471
)
@@ -493,9 +488,10 @@ final class DatabaseAPITests {
493
488
#if swift(>=5.5)
494
489
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
495
490
// async/await is a Swift 5.5+ feature available on iOS 15+
496
- async {
491
+ Task {
497
492
do {
498
- databaseReference = try await databaseReference. onDisconnectRemoveValue ( )
493
+ let /* ref */ _: DatabaseReference = try await DatabaseReference ( )
494
+ . onDisconnectRemoveValue ( )
499
495
} catch {
500
496
// ...
501
497
}
@@ -515,10 +511,11 @@ final class DatabaseAPITests {
515
511
#if swift(>=5.5)
516
512
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
517
513
// async/await is a Swift 5.5+ feature available on iOS 15+
518
- async {
514
+ Task {
519
515
do {
520
516
// onDisconnectUpdateChildValues(_ values:)
521
- databaseReference = try await databaseReference. onDisconnectUpdateChildValues ( values)
517
+ let /* ref */ _: DatabaseReference = try await DatabaseReference ( )
518
+ . onDisconnectUpdateChildValues ( values)
522
519
} catch {
523
520
// ...
524
521
}
@@ -538,9 +535,10 @@ final class DatabaseAPITests {
538
535
#if swift(>=5.5)
539
536
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
540
537
// async/await is a Swift 5.5+ feature available on iOS 15+
541
- async {
538
+ Task {
542
539
do {
543
- databaseReference = try await databaseReference. cancelDisconnectOperations ( )
540
+ let /* ref */ _: DatabaseReference = try await DatabaseReference ( )
541
+ . cancelDisconnectOperations ( )
544
542
} catch {
545
543
// ...
546
544
}
@@ -569,13 +567,13 @@ final class DatabaseAPITests {
569
567
#if swift(>=5.5)
570
568
if #available( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , * ) {
571
569
// async/await is a Swift 5.5+ feature available on iOS 15+
572
- async {
570
+ Task {
573
571
do {
574
572
// runTransactionBlock(_ block:)
575
- let _: ( Bool , DataSnapshot ) = try await databaseReference
573
+ let _: ( Bool , DataSnapshot ) = try await DatabaseReference ( )
576
574
. runTransactionBlock { mutableData in
577
575
let /* mutableData */ _: MutableData = mutableData
578
- return transactionResult
576
+ return TransactionResult ( )
579
577
}
580
578
} catch {
581
579
// ...
@@ -603,8 +601,8 @@ final class DatabaseAPITests {
603
601
604
602
// Instance properties
605
603
let /* parent */ _: DatabaseReference ? = databaseReference. parent
604
+ let /* childKey */ _: String ? = databaseReference. key
606
605
databaseReference = databaseReference. root
607
- childKey = databaseReference. key
608
606
url = databaseReference. url
609
607
database = databaseReference. database
610
608
@@ -638,15 +636,15 @@ final class DatabaseAPITests {
638
636
let /* exists */ _: Bool = dataSnapshot. exists ( )
639
637
640
638
// Data export
641
- value = dataSnapshot. valueInExportFormat ( )
639
+ let /* value */ _ : Any ? = dataSnapshot. valueInExportFormat ( )
642
640
643
641
// Properties
644
- value = dataSnapshot. value
645
- uint = dataSnapshot. childrenCount
646
642
databaseReference = dataSnapshot. ref
647
- child = dataSnapshot. key
643
+ let /* value */ _: Any ? = dataSnapshot. value
644
+ let /* uint */ _: UInt = dataSnapshot. childrenCount
645
+ let /* child */ _: String ? = dataSnapshot. key
648
646
let /* children */ _: NSEnumerator = dataSnapshot. children
649
- priority = dataSnapshot. priority
647
+ let /* priority */ _ : Any ? = dataSnapshot. priority
650
648
651
649
// MARK: - MutableData
652
650
@@ -658,18 +656,19 @@ final class DatabaseAPITests {
658
656
mutableData = mutableData. childData ( byAppendingPath: path)
659
657
660
658
// Properties
661
- value = mutableData. value
662
- priority = mutableData. priority
663
- uint = mutableData. childrenCount
659
+ let /* value */ _: Any ? = mutableData. value
660
+ let /* priority */ _: Any ? = mutableData. priority
661
+
662
+ let /* uint */ _: UInt = mutableData. childrenCount
664
663
let /* children */ _: NSEnumerator = mutableData. children
665
- childKey = mutableData. key
664
+ let /* childKey */ _ : String ? = mutableData. key
666
665
667
666
// MARK: - ServerValue
668
667
669
668
let nsNumber : NSNumber = 0
670
669
671
- values = ServerValue . timestamp ( )
672
- values = ServerValue . increment ( nsNumber)
670
+ let /* values */ _ : [ AnyHashable : Any ] = ServerValue . timestamp ( )
671
+ let /* values */ _ : [ AnyHashable : Any ] = ServerValue . increment ( nsNumber)
673
672
674
673
// MARK: - TransactionResult
675
674
0 commit comments