<commit_before>;; -*- indent-tabs-mode: nil -*-

(ns midje.util.t-report
  (:use [midje.util.report])
  (:use [midje.sweet])
  (:use [clojure.test])
  (:use [midje.test-util]))


(testable-privates midje.util.report midje-position-string functional-failure-lines
                   without-nasty-looking-functions)


;; This code generates failures. The following code prevents them from
;; being counted as failures when the final summary is printed. The
;; disadvantage is that legitimate failures won't appear in the final
;; summary. They will, however, produce failure output, so that's an
;; acceptable compromise.
(background (around :facts (let [report-counters @clojure.test/*report-counters*]
                             ?form
                             (dosync (commute clojure.test/*report-counters* (constantly report-counters)))) ))

(fact "string positions have filenames and line numbers"
  (midje-position-string ["filename.clj" 33]) => "(filename.clj:33)")

(defn re [expected]
  (fn [actual] (re-find expected actual)))

;; In the case of the checker (exactly odd?), you want to see failures
;; written in terms of a function name instead of some absurdly complicated
;; #<core$even_QMARK_ clojure.core$even_QMARK_@15ee9cc3>
(fact "(exactly odd?) is printed attractively"
  (without-nasty-looking-functions even?) => "a function named 'even?'"
  (without-nasty-looking-functions (fn [n] 1)) => (re #"fn__"))

<commit_msg>Keep report tests from confusing clojure.test.<commit_after>;; -*- indent-tabs-mode: nil -*-

(ns midje.util.t-report
  (:use [midje.util.report])
  (:use [midje.sweet])
  (:use [clojure.test])
  (:use [midje.test-util]))


(testable-privates midje.util.report midje-position-string functional-failure-lines
                   without-nasty-looking-functions)


;; This set of tests generate failures. The following code prevents
;; them from being counted as failures when the final summary is
;; printed. The disadvantage is that legitimate failures won't appear
;; in the final summary. They will, however, produce failure output,
;; so that's an acceptable compromise.

(when (nil? clojure.test/*report-counters*)
  (alter-var-root #'clojure.test/*report-counters*
                  (constantly (ref clojure.test/*initial-report-counters*))))

(background (around :facts (let [report-counters @clojure.test/*report-counters*]
                             ?form
                             (dosync (commute clojure.test/*report-counters* (constantly report-counters)))) ))


(fact "string positions have filenames and line numbers"
  (midje-position-string ["filename.clj" 33]) => "(filename.clj:33)")

(defn re [expected]
  (fn [actual] (re-find expected actual)))

;; In the case of the checker (exactly odd?), you want to see failures
;; written in terms of a function name instead of some absurdly complicated
;; #<core$even_QMARK_ clojure.core$even_QMARK_@15ee9cc3>
(fact "(exactly odd?) is printed attractively"
  (without-nasty-looking-functions even?) => "a function named 'even?'"
  (without-nasty-looking-functions (fn [n] 1)) => (re #"fn__"))


{'fraction_non_alphanumeric': 0.13313990973565443, 'fraction_numerical': 0.005802707930367505, 'mean_word_length': 3.708649468892261, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '639176', 'n_tokens_mistral': 967, 'n_tokens_neox': 925, 'n_words': 291}