<commit_before>(ns midje.parsing.2-to-lexical-maps.t-expects
  (:use clojure.test  ;; This is used to check production mode with deftest.
        midje.sweet
        midje.parsing.2-to-lexical-maps.expects
        midje.test-util
        midje.util)
  (:require [midje.config :as config]
            [midje.util.pile :as pile]
            [midje.parsing.util.recognizing :as recognize]
            [midje.emission.api :as emit]))
(expose-testables midje.parsing.2-to-lexical-maps.expects)
 
(unfinished faked-function mocked-function other-function)


;;;

(fact "expect calls emission functions"
  (tabular "emit/pass"
    (fact
      ?expect-call => anything
      (provided
        (emit/pass) => anything))
    ?expect-call
    (expect 1 => 1)
    (expect 2 =not=> 1)
    (expect 1 => odd?)))

;;; RE-EXAMINE THE USEFULNESS OF THESE TESTS

(defchecker odd-checker
  [actual]
  (odd? actual))

(fact "separating overrides of an #expect from fakes"
  ;; The lets are because fact isn't smart enough not to add overrides to fake call otherwise.
  (let [actual (separate recognize/fake?  '( (fake (f 1) => 2) :key 'value))]
    actual => [  '[(fake (f 1) => 2)]
                 '[:key 'value] ])

  (let [actual (separate recognize/fake?  '( (not-called some-function) :key 'value))]
    actual => [ '[(not-called some-function)]
                '[:key 'value] ])

  ;; often passed a seq.
  (let [actual (separate recognize/fake?  (seq '( (fake (f 1) => 2) :key 'value)))]
    actual => [  '[(fake (f 1) => 2)]
                 '[:key 'value] ])

  (let [actual (separate recognize/fake?  '())]
    actual => (just empty? empty?))

  "data fakes too"
  (let [actual (separate recognize/fake?  '((data-fake ..m.. =contains=> {:a 1}) :key 'value))]
    actual => [  '[(data-fake ..m.. =contains=> {:a 1})]
                 '[:key 'value] ]))


(fact "calling a faked function raises an error"
  (faked-function) => (throws Error))

(facts "about the creation of fake maps"
  (let [some-variable 5
        previous-line-position (file-position 1)
        fake-0 (fake (faked-function) => 2)
        fake-1 (fake (faked-function some-variable) => (+ 2 some-variable))
        fake-2 (fake (faked-function 1 some-variable) => [1 some-variable])
        fake-streamed (fake (faked-function 0) =streams=> ['r1 'r2])]

    (fact "The basic parts"
      (:var fake-0) => #'midje.parsing.2-to-lexical-maps.t-expects/faked-function
      (:call-text-for-failures fake-1) => "(faked-function some-variable)"
      (deref (:call-count-atom fake-0)) => 0)

    (fact "argument matching"
      (count (:arg-matchers fake-0)) => 0)

    (fact "Note that lexical scoping is obeyed"
      (count (:arg-matchers fake-1)) => 1
      (pile/apply-pairwise (:arg-matchers fake-1) [5] [nil]) => [[true] [false]]
      (count (:arg-matchers fake-2)) => 2
      (pile/apply-pairwise (:arg-matchers fake-2) [5 5] [1 1]) => [  [false true]
                                                                     [true false] ])

    (fact "Result supplied"
      ((:result-supplier fake-0)) => 2
      ((:result-supplier fake-1)) => (+ 2 some-variable)
      ((:result-supplier fake-2)) => [1 some-variable])

    (fact "Streamed results"
      ((:result-supplier fake-streamed)) => 'r1
      ((:result-supplier fake-streamed)) => 'r2)))<commit_msg>These tests no longer make sense here. The responsibility of arg-matchers is abstracted from the fake. As far as its concerned it gets a function that is used to match arguments, not the internal details of how that works<commit_after>(ns midje.parsing.2-to-lexical-maps.t-expects
  (:use clojure.test  ;; This is used to check production mode with deftest.
        midje.sweet
        midje.parsing.2-to-lexical-maps.expects
        midje.test-util
        midje.util)
  (:require [midje.config :as config]
            [midje.util.pile :as pile]
            [midje.parsing.util.recognizing :as recognize]
            [midje.emission.api :as emit]))
(expose-testables midje.parsing.2-to-lexical-maps.expects)
 
(unfinished faked-function mocked-function other-function)


;;;

(fact "expect calls emission functions"
  (tabular "emit/pass"
    (fact
      ?expect-call => anything
      (provided
        (emit/pass) => anything))
    ?expect-call
    (expect 1 => 1)
    (expect 2 =not=> 1)
    (expect 1 => odd?)))

;;; RE-EXAMINE THE USEFULNESS OF THESE TESTS

(defchecker odd-checker
  [actual]
  (odd? actual))

(fact "separating overrides of an #expect from fakes"
  ;; The lets are because fact isn't smart enough not to add overrides to fake call otherwise.
  (let [actual (separate recognize/fake?  '( (fake (f 1) => 2) :key 'value))]
    actual => [  '[(fake (f 1) => 2)]
                 '[:key 'value] ])

  (let [actual (separate recognize/fake?  '( (not-called some-function) :key 'value))]
    actual => [ '[(not-called some-function)]
                '[:key 'value] ])

  ;; often passed a seq.
  (let [actual (separate recognize/fake?  (seq '( (fake (f 1) => 2) :key 'value)))]
    actual => [  '[(fake (f 1) => 2)]
                 '[:key 'value] ])

  (let [actual (separate recognize/fake?  '())]
    actual => (just empty? empty?))

  "data fakes too"
  (let [actual (separate recognize/fake?  '((data-fake ..m.. =contains=> {:a 1}) :key 'value))]
    actual => [  '[(data-fake ..m.. =contains=> {:a 1})]
                 '[:key 'value] ]))


(fact "calling a faked function raises an error"
  (faked-function) => (throws Error))

(facts "about the creation of fake maps"
  (let [some-variable 5
        previous-line-position (file-position 1)
        fake-0 (fake (faked-function) => 2)
        fake-1 (fake (faked-function some-variable) => (+ 2 some-variable))
        fake-2 (fake (faked-function 1 some-variable) => [1 some-variable])
        fake-streamed (fake (faked-function 0) =streams=> ['r1 'r2])]

    (fact "The basic parts"
      (:var fake-0) => #'midje.parsing.2-to-lexical-maps.t-expects/faked-function
      (:call-text-for-failures fake-1) => "(faked-function some-variable)"
      (deref (:call-count-atom fake-0)) => 0)

    (fact "Result supplied"
      ((:result-supplier fake-0)) => 2
      ((:result-supplier fake-1)) => (+ 2 some-variable)
      ((:result-supplier fake-2)) => [1 some-variable])

    (fact "Streamed results"
      ((:result-supplier fake-streamed)) => 'r1
      ((:result-supplier fake-streamed)) => 'r2)))
{'fraction_non_alphanumeric': 0.1656499296105115, 'fraction_numerical': 0.015485687470671047, 'mean_word_length': 2.647461494580719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 66, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '929573', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2133, 'n_words': 603}