Skip to content

Commit b787f5e

Browse files
authored
FIx multiple typos in documentation
1 parent 859fe06 commit b787f5e

File tree

6 files changed

+49
-18
lines changed

6 files changed

+49
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Enable the shrinker by adding the `shrinking` trait:
101101
@Test(.shrinking) func checkSumInRange() async
102102
```
103103

104-
After shrinking, the new failing case is `[46, 97, 68, 23, 16]`, which sums to exactly `250`. The first few elements have been removed, which the middle element has been reduced to be closer to the edge.
104+
After shrinking, the new failing case is `[46, 97, 68, 23, 16]`, which sums to exactly `250`. The first few elements have been removed, while the middle element has been reduced to be closer to the edge.
105105

106106
When using the built-in generators and the `zip` function, shrinkers will also be composed.
107107

Sources/PropertyBased/Gen+Float.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ extension Gen where Value: BinaryFloatingPoint & Sendable, Value.RawSignificand:
2828
}
2929

3030
extension Gen where Value == Float {
31-
/// Produces a generator of random values within the specified range.
31+
/// Produces a generator of random floats within the specified range.
3232
///
3333
/// - Parameter range: The range in which to create a random value. `range` must be finite.
3434
/// - Returns: A generator of random values within the bounds of range.
3535
@inlinable
3636
public static func float(in range: ClosedRange<Float>) -> Generator<Float, Shrink.Floating<Float>> { return value(in: range) }
3737

38-
/// Produces a generator of random values within the specified range.
38+
/// Produces a generator of random floats within the specified range.
3939
///
4040
/// - Parameter range: The range in which to create a random value. `range` must be finite.
4141
/// - Returns: A generator of random values within the bounds of range.
@@ -44,14 +44,14 @@ extension Gen where Value == Float {
4444
}
4545

4646
extension Gen where Value == Double {
47-
/// Produces a generator of random values within the specified range.
47+
/// Produces a generator of random floats within the specified range.
4848
///
4949
/// - Parameter range: The range in which to create a random value. `range` must be finite.
5050
/// - Returns: A generator of random values within the bounds of range.
5151
@inlinable
5252
public static func double(in range: ClosedRange<Double>) -> Generator<Double, Shrink.Floating<Double>> { return value(in: range) }
5353

54-
/// Produces a generator of random values within the specified range.
54+
/// Produces a generator of random floats within the specified range.
5555
///
5656
/// - Parameter range: The range in which to create a random value. `range` must be finite.
5757
/// - Returns: A generator of random values within the bounds of range.
@@ -61,14 +61,14 @@ extension Gen where Value == Double {
6161

6262
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
6363
extension Gen where Value == Float16 {
64-
/// Produces a generator of random values within the specified range.
64+
/// Produces a generator of random floats within the specified range.
6565
///
6666
/// - Parameter range: The range in which to create a random value. `range` must be finite.
6767
/// - Returns: A generator of random values within the bounds of range.
6868
@inlinable
6969
public static func float16(in range: ClosedRange<Float16>) -> Generator<Float16, Shrink.Floating<Float16>> { return value(in: range) }
7070

71-
/// Produces a generator of random values within the specified range.
71+
/// Produces a generator of random floats within the specified range.
7272
///
7373
/// - Parameter range: The range in which to create a random value. `range` must be finite.
7474
/// - Returns: A generator of random values within the bounds of range.
@@ -78,14 +78,14 @@ extension Gen where Value == Float16 {
7878

7979
#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64))
8080
extension Gen where Value == Float80 {
81-
/// Produces a generator of random values within the specified range.
81+
/// Produces a generator of random floats within the specified range.
8282
///
8383
/// - Parameter range: The range in which to create a random value. `range` must be finite.
8484
/// - Returns: A generator of random values within the bounds of range.
8585
@inlinable
8686
public static func float80(in range: ClosedRange<Float80>) -> Generator<Float80, Shrink.Floating<Float80>> { return value(in: range) }
8787

88-
/// Produces a generator of random values within the specified range.
88+
/// Produces a generator of random floats within the specified range.
8989
///
9090
/// - Parameter range: The range in which to create a random value. `range` must be finite.
9191
/// - Returns: A generator of random values within the bounds of range.
@@ -97,14 +97,14 @@ extension Gen where Value == Float80 {
9797
#if canImport(Foundation)
9898
import Foundation
9999
extension Gen where Value == CGFloat {
100-
/// Produces a generator of random values within the specified range.
100+
/// Produces a generator of random floats within the specified range.
101101
///
102102
/// - Parameter range: The range in which to create a random value. `range` must be finite.
103103
/// - Returns: A generator of random values within the bounds of range.
104104
@inlinable
105105
public static func cgFloat(in range: ClosedRange<CGFloat>) -> Generator<CGFloat, Shrink.Floating<CGFloat>> { return value(in: range) }
106106

107-
/// Produces a generator of random values within the specified range.
107+
/// Produces a generator of random floats within the specified range.
108108
///
109109
/// - Parameter range: The range in which to create a random value. `range` must be finite.
110110
/// - Returns: A generator of random values within the bounds of range.

Sources/PropertyBased/Gen+Int.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Copyright (c) 2019 Point-Free, Inc. MIT License
33

44
extension Gen where Value: FixedWidthInteger & Sendable {
5-
/// Produces a generator of random integers within the specified range.
5+
/// Produces a generator of random values within the specified range.
66
///
77
/// - Parameter range: The range in which to create a random value.
8-
/// - Returns: A generator of random integers within the bounds of range.
8+
/// - Returns: A generator of random values within the bounds of range.
99
@inlinable
1010
public static func value(in range: ClosedRange<Value> = Value.min ... Value.max) -> Generator<Value, Shrink.Integer<Value>> {
1111
return .init(
@@ -14,10 +14,10 @@ extension Gen where Value: FixedWidthInteger & Sendable {
1414
)
1515
}
1616

17-
/// Produces a generator of random integers within the specified range.
17+
/// Produces a generator of random values within the specified range.
1818
///
1919
/// - Parameter range: The range in which to create a random value.
20-
/// - Returns: A generator of random integers within the bounds of range.
20+
/// - Returns: A generator of random values within the bounds of range.
2121
@inlinable
2222
public static func value(in range: some RangeExpression<Value>) -> Generator<Value, Shrink.Integer<Value>> {
2323
return value(in: ClosedRange(range))

Sources/PropertyBased/PropertyCheck.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ import Testing
8888
/// @Test(.shrinking) func checkSumInRange() async
8989
/// ```
9090
///
91-
/// After shrinking, the new failing case is `[46, 97, 68, 23, 16]`, which sums to exactly `250`. The first few elements have been removed, which the middle element has been reduced to be closer to the edge.
91+
/// After shrinking, the new failing case is `[46, 97, 68, 23, 16]`, which sums to exactly `250`. The first few elements have been removed, while the middle element has been reduced to be closer to the edge.
9292
///
9393
/// When using built-in generators and the `zip` function to combine them, shrinkers will also be composed.
9494
///

Sources/PropertyBased/Shrink+Float.swift

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extension FloatingPoint {
6363
/// Get a shrinking sequence that shrinks this value to a specific value.
6464
///
6565
/// If this value or the given bound is NaN, the sequence is empty.
66-
/// - Parameter bound: The value to shrink to.
66+
/// - Parameter bound: The value to shrink towards.
6767
/// - Returns: A new sequence.
6868
@inlinable
6969
public func shrink(towards bound: Self) -> Shrink.Floating<Self> {
@@ -86,15 +86,42 @@ extension FloatingPoint {
8686
}
8787
}
8888

89+
/// Get a shrinking sequence that shrinks this value as close to the given bound as possible.
90+
///
91+
/// If this value is NaN, the sequence is empty.
92+
/// - Parameter range: If this range doesn't contain the `bound` parameter, the bound closest to the `bound` parameter will be used.
93+
/// - Parameter bound: The preferred bound to shrink towards. Defaults to zero.
94+
/// - Returns: A new sequence.
8995
@inlinable public func shrink(within range: Range<Self>, towards bound: Self = 0) -> Shrink.Floating<Self> {
9096
shrink(within: range.lowerBound ... range.upperBound.nextDown, towards: bound)
9197
}
98+
99+
/// Get a shrinking sequence that shrinks this value as close to the given bound as possible.
100+
///
101+
/// If this value is NaN, the sequence is empty.
102+
/// - Parameter range: If this range doesn't contain the `bound` parameter, the bound closest to the `bound` parameter will be used.
103+
/// - Parameter bound: The preferred bound to shrink towards. Defaults to zero.
104+
/// - Returns: A new sequence.
92105
@inlinable public func shrink(within range: PartialRangeThrough<Self>, towards bound: Self = 0) -> Shrink.Floating<Self> {
93106
shrink(towards: min(bound, range.upperBound))
94107
}
108+
109+
/// Get a shrinking sequence that shrinks this value as close to the given bound as possible.
110+
///
111+
/// If this value is NaN, the sequence is empty.
112+
/// - Parameter range: If this range doesn't contain the `bound` parameter, the bound closest to the `bound` parameter will be used.
113+
/// - Parameter bound: The preferred bound to shrink towards. Defaults to zero.
114+
/// - Returns: A new sequence.
95115
@inlinable public func shrink(within range: PartialRangeUpTo<Self>, towards bound: Self = 0) -> Shrink.Floating<Self> {
96116
shrink(towards: min(bound, range.upperBound.nextDown))
97117
}
118+
119+
/// Get a shrinking sequence that shrinks this value as close to the given bound as possible.
120+
///
121+
/// If this value is NaN, the sequence is empty.
122+
/// - Parameter range: If this range doesn't contain the `bound` parameter, the bound closest to the `bound` parameter will be used.
123+
/// - Parameter bound: The preferred bound to shrink towards. Defaults to zero.
124+
/// - Returns: A new sequence.
98125
@inlinable public func shrink(within range: PartialRangeFrom<Self>, towards bound: Self = 0) -> Shrink.Floating<Self> {
99126
shrink(towards: max(bound, range.lowerBound))
100127
}

Sources/PropertyBased/Shrink+Integer.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extension Shrink {
6060

6161
extension FixedWidthInteger {
6262
/// Get a shrinking sequence that shrinks this value to a specific value.
63-
/// - Parameter bound: The value to shrink to.
63+
/// - Parameter bound: The value to shrink towards.
6464
/// - Returns: A new sequence.
6565
@inlinable
6666
public func shrink(towards bound: Self) -> Shrink.Integer<Self> {
@@ -81,6 +81,10 @@ extension FixedWidthInteger {
8181
}
8282
}
8383

84+
/// Get a shrinking sequence that shrinks this value as close to the given bound as possible.
85+
/// - Parameter range: If this range doesn't contain the `bound` parameter, the bound closest to the `bound` parameter will be used.
86+
/// - Parameter bound: The preferred bound to shrink towards. Defaults to zero.
87+
/// - Returns: A new sequence.
8488
@inlinable
8589
public func shrink(within range: some RangeExpression<Self>, towards bound: Self = 0) -> Shrink.Integer<Self> {
8690
shrink(within: ClosedRange(range), towards: bound)

0 commit comments

Comments
 (0)