Coder Social home page Coder Social logo

conditional property doc example about scalacheck HOT 2 CLOSED

mgk avatar mgk commented on May 18, 2024
conditional property doc example

from scalacheck.

Comments (2)

Philippus avatar Philippus commented on May 18, 2024
  1. I think it's because of the n >= 0 part in propMakeList.
    ScalaCheck has a bias for special values (like 0 and 1).
    Probably in this case the values 0 and 1 are selected enough times for 100 successful tests.

If you change your x > 0 to x >=0 you will also get 100 successful tests (but mainly 0 and 1 will be tested).

You can play around with collect to see the distribution of the generated data:

  val propMakeList = forAll { n: Int =>
    collect(n) {
      (n >= 0 && n < 10000) ==> (List.fill(n)("").length == n)
    }
  }

(This also means that the example given in the documentation is a little unfortunate as the property is only really tested for values 0 and 1.)

  1. yes, I think so.

from scalacheck.

ashawley avatar ashawley commented on May 18, 2024

That's correct. The example uses fencing so it is a fragile test. The tutorial now includes information about discarded generated values.

from scalacheck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.