SwiftCheck
SwiftCheck copied to clipboard
(U)Int `arbitrary` implementation provides limited values with `.proliferate(withSize:)`
Version
077c096c3ddfc38db223ac8e525ad16ffb987138
Environment
- macOS 11.6
- Xcode 13.1RC
- 2019 Intel 16" MBP
Description
When combined with proliferate(withSize:), (U)Int[8|16|32|64].arbitrary will only generate values from -30 to 30 if signed, and 0 to 30 if unsigned.
Steps To Reproduce
Set(UInt.arbitrary.proliferate(withSize: 2000).generate).sorted()
Expected Result
Random values in a wider range
Actual Result
Very limited range of random values
Additional information
None
This is intentional behaviour.
From Gen.swift:
/// Generates a value.
///
/// - Attention: This property exists as a convenience mostly to test
/// generators. In practice, you should never use this property because
/// it hinders the replay functionality and the robustness of tests in
/// general.
public var generate : A {
let r = newStdGen()
return unGen(r, 30)
}