Skip to content

Code from README doesn't compile #299

Description

@xavierLowmiller

Version

077c096c3ddfc38db223ac8e525ad16ffb987138

Environment

macOS 10.15.6, Swift 5.2, Xcode 11.6

Description

I was following the steps from README.md to learn about SwiftCheck.
Unfortunately, the example for complex properties doesn't compile:

property("Shrunken lists of integers always contain [] or [0]") <- forAll { (l : [Int]) in
  // Here we use the Implication Operator `==>` to define a precondition for
  // this test.  If the precondition fails the test is discarded.  If it holds
  // the test proceeds.
  return (!l.isEmpty && l != [0]) ==> {
    let ls = self.shrinkArbitrary(l)
    //       ^ Value of type 'ExampleTests' has no member 'shrinkArbitrary'
    return (ls.filter({ $0 == [] || $0 == [0] }).count >= 1)
  }
}

I'm no expert on QuickCheck (or SwiftCheck), so I don't know how to fix this message.

Steps To Reproduce

  1. Create a new test function
  2. Copy the code block from README.md

Expected Result

The code compiles and produces a passing test case.

Actual Result

There is a compiler error:
Value of type 'ExampleTests' has no member 'shrinkArbitrary'

Additional information

--

Activity

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