Skip to content

(U)Int arbitrary implementation provides limited values with .proliferate(withSize:) #307

Description

@nesevis

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

Activity

  1. changed the title [-](U)Int `arbitrary` implementation provides limited values with `.proliferateWithSize`[/-] [+](U)Int `arbitrary` implementation provides limited values with `.proliferate(withSize:)`[/+] on Oct 19, 2021
  2. Qata commented on May 15, 2025

    @Qata

    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)
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions