Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

WIP: Setup Test Check #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/target/
**/.nrepl-port
**/.nrepl-history
/out
/.serverless
**/node_modules
Expand Down
2 changes: 1 addition & 1 deletion functions/boot.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#http://boot-clj.com
#Mon Aug 15 22:32:43 CEST 2016
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.9.0-alpha10
BOOT_CLOJURE_VERSION=1.9.0-alpha14
BOOT_VERSION=2.6.0
19 changes: 17 additions & 2 deletions functions/build.boot
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
:resource-paths #{"src"}
:dependencies '[[adzerk/boot-cljs "1.7.228-1" :scope "test"]
[adzerk/boot-cljs-repl "0.3.3" :scope "test"]
[adzerk/boot-reload "0.4.12" :scope "test"]
[adzerk/boot-reload "0.4.12" :scope "test"]
[pandeiro/boot-http "0.7.3" :scope "test"]
[crisptrutski/boot-cljs-test "0.3.0-SNAPSHOT" :scope "test"]
[boot-codox "0.10.0" :scope "test"]
[org.clojure/clojure "1.9.0-alpha12"]
[org.clojure/clojure "1.9.0-alpha14"]
[org.clojure/core.async "0.2.391"]
[org.clojure/test.check "0.9.0"]
[org.clojure/clojurescript "1.9.229"]
Expand All @@ -20,15 +20,30 @@
'[adzerk.boot-cljs :refer [cljs]]
'[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
'[adzerk.boot-reload :refer [reload]]
'[crisptrutski.boot-cljs-test :refer [test-cljs]]
'[codox.boot :refer [codox]]
'[pandeiro.boot-http :refer [serve]])

(deftask testing []
(merge-env! :resource-paths #{"test"})
identity)

(deftask auto-test []
(comp (testing)
(watch)
(speak)
(test-cljs)))

(deftask build []
(task-options! cljs {:compiler-options {:optimizations :simple
:target :nodejs}})
(comp (cljs)
(target)))

(deftask test []
(comp (testing)
(test-cljs)))

(deftask dev []
(comp (watch)
(checkout)
Expand Down
32 changes: 32 additions & 0 deletions functions/test/app/sample_test.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(ns app.sample-test
(:require [clojure.test.check :as tc]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop :include-macros true]
[cljs.spec :as s]
[cljs.spec.test :as stest]
[cljs.test :refer-macros [deftest is]]
[clojure.pprint :as pprint]))

(def sort-idempotent-prop
(prop/for-all [v (gen/vector gen/int)]
(= (sort v) (sort (sort v)))))

(tc/quick-check 100 sort-idempotent-prop)

;; Sample function and a function spec
(defn fooo [i] (+ i 20))

(s/fdef fooo
:args (s/cat :i integer?)
:ret integer?
:fn #(> (:ret %) (-> % :args :i)))

;; Utility functions to intergrate clojure.spec.test/check with clojure.test
(defn summarize-results' [spec-check]
(map (comp #(pprint/write % :stream nil) stest/abbrev-result) spec-check))

(defn check' [spec-check]
(is (nil? (-> spec-check first :failure)) (summarize-results' spec-check)))

;; Tests
(deftest fooish (check' (stest/check `fooo)))