<commit_before>;; Note: checkers need to be exported in ../checkers.clj

(ns ^{:doc "Prepackaged functions that perform common checks."}
  midje.checking.checkers.simple
  (:use midje.clojure.core
        midje.checking.core
        [midje.checking.checkers.defining :only [as-checker checker defchecker]]
      	[midje.checking.checkers.util :only [named-as-call]]
      	[midje.util.exceptions :only [captured-throwable?]]
        [midje.util.ecosystem :only [clojure-1-3? +M -M *M]]
        [clojure.algo.monads :only [domonad set-m]])
  (:import [midje.util.exceptions ICapturedThrowable]))

(defchecker truthy 
  "Returns precisely true if actual is not nil and not false."
  [actual] 
  (and (not (captured-throwable? actual))
       (boolean actual)))
(defalias TRUTHY truthy)

(defchecker falsey 
  "Returns precisely true if actual is nil or false."
  [actual] 
  (not actual))
(defalias FALSEY falsey)

(defchecker & "Any arity" [])

(defchecker anything
  "Accepts any value."
  [actual]
  (not (captured-throwable? actual)))
(defalias irrelevant anything)

(defchecker exactly
  "Checks for equality. Use to avoid default handling of functions."
  [expected]
    (named-as-call "exactly" expected
                   (checker [actual] (= expected actual))))

(letfn [(abs [n]
          (if (pos? n)
            n
            (-M n)))] ;; -M not strictly necessary, but...

  (defchecker roughly
    "With two arguments, accepts a value within delta of the
     expected value. With one argument, the delta is 1/1000th
     of the expected value."
    ([expected delta]
       (checker [actual]
         (and (number? actual)
              (>= expected (-M actual delta))
              (<= expected (+M actual delta)))))<commit_msg>Arity checker just checks a list of argument-matchers against the actual value.<commit_after>;; Note: checkers need to be exported in ../checkers.clj

(ns ^{:doc "Prepackaged functions that perform common checks."}
  midje.checking.checkers.simple
  (:use midje.clojure.core
        midje.checking.core
        [midje.checking.checkers.defining :only [as-checker checker defchecker]]
      	[midje.checking.checkers.util :only [named-as-call]]
      	[midje.util.exceptions :only [captured-throwable?]]
        [midje.util.ecosystem :only [clojure-1-3? +M -M *M]]
        [clojure.algo.monads :only [domonad set-m]])
  (:import [midje.util.exceptions ICapturedThrowable]))

(defchecker truthy 
  "Returns precisely true if actual is not nil and not false."
  [actual] 
  (and (not (captured-throwable? actual))
       (boolean actual)))
(defalias TRUTHY truthy)

(defchecker falsey 
  "Returns precisely true if actual is nil or false."
  [actual] 
  (not actual))
(defalias FALSEY falsey)

(defchecker & "Any arity" [actual argument-matchers]
  (reduce #(extended-= actual %) argument-matchers))

(defchecker anything
  "Accepts any value."
  [actual]
  (not (captured-throwable? actual)))
(defalias irrelevant anything)

(defchecker exactly
  "Checks for equality. Use to avoid default handling of functions."
  [expected]
    (named-as-call "exactly" expected
                   (checker [actual] (= expected actual))))

(letfn [(abs [n]
          (if (pos? n)
            n
            (-M n)))] ;; -M not strictly necessary, but...

  (defchecker roughly
    "With two arguments, accepts a value within delta of the
     expected value. With one argument, the delta is 1/1000th
     of the expected value."
    ([expected delta]
       (checker [actual]
         (and (number? actual)
              (>= expected (-M actual delta))
              (<= expected (+M actual delta)))))
{'fraction_non_alphanumeric': 0.12189740761169332, 'fraction_numerical': 0.003861003861003861, 'mean_word_length': 2.963934426229508, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7234483', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1131, 'n_words': 364}