<commit_before>(ns check.fun-with-values-test
  (:require [mount.core :as mount :refer [defstate]]
            [clojure.test :refer :all]))

(defn f [n]
  (fn [m]
    (+ n m)))

(defn g [a b]
  (+ a b))

(defn- pf [n]
  (+ 41 n))

(defn fna []
  42)

(defstate scalar :start 42)
(defstate fun :start #(inc 41))
(defstate with-fun :start (inc 41))
(defstate with-partial :start (partial g 41))
(defstate f-in-f :start (f 41))
(defstate f-no-args-value :start (fna))
(defstate f-no-args :start fna)
(defstate f-args :start g)
(defstate f-value :start (g 41 1))
(defstate private-f :start pf)

(defn with-fun-and-values [f]
  (mount/start #'check.fun-with-values-test/scalar
               #'check.fun-with-values-test/fun
               #'check.fun-with-values-test/with-fun
               #'check.fun-with-values-test/with-partial
               #'check.fun-with-values-test/f-in-f
               #'check.fun-with-values-test/f-args
               #'check.fun-with-values-test/f-no-args-value
               #'check.fun-with-values-test/f-no-args
               #'check.fun-with-values-test/private-f
               #'check.fun-with-values-test/f-value)
  (f)
  (mount/stop))

(use-fixtures :each with-fun-and-values)

(deftest fun-with-values
  (is (= @scalar 42))
  (is (= (@fun) 42))
  (is (= @with-fun 42))
  (is (= (@with-partial 1) 42))
  (is (= (@f-in-f 1) 42))
  (is (= @f-no-args-value 42))
  (is (= (@f-no-args) 42))
  (is (= (@f-args 41 1) 42))
  (is (= (@private-f 1) 42))
  (is (= @f-value 42)))

(deftest deref-fun-with-values
  (mount/in-cljc-mode)
  (is (= scalar 42))
  (is (= (fun) 42))
  (is (= with-fun 42))
  (is (= (with-partial 1) 42))
  (is (= (f-in-f 1) 42))
  (is (= f-no-args-value 42))
  (is (= (f-no-args) 42))
  (is (= (f-args 41 1) 42))
  (is (= (private-f 1) 42))
  (is (= f-value 42))
  (mount/in-clj-mode))
<commit_msg>swapping fun with values (deref vs. values)<commit_after>(ns check.fun-with-values-test
  (:require [mount.core :as mount :refer [defstate]]
            [clojure.test :refer :all]))

(defn f [n]
  (fn [m]
    (+ n m)))

(defn g [a b]
  (+ a b))

(defn- pf [n]
  (+ 41 n))

(defn fna []
  42)

(defstate scalar :start 42)
(defstate fun :start #(inc 41))
(defstate with-fun :start (inc 41))
(defstate with-partial :start (partial g 41))
(defstate f-in-f :start (f 41))
(defstate f-no-args-value :start (fna))
(defstate f-no-args :start fna)
(defstate f-args :start g)
(defstate f-value :start (g 41 1))
(defstate private-f :start pf)

(defn with-fun-and-values [f]
  (mount/start #'check.fun-with-values-test/scalar
               #'check.fun-with-values-test/fun
               #'check.fun-with-values-test/with-fun
               #'check.fun-with-values-test/with-partial
               #'check.fun-with-values-test/f-in-f
               #'check.fun-with-values-test/f-args
               #'check.fun-with-values-test/f-no-args-value
               #'check.fun-with-values-test/f-no-args
               #'check.fun-with-values-test/private-f
               #'check.fun-with-values-test/f-value)
  (f)
  (mount/stop))

(use-fixtures :each with-fun-and-values)

(deftest fun-with-values
  (is (= scalar 42))
  (is (= (fun) 42))
  (is (= with-fun 42))
  (is (= (with-partial 1) 42))
  (is (= (f-in-f 1) 42))
  (is (= f-no-args-value 42))
  (is (= (f-no-args) 42))
  (is (= (f-args 41 1) 42))
  (is (= (private-f 1) 42))
  (is (= f-value 42)))

(deftest deref-fun-with-values
  (mount/in-cljc-mode)
  (is (= @scalar 42))
  (is (= (@fun) 42))
  (is (= @with-fun 42))
  (is (= (@with-partial 1) 42))
  (is (= (@f-in-f 1) 42))
  (is (= @f-no-args-value 42))
  (is (= (@f-no-args) 42))
  (is (= (@f-args 41 1) 42))
  (is (= (@private-f 1) 42))
  (is (= @f-value 42))
  (mount/in-clj-mode))

{'fraction_non_alphanumeric': 0.20969469737546867, 'fraction_numerical': 0.036957686127477234, 'mean_word_length': 2.4140767824497256, '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': '6628475', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1528, 'n_words': 354}