Skip to content

Commit e07a71a

Browse files
authored
Merge pull request #210 from CodaFi/cosmetics
Cleanup some messes I left in the docs
2 parents 7175b6b + 43b0f34 commit e07a71a

11 files changed

+80
-49
lines changed

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ matrix:
3535
- echo $SIMULATOR_ID
3636
- echo $iOS_DEVICE_NAME
3737
- echo $iOS_RUNTIME_VERSION
38-
# !!!: Start simulator w/ desired device—helps avoid issues w/ Xcode timing out when waiting for simulator to become ready
39-
- open -b com.apple.iphonesimulator --args -CurrentDeviceUDID $SIMULATOR_ID
38+
- xcodebuild build-for-testing -scheme SwiftCheck-iOS -destination "platform=iOS Simulator,name=${iOS_DEVICE_NAME},OS=${iOS_RUNTIME_VERSION}" | xcpretty -c
4039
- xcodebuild test -scheme SwiftCheck-iOS -destination "platform=iOS Simulator,name=${iOS_DEVICE_NAME},OS=${iOS_RUNTIME_VERSION}" | xcpretty -c
41-
# -- End iOS --
40+
- xcodebuild build-for-testing -scheme SwiftCheck-tvOS -destination 'platform=tvOS Simulator,name=Apple TV 1080p' | xcpretty -c
4241
- xcodebuild test -scheme SwiftCheck-tvOS -destination 'platform=tvOS Simulator,name=Apple TV 1080p' | xcpretty -c
4342
- os: linux
4443
language: generic

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ let vowels = Gen.fromElements(of: [ "A", "E", "I", "O", "U" ])
281281

282282
let randomHexValue = Gen<UInt>.choose((0, 15))
283283

284-
let uppers : Gen<Character>= Gen<Character>.fromElements(in: "A"..."Z")
284+
let uppers : Gen<Character> = Gen<Character>.fromElements(in: "A"..."Z")
285285
let lowers : Gen<Character> = Gen<Character>.fromElements(in: "a"..."z")
286286
let numbers : Gen<Character> = Gen<Character>.fromElements(in: "0"..."9")
287287

Sources/Arbitrary.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
///
1111
/// While testing, SwiftCheck will invoke `arbitrary` a given amount of times
1212
/// (usually 100 if the default settings are used). During that time, the
13-
/// receiver has an opportunity to call through to any data or sources of
13+
/// callee has an opportunity to call through to any data or sources of
1414
/// randomness it needs to return what it deems an "Arbitrary" value.
1515
///
1616
/// Shrinking is reduction in the complexity of a tested value to remove noise

Sources/CoArbitrary.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/// given generator (more than likely using `Gen.variant()`) based on the value
1818
/// it observes.
1919
public protocol CoArbitrary {
20-
/// Uses an instance of the receiver to return a function that perturbs a
20+
/// Uses an instance of the this type to return a function that perturbs a
2121
/// generator.
2222
static func coarbitrary<C>(_ x : Self) -> ((Gen<C>) -> Gen<C>)
2323
}

Sources/Gen.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/// generator relies on its size to help control aspects like the length of
1414
/// generated arrays and the magnitude of integral values.
1515
public struct Gen<A> {
16-
/// The function underlying the receiver.
16+
/// The function underlying the generator.
1717
///
1818
/// +--- An RNG
1919
/// | +--- The size of generated values.
@@ -64,7 +64,7 @@ public struct Gen<A> {
6464

6565
/// Constructs a Generator that uses a given array to produce smaller arrays
6666
/// composed of its initial segments. The size of each initial segment
67-
/// increases with the receiver's size parameter.
67+
/// increases with the generator's size parameter.
6868
///
6969
/// The input array is required to be non-empty.
7070
public static func fromInitialSegments<S>(of xs : [S]) -> Gen<[S]> {
@@ -182,7 +182,7 @@ extension Gen {
182182
// MARK: Generator Modifiers
183183

184184
extension Gen {
185-
/// Shakes up the receiver's internal Random Number Generator with a seed.
185+
/// Shakes up the generator's internal Random Number Generator with a seed.
186186
public func variant<S : Integer>(_ seed : S) -> Gen<A> {
187187
return Gen(unGen: { rng, n in
188188
return self.unGen(vary(seed, rng), n)
@@ -218,7 +218,7 @@ extension Gen {
218218

219219
var size = n
220220
var r1 = r
221-
var scrutinee : A? = valGen.unGen(r, size)
221+
var scrutinee : A? = valGen.unGen(r1, size)
222222
while scrutinee == nil {
223223
let (rl, rr) = r1.split
224224
size = size + 1
@@ -254,15 +254,15 @@ extension Gen {
254254
}
255255

256256
/// Modifies a Generator such that it produces arrays with a length
257-
/// determined by the receiver's size parameter.
257+
/// determined by the generator's size parameter.
258258
public var proliferate : Gen<[A]> {
259259
return Gen<[A]>.sized { n in
260260
return Gen.choose((0, n)).flatMap(self.proliferate(withSize:))
261261
}
262262
}
263263

264264
/// Modifies a Generator such that it produces non-empty arrays with a
265-
/// length determined by the receiver's size parameter.
265+
/// length determined by the generator's size parameter.
266266
public var proliferateNonEmpty : Gen<[A]> {
267267
return Gen<[A]>.sized { n in
268268
return Gen.choose((1, max(1, n))).flatMap(self.proliferate(withSize:))
@@ -317,13 +317,13 @@ extension Gen {
317317

318318
extension Gen /*: Functor*/ {
319319
/// Returns a new generator that applies a given function to any outputs the
320-
/// receiver creates.
320+
/// generator creates.
321321
///
322322
/// This function is most useful for converting between generators of inter-
323323
/// related types. For example, you might have a Generator of `Character`
324324
/// values that you then `.proliferate` into an `Array` of `Character`s. You
325-
/// can then use `fmap` to convert that generator of `Array`s to a generator of
326-
/// `String`s.
325+
/// can then use `map` to convert that generator of `Array`s to a generator
326+
/// of `String`s.
327327
public func map<B>(_ f : @escaping (A) -> B) -> Gen<B> {
328328
return Gen<B>(unGen: { r, n in
329329
return f(self.unGen(r, n))
@@ -340,7 +340,7 @@ extension Gen /*: Applicative*/ {
340340
}
341341

342342
/// Given a generator of functions, applies any generated function to any
343-
/// outputs the receiver creates.
343+
/// outputs the generator creates.
344344
public func ap<B>(_ fn : Gen<(A) -> B>) -> Gen<B> {
345345
return Gen<B>(unGen: { r, n in
346346
let (r1, r2) = r.split

Sources/Lattice.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ extension AnyIndex : LatticeType {
105105
#if os(Linux)
106106
import Glibc
107107

108-
/// Matches http://www.opensource.apple.com/source/gcc/gcc-934.3/float.h
108+
// Matches http://www.opensource.apple.com/source/gcc/gcc-934.3/float.h
109+
110+
/// Maximum value of `Float`.
109111
public var FLT_MAX: Float = 3.40282347e+38
112+
/// Minimum value of `Float`.
110113
public var FLT_MIN: Float = 1.17549435e-38
111114

115+
/// Maximum value of `Double`.
112116
public var DBL_MAX: Double = 1.7976931348623157e+308
117+
/// Minimum value of `Double`.
113118
public var DBL_MIN: Double = 2.2250738585072014e-308
114119
#else
115120
import Darwin

Sources/Modifiers.swift

+30-5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public struct Blind<A : Arbitrary> : Arbitrary, CustomStringConvertible {
5555
/// Retrieves the underlying value.
5656
public let getBlind : A
5757

58+
/// Creates a new `Blind` modifier from an underlying value.
5859
public init(_ blind : A) {
5960
self.getBlind = blind
6061
}
@@ -78,8 +79,9 @@ public struct Blind<A : Arbitrary> : Arbitrary, CustomStringConvertible {
7879
}
7980

8081
extension Blind : CoArbitrary {
81-
// Take the lazy way out.
82+
/// Uses the underlying value to perturb a generator.
8283
public static func coarbitrary<C>(_ x : Blind) -> ((Gen<C>) -> Gen<C>) {
84+
// Take the lazy way out.
8385
return coarbitraryPrintable(x)
8486
}
8587
}
@@ -89,6 +91,7 @@ public struct Static<A : Arbitrary> : Arbitrary, CustomStringConvertible {
8991
/// Retrieves the underlying value.
9092
public let getStatic : A
9193

94+
/// Creates a new `Static` modifier from an underlying value.
9295
public init(_ fixed : A) {
9396
self.getStatic = fixed
9497
}
@@ -105,8 +108,9 @@ public struct Static<A : Arbitrary> : Arbitrary, CustomStringConvertible {
105108
}
106109

107110
extension Static : CoArbitrary {
108-
// Take the lazy way out.
111+
/// Uses the underlying value to perturb a generator.
109112
public static func coarbitrary<C>(_ x : Static) -> ((Gen<C>) -> Gen<C>) {
113+
// Take the lazy way out.
110114
return coarbitraryPrintable(x)
111115
}
112116
}
@@ -121,6 +125,7 @@ public struct ArrayOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
121125
return ContiguousArray(self.getArray)
122126
}
123127

128+
/// Creates a new `ArrayOf` modifier from an underlying array of values.
124129
public init(_ array : [A]) {
125130
self.getArray = array
126131
}
@@ -142,6 +147,7 @@ public struct ArrayOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
142147
}
143148

144149
extension ArrayOf : CoArbitrary {
150+
/// Uses the underlying array of values to perturb a generator.
145151
public static func coarbitrary<C>(_ x : ArrayOf) -> ((Gen<C>) -> Gen<C>) {
146152
let a = x.getArray
147153
if a.isEmpty {
@@ -162,6 +168,11 @@ public struct OrderedArrayOf<A : Arbitrary & Comparable> : Arbitrary, CustomStri
162168
return ContiguousArray(self.getOrderedArray)
163169
}
164170

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.
165176
public init(_ array : [A]) {
166177
self.getOrderedArray = array.sorted()
167178
}
@@ -188,6 +199,8 @@ public struct DictionaryOf<K : Hashable & Arbitrary, V : Arbitrary> : Arbitrary,
188199
/// Retrieves the underlying dictionary of values.
189200
public let getDictionary : Dictionary<K, V>
190201

202+
/// Creates a new `DictionaryOf` modifier from an underlying dictionary of
203+
/// key-value pairs.
191204
public init(_ dict : Dictionary<K, V>) {
192205
self.getDictionary = dict
193206
}
@@ -209,6 +222,7 @@ public struct DictionaryOf<K : Hashable & Arbitrary, V : Arbitrary> : Arbitrary,
209222
}
210223

211224
extension DictionaryOf : CoArbitrary {
225+
/// Uses the underlying array of values to perturb a generator.
212226
public static func coarbitrary<C>(_ x : DictionaryOf) -> ((Gen<C>) -> Gen<C>) {
213227
return Dictionary.coarbitrary(x.getDictionary)
214228
}
@@ -219,13 +233,14 @@ public struct OptionalOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
219233
/// Retrieves the underlying optional value.
220234
public let getOptional : A?
221235

236+
/// Creates a new `OptionalOf` modifier from an underlying `Optional` value.
222237
public init(_ opt : A?) {
223238
self.getOptional = opt
224239
}
225240

226241
/// A textual representation of `self`.
227242
public var description : String {
228-
return "\(self.getOptional)"
243+
return "\(String(describing: self.getOptional))"
229244
}
230245

231246
/// Returns a generator for `OptionalOf` values.
@@ -240,6 +255,7 @@ public struct OptionalOf<A : Arbitrary> : Arbitrary, CustomStringConvertible {
240255
}
241256

242257
extension OptionalOf : CoArbitrary {
258+
/// Uses the underlying presence or lack of a value to perturb a generator.
243259
public static func coarbitrary<C>(_ x : OptionalOf) -> ((Gen<C>) -> Gen<C>) {
244260
if let _ = x.getOptional {
245261
return { $0.variant(0) }
@@ -253,6 +269,7 @@ public struct SetOf<A : Hashable & Arbitrary> : Arbitrary, CustomStringConvertib
253269
/// Retrieves the underlying set of values.
254270
public let getSet : Set<A>
255271

272+
/// Creates a new `SetOf` modifier from an underlying set of values.
256273
public init(_ set : Set<A>) {
257274
self.getSet = set
258275
}
@@ -282,6 +299,7 @@ public struct SetOf<A : Hashable & Arbitrary> : Arbitrary, CustomStringConvertib
282299
}
283300

284301
extension SetOf : CoArbitrary {
302+
/// Uses the underlying set of values to perturb a generator.
285303
public static func coarbitrary<C>(_ x : SetOf) -> ((Gen<C>) -> Gen<C>) {
286304
if x.getSet.isEmpty {
287305
return { $0.variant(0) }
@@ -384,6 +402,7 @@ public struct Large<A : RandomType & LatticeType & Integer> : Arbitrary {
384402
/// Retrieves the underlying large value.
385403
public let getLarge : A
386404

405+
/// Creates a new `Large` modifier from a given bounded integral value.
387406
public init(_ lrg : A) {
388407
self.getLarge = lrg
389408
}
@@ -409,6 +428,7 @@ public struct Positive<A : Arbitrary & SignedNumber> : Arbitrary, CustomStringCo
409428
/// Retrieves the underlying positive value.
410429
public let getPositive : A
411430

431+
/// Creates a new `Positive` modifier from a given signed integral value.
412432
public init(_ pos : A) {
413433
self.getPositive = pos
414434
}
@@ -430,8 +450,9 @@ public struct Positive<A : Arbitrary & SignedNumber> : Arbitrary, CustomStringCo
430450
}
431451

432452
extension Positive : CoArbitrary {
433-
// Take the lazy way out.
453+
/// Uses the underlying positive integral value to perturb a generator.
434454
public static func coarbitrary<C>(_ x : Positive) -> ((Gen<C>) -> Gen<C>) {
455+
// Take the lazy way out.
435456
return coarbitraryPrintable(x)
436457
}
437458
}
@@ -441,6 +462,7 @@ public struct NonZero<A : Arbitrary & Integer> : Arbitrary, CustomStringConverti
441462
/// Retrieves the underlying non-zero value.
442463
public let getNonZero : A
443464

465+
/// Creates a new `NonZero` modifier from a given integral value.
444466
public init(_ non : A) {
445467
self.getNonZero = non
446468
}
@@ -462,6 +484,7 @@ public struct NonZero<A : Arbitrary & Integer> : Arbitrary, CustomStringConverti
462484
}
463485

464486
extension NonZero : CoArbitrary {
487+
/// Uses the underlying non-zero integral value to perturb a generator.
465488
public static func coarbitrary<C>(_ x : NonZero) -> ((Gen<C>) -> Gen<C>) {
466489
return x.getNonZero.coarbitraryIntegral()
467490
}
@@ -472,6 +495,7 @@ public struct NonNegative<A : Arbitrary & Integer> : Arbitrary, CustomStringConv
472495
/// Retrieves the underlying non-negative value.
473496
public let getNonNegative : A
474497

498+
/// Creates a new `NonNegative` modifier from a given integral value.
475499
public init(_ non : A) {
476500
self.getNonNegative = non
477501
}
@@ -493,6 +517,7 @@ public struct NonNegative<A : Arbitrary & Integer> : Arbitrary, CustomStringConv
493517
}
494518

495519
extension NonNegative : CoArbitrary {
520+
/// Uses the underlying non-negative integral value to perturb a generator.
496521
public static func coarbitrary<C>(_ x : NonNegative) -> ((Gen<C>) -> Gen<C>) {
497522
return x.getNonNegative.coarbitraryIntegral()
498523
}
@@ -626,7 +651,7 @@ private final class PointerOfImpl<T : Arbitrary> : Arbitrary {
626651
let size : Int
627652

628653
var description : String {
629-
return "\(self.ptr)"
654+
return "\(String(describing: self.ptr))"
630655
}
631656

632657
init(_ ptr : UnsafeMutablePointer<T>, _ size : Int) {

Sources/Random.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
/// type. It is analogous to `GeneratorType`, but rather than consume a
1111
/// sequence it uses sources of randomness to generate values indefinitely.
1212
public protocol RandomGeneneratorType {
13-
/// The next operation returns an Int that is uniformly distributed in the
14-
/// range returned by `genRange` (including both end points), and a new
15-
/// generator.
13+
/// Returns an `Int` that is uniformly distributed in the range returned by
14+
/// `genRange` (including both end points), and a new random value generator.
1615
var next : (Int, Self) { get }
17-
/// The genRange operation yields the range of values returned by the
18-
/// generator.
16+
/// Yields the range of values returned by the generator.
1917
///
2018
/// This property must return integers in ascending order.
2119
var genRange : (Int, Int) { get }
22-
/// Splits the receiver into two distinct random value generators.
20+
/// Splits the current random value generator into two distinct random value
21+
/// generators.
2322
var split : (Self, Self) { get }
2423
}
2524

@@ -69,7 +68,8 @@ public struct StdGen : RandomGeneneratorType {
6968
return (z_, StdGen(s1__, s2__))
7069
}
7170

72-
/// Splits the receiver and returns two distinct random number generators.
71+
/// Splits the random number generator and returns two distinct random
72+
/// number generators.
7373
public var split : (StdGen, StdGen) {
7474
let s1 = self.seed1
7575
let s2 = self.seed2

0 commit comments

Comments
 (0)