babashka/test-resources/lib_tests/expound/test_utils.cljc
Gabriel Horner 665ae4dd97
Finish up library tests (#1120)
* Add tests for markdown-clj and tools.namespace

See comment for why only one markdown test could be run.
Closes #1069 and #1064

* Convert 10 test libs using add-libtest

Also improved add-libtest to only require maven artifact
and rely on clojars for getting git-url most of the time

* Convert 8 more test libs using add-libtest

Also updated table and added comment for newline test

* Fix doric test

* Disable tools.namespace test that fails on windows

* Added dozen manual test libs and converted 2 test libs

add-libtest.clj supports manually-added and test-directories options

* Converts last tests to test namespaces and write libraries.csv

* Add a number of library tests from projects.md

Also add more docs around adding test libs and tweak add script

* Use :sha for gitlib and older clojure cli

* Revert "Use :sha for gitlib and older clojure cli"

This reverts commit c663ab8368.

* Fix and disable failing tests

Disabled tests that fail consistently and fixed windows one
2021-12-29 16:35:14 +01:00

41 lines
1.5 KiB
Clojure

(ns expound.test-utils
(:require [clojure.spec.alpha :as s]
#?(:cljs
[clojure.spec.test.alpha :as st]
;; FIXME
;; orchestra is supposed to work with cljs but
;; it isn't working for me right now
#_[orchestra-cljs.spec.test :as st]
:clj [orchestra.spec.test :as st])
[expound.alpha :as expound]
[clojure.test :as ct]
;; BB-TEST-PATCH: Don't have this dep and can't load it
#_[com.gfredericks.test.chuck.clojure-test :as chuck]
[expound.util :as util]
[clojure.test.check.generators :as gen]))
;; test.chuck defines a reporter for the shrunk results, but only for the
;; default reporter (:cljs.test/default). Since karma uses its own reporter,
;; we need to provide an implementation of the report multimethod for
;; the karma reporter and shrunk results
; (defmethod ct/report [:jx.reporter.karma/karma ::chuck/shrunk] [m]
; (let [f (get (methods ct/report) [::ct/default ::chuck/shrunk])]
; (f m)))
(defn check-spec-assertions [test-fn]
(s/check-asserts true)
(test-fn)
(s/check-asserts false))
(defn instrument-all [test-fn]
(binding [s/*explain-out* (expound/custom-printer {:theme :figwheel-theme})]
(st/instrument)
(test-fn)
(st/unstrument)))
(defn contains-nan? [x]
(boolean (some util/nan? (tree-seq coll? identity x))))
(def any-printable-wo-nan (gen/such-that (complement contains-nan?)
gen/any-printable))