github typelift/SwiftCheck v0.6.2
Scrap Your [Applicative] Boilerplate

latest releases: 0.12.0, 0.11.0, 0.10.1...
8 years ago

This release includes support for Swift 2.3. In addition, we've completely revamped the way you can interact with Gen with a new combinator Gen.compose.

Most users of this framework have to generate structures that involve significant amounts of setup and state. Previously, this meant you would have to go through the Applicative generator dance much like this

MyClass.create
  <^> Int.arbitrary
  <*> String.arbitrary
  <*> Float.arbitrary
  <*> // ...

This pattern, while terse, can lead to code bloat, bad compile times, and an overall bad experience with the framework. Instead, let's rewrite this in a more natural way [and infer all the types as a bonus!]

Gen<MyClass>.compose { c in
    return MyClass(
        // Use the nullary method to get an `arbitrary` value.
        a: c.generate(),

       // or pass a custom generator
       b: c.generate(Bool.suchThat { $0 == false }),

       // .. and so on, for as many values and types as you need.
       c: c.generate(), ...
    )
}

We're going to begin the process of deprecating the old pattern and replacing it with Gen.compose.

Don't miss a new SwiftCheck release

NewReleases is sending notifications on new releases.