<commit_before>(ns cmr.common.test.test-check-ext
  (:require [clojure.test.check.generators :as gen]
            [clojure.string :as s]
            [clj-time.coerce :as c]
            [clojure.test.check.clojure-test]
            [clojure.test.check]
            [clojure.test]
            [clojure.pprint])
  (:import java.util.Random))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The following two functions were copy and pasted from the clojure test.check library to fix a small
;; issue relating to the printing out of failed specs.
;; See http://dev.clojure.org/jira/browse/TCHECK-18
;; I have also changed the argument just after name, options, to be a map of options that can be passed in.

(def ^:dynamic  *default-test-count* 100)

(defn- assert-check
  [{:keys [result shrunk fail] :as m} {:keys [printer-fn]}]
  (println (pr-str m))

  (when printer-fn
    (when fail
      (println "-----------------------------------------------------------------------")
      (printer-fn :first-fail (first fail)))
    (when (:smallest shrunk)
      (println "-----------------------------------------------------------------------")
      (printer-fn :shrunken (first (:smallest shrunk)))))

  (if (instance? Throwable result)
    (throw result)
    (clojure.test/is result)))

(defmacro defspec
  "Defines a new clojure.test test var that uses `quick-check` to verify
  [property] with the given [args] (should be a sequence of generators).<commit_msg>Fixing the way the printer function is called for test check failures so that it will handle multiple generated values.<commit_after>(ns cmr.common.test.test-check-ext
  (:require [clojure.test.check.generators :as gen]
            [clojure.string :as s]
            [clj-time.coerce :as c]
            [clojure.test.check.clojure-test]
            [clojure.test.check]
            [clojure.test]
            [clojure.pprint])
  (:import java.util.Random))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The following two functions were copy and pasted from the clojure test.check library to fix a small
;; issue relating to the printing out of failed specs.
;; See http://dev.clojure.org/jira/browse/TCHECK-18
;; I have also changed the argument just after name, options, to be a map of options that can be passed in.

(def ^:dynamic  *default-test-count* 100)

(defn- assert-check
  [{:keys [result shrunk fail] :as m} {:keys [printer-fn]}]
  (println (pr-str m))

  (when printer-fn
    (when fail
      (println "-----------------------------------------------------------------------")
      (apply printer-fn :first-fail fail))
    (when (:smallest shrunk)
      (println "-----------------------------------------------------------------------")
      (apply printer-fn :shrunken (:smallest shrunk))))

  (if (instance? Throwable result)
    (throw result)
    (clojure.test/is result)))

(defmacro defspec
  "Defines a new clojure.test test var that uses `quick-check` to verify
  [property] with the given [args] (should be a sequence of generators).
{'fraction_non_alphanumeric': 0.2306930693069307, 'fraction_numerical': 0.0033003300330033004, 'mean_word_length': 2.1938883034773444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4611527', 'n_tokens_mistral': 936, 'n_tokens_neox': 877, 'n_words': 286}