ghostwheel

Hassle-free clojure.spec, automatic generative testing, side effect detection, and evaluation tracing for Clojure(-Script) – https://github.com/gnl/ghostwheel
Sen 2018-08-25T02:51:24.000100Z

I cannot find out a way to 'turn on' >fdef, what am I doing wrong?

(ns test-ghostwheel.events
#:ghostwheel.core{:check     true
                    :num-tests 10}
  (:require
   [re-frame.core :as re-frame]
   [clojure.core :as c]
   [cljs.spec.alpha :as s]
   [cljs.spec.test.alpha :as stest]
   [ghostwheel.core :as g
             :refer [>defn >defn- >fdef => | <- ?]]
   [test-ghostwheel.db :as db]
   ))

(re-frame/reg-event-db
 ::initialize-db
 (fn [_ _]
   db/default-db))

(>fdef c/max
       [x & more]
       [number? (s/* number?) => number?])

(>fdef c/count
       [x]
       [(? (some-fn seqable? counted?)) => nat-int?])

(defn addition
       [a b]
       (+ a b))

(>fdef addition
       [a b]
       [pos-int? pos-int?
        => int? | #(> % a) #(> % b)])

(g/check)

Sen 2018-08-25T02:52:07.000100Z

Browser console says 'No active tests found'

gnl 2018-08-25T08:16:37.000100Z

@armikhalev >fdef is meant to be used for spec-instrumentation of external libraries/namespaces where you don't write the function code yourself. In Ghostwheel only >defn generates tests when you properly define the specs inline.

gnl 2018-08-25T08:18:49.000100Z

(And on a side note – re-frame is a great choice to use with Ghostwheel because of the ability to have pure events, which are perfect for generative testing.)

👍 1
Sen 2018-08-25T13:44:16.000100Z

Thank you for explanation, I somehow didn't catch that. I have a case where I can't use >defn macro because I already use a macro for the function. I'm using re-frame-10x library for tracing data, it requires macro as per https://github.com/Day8/re-frame-10x/blob/master/docs/HyperlinkedInformation/EventCodeTracing.md So, it might be that I can just live without that, I would prefer having my functions speced, but it would be nice to have.

gnl 2018-08-25T17:07:03.000100Z

@armikhalev I'll give this some more thought, but in the meantime I can point you to Ghostwheel's own tracing functionality, which you could use instead: https://github.com/gnl/ghostwheel#evaluation-tracing-and-program-observability

gnl 2018-08-25T17:07:27.000100Z

You can still use re-frame-10x for high level event tracing and use Ghostwheel for low-level in-depth tracing of single functions.

Sen 2018-08-25T18:06:33.000100Z

Thanks, overall I'm pretty much satisfied with Ghostwheel's tracing, not much need of 10x, just for the future, it might be worth to investigate this problem further.

gnl 2018-08-25T18:09:35.000100Z

Yup, it's not a priority but I will put it on the list. For now I think re-frame-10x and Ghostwheel can complement each other quite nicely, but we'll see how well that works in practice over a longer period and if any issues pop up.