@@ -55,6 +55,7 @@ public struct Blind<A : Arbitrary> : Arbitrary, CustomStringConvertible {
55
55
/// Retrieves the underlying value.
56
56
public let getBlind : A
57
57
58
+ /// Creates a new `Blind` modifier from an underlying value.
58
59
public init ( _ blind : A ) {
59
60
self . getBlind = blind
60
61
}
@@ -78,8 +79,9 @@ public struct Blind<A : Arbitrary> : Arbitrary, CustomStringConvertible {
78
79
}
79
80
80
81
extension Blind : CoArbitrary {
81
- // Take the lazy way out .
82
+ /// Uses the underlying value to perturb a generator .
82
83
public static func coarbitrary< C> ( _ x : Blind ) -> ( ( Gen < C > ) -> Gen < C > ) {
84
+ // Take the lazy way out.
83
85
return coarbitraryPrintable ( x)
84
86
}
85
87
}
@@ -89,6 +91,7 @@ public struct Static<A : Arbitrary> : Arbitrary, CustomStringConvertible {
89
91
/// Retrieves the underlying value.
90
92
public let getStatic : A
91
93
94
+ /// Creates a new `Static` modifier from an underlying value.
92
95
public init ( _ fixed : A ) {
93
96
self . getStatic = fixed
94
97
}
@@ -105,8 +108,9 @@ public struct Static<A : Arbitrary> : Arbitrary, CustomStringConvertible {
105
108
}
106
109
107
110
extension Static : CoArbitrary {
108
- // Take the lazy way out .
111
+ /// Uses the underlying value to perturb a generator .
109
112
public static func coarbitrary< C> ( _ x : Static ) -> ( ( Gen < C > ) -> Gen < C > ) {
113
+ // Take the lazy way out.
110
114
return coarbitraryPrintable ( x)
111
115
}
112
116
}
@@ -121,6 +125,7 @@ public struct ArrayOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
121
125
return ContiguousArray ( self . getArray)
122
126
}
123
127
128
+ /// Creates a new `ArrayOf` modifier from an underlying array of values.
124
129
public init ( _ array : [ A ] ) {
125
130
self . getArray = array
126
131
}
@@ -142,6 +147,7 @@ public struct ArrayOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
142
147
}
143
148
144
149
extension ArrayOf : CoArbitrary {
150
+ /// Uses the underlying array of values to perturb a generator.
145
151
public static func coarbitrary< C> ( _ x : ArrayOf ) -> ( ( Gen < C > ) -> Gen < C > ) {
146
152
let a = x. getArray
147
153
if a. isEmpty {
@@ -162,6 +168,11 @@ public struct OrderedArrayOf<A : Arbitrary & Comparable> : Arbitrary, CustomStri
162
168
return ContiguousArray ( self . getOrderedArray)
163
169
}
164
170
171
+ /// Creates a new `OrderedArrayOf` modifier from an underlying array of
172
+ /// values.
173
+ ///
174
+ /// The values in the array are not required to be sorted, they will
175
+ /// be sorted by the initializer.
165
176
public init ( _ array : [ A ] ) {
166
177
self . getOrderedArray = array. sorted ( )
167
178
}
@@ -188,6 +199,8 @@ public struct DictionaryOf<K : Hashable & Arbitrary, V : Arbitrary> : Arbitrary,
188
199
/// Retrieves the underlying dictionary of values.
189
200
public let getDictionary : Dictionary < K , V >
190
201
202
+ /// Creates a new `DictionaryOf` modifier from an underlying dictionary of
203
+ /// key-value pairs.
191
204
public init ( _ dict : Dictionary < K , V > ) {
192
205
self . getDictionary = dict
193
206
}
@@ -209,6 +222,7 @@ public struct DictionaryOf<K : Hashable & Arbitrary, V : Arbitrary> : Arbitrary,
209
222
}
210
223
211
224
extension DictionaryOf : CoArbitrary {
225
+ /// Uses the underlying array of values to perturb a generator.
212
226
public static func coarbitrary< C> ( _ x : DictionaryOf ) -> ( ( Gen < C > ) -> Gen < C > ) {
213
227
return Dictionary . coarbitrary ( x. getDictionary)
214
228
}
@@ -219,13 +233,14 @@ public struct OptionalOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
219
233
/// Retrieves the underlying optional value.
220
234
public let getOptional : A ?
221
235
236
+ /// Creates a new `OptionalOf` modifier from an underlying `Optional` value.
222
237
public init ( _ opt : A ? ) {
223
238
self . getOptional = opt
224
239
}
225
240
226
241
/// A textual representation of `self`.
227
242
public var description : String {
228
- return " \( self . getOptional) "
243
+ return " \( String ( describing : self . getOptional) ) "
229
244
}
230
245
231
246
/// Returns a generator for `OptionalOf` values.
@@ -240,6 +255,7 @@ public struct OptionalOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
240
255
}
241
256
242
257
extension OptionalOf : CoArbitrary {
258
+ /// Uses the underlying presence or lack of a value to perturb a generator.
243
259
public static func coarbitrary< C> ( _ x : OptionalOf ) -> ( ( Gen < C > ) -> Gen < C > ) {
244
260
if let _ = x. getOptional {
245
261
return { $0. variant ( 0 ) }
@@ -253,6 +269,7 @@ public struct SetOf<A : Hashable & Arbitrary> : Arbitrary, CustomStringConvertib
253
269
/// Retrieves the underlying set of values.
254
270
public let getSet : Set < A >
255
271
272
+ /// Creates a new `SetOf` modifier from an underlying set of values.
256
273
public init ( _ set : Set < A > ) {
257
274
self . getSet = set
258
275
}
@@ -282,6 +299,7 @@ public struct SetOf<A : Hashable & Arbitrary> : Arbitrary, CustomStringConvertib
282
299
}
283
300
284
301
extension SetOf : CoArbitrary {
302
+ /// Uses the underlying set of values to perturb a generator.
285
303
public static func coarbitrary< C> ( _ x : SetOf ) -> ( ( Gen < C > ) -> Gen < C > ) {
286
304
if x. getSet. isEmpty {
287
305
return { $0. variant ( 0 ) }
@@ -384,6 +402,7 @@ public struct Large<A : RandomType & LatticeType & Integer> : Arbitrary {
384
402
/// Retrieves the underlying large value.
385
403
public let getLarge : A
386
404
405
+ /// Creates a new `Large` modifier from a given bounded integral value.
387
406
public init ( _ lrg : A ) {
388
407
self . getLarge = lrg
389
408
}
@@ -409,6 +428,7 @@ public struct Positive<A : Arbitrary & SignedNumber> : Arbitrary, CustomStringCo
409
428
/// Retrieves the underlying positive value.
410
429
public let getPositive : A
411
430
431
+ /// Creates a new `Positive` modifier from a given signed integral value.
412
432
public init ( _ pos : A ) {
413
433
self . getPositive = pos
414
434
}
@@ -430,8 +450,9 @@ public struct Positive<A : Arbitrary & SignedNumber> : Arbitrary, CustomStringCo
430
450
}
431
451
432
452
extension Positive : CoArbitrary {
433
- // Take the lazy way out .
453
+ /// Uses the underlying positive integral value to perturb a generator .
434
454
public static func coarbitrary< C> ( _ x : Positive ) -> ( ( Gen < C > ) -> Gen < C > ) {
455
+ // Take the lazy way out.
435
456
return coarbitraryPrintable ( x)
436
457
}
437
458
}
@@ -441,6 +462,7 @@ public struct NonZero<A : Arbitrary & Integer> : Arbitrary, CustomStringConverti
441
462
/// Retrieves the underlying non-zero value.
442
463
public let getNonZero : A
443
464
465
+ /// Creates a new `NonZero` modifier from a given integral value.
444
466
public init ( _ non : A ) {
445
467
self . getNonZero = non
446
468
}
@@ -462,6 +484,7 @@ public struct NonZero<A : Arbitrary & Integer> : Arbitrary, CustomStringConverti
462
484
}
463
485
464
486
extension NonZero : CoArbitrary {
487
+ /// Uses the underlying non-zero integral value to perturb a generator.
465
488
public static func coarbitrary< C> ( _ x : NonZero ) -> ( ( Gen < C > ) -> Gen < C > ) {
466
489
return x. getNonZero. coarbitraryIntegral ( )
467
490
}
@@ -472,6 +495,7 @@ public struct NonNegative<A : Arbitrary & Integer> : Arbitrary, CustomStringConv
472
495
/// Retrieves the underlying non-negative value.
473
496
public let getNonNegative : A
474
497
498
+ /// Creates a new `NonNegative` modifier from a given integral value.
475
499
public init ( _ non : A ) {
476
500
self . getNonNegative = non
477
501
}
@@ -493,6 +517,7 @@ public struct NonNegative<A : Arbitrary & Integer> : Arbitrary, CustomStringConv
493
517
}
494
518
495
519
extension NonNegative : CoArbitrary {
520
+ /// Uses the underlying non-negative integral value to perturb a generator.
496
521
public static func coarbitrary< C> ( _ x : NonNegative ) -> ( ( Gen < C > ) -> Gen < C > ) {
497
522
return x. getNonNegative. coarbitraryIntegral ( )
498
523
}
@@ -626,7 +651,7 @@ private final class PointerOfImpl<T : Arbitrary> : Arbitrary {
626
651
let size : Int
627
652
628
653
var description : String {
629
- return " \( self . ptr) "
654
+ return " \( String ( describing : self . ptr) ) "
630
655
}
631
656
632
657
init ( _ ptr : UnsafeMutablePointer < T > , _ size : Int ) {
0 commit comments