Skip to content

Releases: typelift/SwiftCheck

Target Practice

09 Oct 23:26
Compare
Choose a tag to compare
  • Fixes a compatibility issue with the Swift Package Manager
  • Thanks to gyb, zip and map now extend all the way out to arity 22.
  • The default RawRepresentable arbitrary instance has been removed.

The Seven Chekras

16 Sep 23:21
Compare
Choose a tag to compare

⚠️ Breaking Changes Ahead ⚠️

SwiftCheck now fully supports Swift 3.0 and Xcode 8.0. That entails a bit of breakage:

  • The operator equivalents for functional combinators have been removed - these are, <^>, <*>, and >>-. Please use their nominal equivalents .map, .ap, and .flatMap respectively.
  • For long Applicative-style chains a <^> b <*> c <*> ... please use Gen.compose.
  • The little-known and barely-used exhaustive requirement of Arbitrary has been removed. Please use .once and .again.

In addition, we have a number of framework improvements:

  • Gen.withBounds and Gen.chooseAny have been added to make interacting with RandomType and LatticeType generators even easier.
  • Fixes a potential crash when interacting with randomInRange for large unsigned values.
  • Documentation coverage and robustness continues to increase with the addition of doc comments.
  • SwiftCheck now builds without dependencies.

Thank you to everybody who contributed to this release.

@griotspeak
@bgerstle
@kouky
@EuAndreh
@kballard
@gfontenot
@kykim

❤️

Scrap Your [Applicative] Boilerplate

29 Aug 16:54
Compare
Choose a tag to compare

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.

The Exchequer

06 May 23:41
Compare
Choose a tag to compare

This is an exciting release for us, led by a ton of helpful new features and patterns to make the framework easier more Swifty. Let's get right to it:

  • We know it can be a huge pain to work with the Applicative operators. To that end, we have included an instance of Monoidal Functors (rather than the old Applicative one) for Gen that provides an overload of zip up to 10 parameters. This means code that previously looked like this:
public struct ArbitraryFoo {
    let x : Int
    let y : Int

    public static func create(x : Int) -> Int -> ArbitraryFoo {
        return { y in ArbitraryFoo(x: x, y: y) }
    }
}

extension ArbitraryFoo : Arbitrary {
    public static var arbitrary : Gen<ArbitraryFoo> {
        return ArbitraryFoo.create <^> Int.arbitrary <*> Int.arbitrary
    }
}

Can instead scrap the horrific initializer boilerplate and move straight to zip then map like so:

public struct ArbitraryFoo {
    let x : Int
    let y : Int
}

extension ArbitraryFoo : Arbitrary {
    public static var arbitrary : Gen<ArbitraryFoo> {
        return Gen<(Int, Int)>.zip(Int.arbitrary, Int.arbitrary).map(ArbitraryFoo.init)
    }
}

If you ever run out of parameters, try flatMaping generators together.

  • Enums that conform to RawRepresentable now have a default instance of Arbitrary if you ask for it. To do so, simply declare your conformance to both RawRepresentable and Arbitrary and we'll handle the rest (thanks @bgerstle!).
  • zip and ap now have much, much faster implementations.
  • Fixed a bug (h/t @bgerstle) where replay seeds and sizes would fail to print if the test failed through coverage.
  • The framework's overall documentation and code coverage continue to improve.

Check Yourself Before You Wreck Yourself

22 Mar 02:26
Compare
Choose a tag to compare
  • SwiftCheck now fully supports Swift 2.2 and all that entails including
    • Support for the Swift Package Manager
    • Support for building SwiftCheck on Linux
  • The order of Gen.sequence and Rose.sequence have been fixed.
  • Documentation has been added to more parts of the framework.
  • Our own test suite is now more robust.

Arbiter of Perfection

17 Mar 04:28
Compare
Choose a tag to compare
  • Adjusts internal RNG code for integers so it isn't subject to integer overflow conditions. This fixes #151 and may, as a side-effect, cause existing seed values created before this release to report different values as the calculations have become more robust.

Carthaginian Angst

22 Jan 21:54
Compare
Choose a tag to compare
  • Fixes compatibility issues with the iOS Carthage scheme (h/t @samritchie).

Harry Potter and the Half-Blood print()s

08 Jan 10:15
Compare
Choose a tag to compare

⚠️ Breaking Changes Ahead ⚠️

For SwiftCheck's 5th birthday, we sped up all the insides and moved the furniture around a bit.

  • The insides of Gen move an order of magnitude quicker because of framework-wide simplifications.
  • We now match Swift's naming convention for some big combinators (esp. map and flatMap). Update your code accordingly!
  • Currying syntax has been removed framework-wide and labels have been made more semantically meaningful.
  • Gen.fromShufflingElementsOf is unbelievably fast now.
  • pseudo-Equatable instances for modifier types have been removed.
  • More things have been documented and what documentation there is has been improved.
  • Quantifiers and property binders have more informative @warn_unused_result messages.

Finally, for the pièce de résistance, cover has been made a first-class citizen of the framework. For those times when a particular property of a spec should hold a certain percentage of the time, you can ask SwiftCheck how well it's been covered. If we don't rise to meet your set goals, the test fails!

screen shot 2016-01-08 at 2 53 31 am

Production Rights

04 Jan 05:21
Compare
Choose a tag to compare

We fought xcodebuild tooth and nail to bring you tvOS support. Enjoy!

Effectric Slide

28 Dec 22:22
Compare
Choose a tag to compare
  • Framework build times continue to improve.
  • Fixes an issue where building the framework in release mode would cause strange crashes (h/t @kykim).