Git Product home page Git Product logo

active-quickcheck's People

Contributors

bradfora avatar cresh avatar dfrese avatar kenranunderscore avatar markusschlegel avatar mikesperber avatar stillerharpo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

active-quickcheck's Issues

Coarbitrary implementation of spec-related combinators

You can currently use spec only to generate data but not to generate functions that take a spec as domain or range. In order to get there we need to implement coarbitraries for the such-that and generate-one-of combinators.

Properties generating functions/use unknown "types" will run forever

Using the property-macro for generating functions, it will run forever when choosing an "unknown" codomain (such as int instead of integer in the example below).

(ns active-quickcheck-example.core-test
  (:require [active.quickcheck :as qs]))

;; This one works.
(qs/quickcheck
 (qs/property [f (boolean -> boolean)]
              (boolean? (f))))

;; => OK, passed 100 tests.

;; This will run forever (?).
(qs/quickcheck
 (qs/property [i int
               f (int -> int)]
              (int? (f i))))

It would be helpful to notify the user that something went wrong.

Combinator kwargs

A lot of the combinators such as map-of take kwargs that modify the specs in some regards. We already implemented some of these kwargs with coll-of. We should make this implementation work with the other combinators as well.

Integration with `clojure.test` depends on being `:use`ed

When integrating active.quickcheck with clojure.test, one is required to import QuickCheck via :use. Otherwise, the tests QuickCheck runs will pass but an exception is reported.

(ns active-quickcheck-example.core-test
  (:use [active.quickcheck])
  (:require [clojure.test :refer :all]))

;; This will pass and NOT produce an exception
(deftest trivial-test
  (is (quickcheck
       (property [x integer]
                 (= x x)))))
;; => OK, passed 100 tests.
(ns active-quickcheck-example.core2-test
  (:require [clojure.test :refer :all]
            [active.quickcheck :as qc]))

;; This will report success but produce an exception
(deftest trivial-test
  (is (qs/quickcheck
       (qs/property [x integer]
                    (= x x)))))
;; => OK, passed 100 tests.
Fail in trivial-test

expected: (qs/quickcheck (qs/property [x integer] (= x x)))

  actual: (not          
           (qs/quickcheck
            #active.quickcheck.Property-type{:func
                                             #function[active-quickcheck-example.core2-test/fn--17615/fn--17616],
                                             :arg-names (x),
                                             :args
                                             (#active.quickcheck.Arbitrary-type{:generator
                                                                                #active.clojure.monad.Bind{:monad
                                                                                                           #active.quickcheck.Get-size-type{},
                                                                                                           :cont
                                                                                                           #function[active.quickcheck/sized/fn--14763]}})}))

More base generators

We need to support more base generators such as symbol? etc. This requires a bit of research first. What base generators does Clojure spec generators support?

`property` seems to ignore `:gen` clauses in specs

Expectation

If a spec is defined with an explicit generator (via the :gen) option, I would expect the property macro to generate values using that generator.

Observation

property seems to ignore the :gen clause. Example:

(ns example.check
  (:use [active.quickcheck])
  (:require [clojure.spec.alpha :as s]
            [clojure.test :as t]
            [clojure.test.check.generators :as gen]))

(s/def ::nat pos-int?)

(def sure-its-always-4-elems
  "A spec that always generates a list of exactly four distinct positive
  integers."
  (s/spec (s/coll-of ::nat :into [])
          :gen (fn []
                 (gen/list-distinct (s/gen ::nat) {:num-elements 4}))))

;; This works
(s/exercise sure-its-always-4-elems)

;; This doesn't work but instead generates examples with `nil` cases.
(quickcheck
 (property [ks (spec sure-its-always-4-elems)]
           (let [[a b c d] ks]
             (t/is (distinct? a b c d)))))

In this example, exercise always generates a vector of exactly four distinct numbers. Quickcheck, on the other hand, also generates lists with nil in them:

FAIL in () (NO_SOURCE_FILE:23)
expected: (distinct? a b c d)
  actual: (not (distinct? nil nil nil nil))
Falsifiable, after 0 tests:
ks = []

I would expect quickcheck to respect the provided gen. Is this a bug or a user-error?

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.