Skip to content

Commit d4abe36

Browse files
authored
Fix Frequency weight being affected by filters
1 parent 1281c48 commit d4abe36

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Sources/PropertyBased/Gen+Frequency.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extension Gen {
8585
let pick = FloatLiteralType.random(in: 0..<total, using: &rng)
8686
let index = options.firstIndex { $0.limit > pick }! as Int
8787

88-
return (index: index, value: options[index].gen._runIntermediate(&rng))
88+
return (index: index, value: options[index].gen.runFull(&rng).input)
8989
},
9090
shrink: { pair in
9191
let opt = options[pair.index]

Sources/PropertyBased/Generator.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ public struct Generator<ResultValue, ShrinkSequence: SendableSequenceType>: Send
3434

3535
/// Run the generator until a single unfiltered value is found.
3636
@inlinable
37-
internal func runFull<G: SeededRandomNumberGenerator>(_ rng: inout G) -> sending (
38-
input: InputValue, result: ResultValue
39-
) {
37+
internal func runFull<G: SeededRandomNumberGenerator>(_ rng: inout G)
38+
-> sending (
39+
input: InputValue, result: ResultValue
40+
)
41+
{
4042
var arng: any SeededRandomNumberGenerator = rng
4143
defer { rng = arng as! G }
4244

0 commit comments

Comments
 (0)