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

(ns midje.error-handling.semi-sweet-errors
  (:use 
    [clojure.pprint :only [cl-format]]
    [midje.error-handling.monadic :only [user-error-report-form validate]]
    [midje.util.namespace :only [matches-symbols-in-semi-sweet-or-sweet-ns?]]
    [midje.ideas.metaconstants :only [metaconstant-symbol?]]
    [midje.ideas.arrow-symbols :only [=contains=>]]))

(defmethod validate "fake" [form]
  (cond (not (list? (second form)))
        (user-error-report-form
          form
          "The left-hand-side of a prerequisite must look like a function call."
          (cl-format nil "`~S` doesn't." (second form)))
        :else
        (rest form)))

(defmethod validate "data-fake" [[header metaconstant arrow hash & remainder :as form]]
  (cond (not (metaconstant-symbol? metaconstant))
        (user-error-report-form
          form
          "You seem to be assigning values to a metaconstant, but there's no metaconstant.")

        (not= (matches-symbols-in-semi-sweet-or-sweet-ns? '(arrow) =contains=>))
        (user-error-report-form
          form
          "Assigning values to a metaconstant requires =contains=>")

        :else
        (rest form)))

(defmethod validate "expect" [form]
  (if (< (count form) 4)
    (user-error-report-form form
      (cl-format nil "    This form: ~A" form)
      (cl-format nil "Doesn't match: (~A <actual> => <expected> [<keyword-value pairs>*])" (first form)))
    (rest form)))<commit_msg>refactored validate method for "fake", in prep for adding feature<commit_after>;; -*- indent-tabs-mode: nil -*-

(ns midje.error-handling.semi-sweet-errors
  (:use 
    [clojure.pprint :only [cl-format]]
    [midje.error-handling.monadic :only [user-error-report-form validate]]
    [midje.util.namespace :only [matches-symbols-in-semi-sweet-or-sweet-ns?]]
    [midje.ideas.metaconstants :only [metaconstant-symbol?]]
    [midje.ideas.arrow-symbols :only [=contains=>]]))

(defmethod validate "fake" [[_fake_ & fake-form :as form]]
  (let [funcall (first fake-form)]
    (cond (not (list? funcall))
          (user-error-report-form
            form
            "The left-hand-side of a prerequisite must look like a function call."
            (cl-format nil "`~S` doesn't." funcall))
          :else
          fake-form)))

(defmethod validate "data-fake" [[header metaconstant arrow hash & remainder :as form]]
  (cond (not (metaconstant-symbol? metaconstant))
        (user-error-report-form
          form
          "You seem to be assigning values to a metaconstant, but there's no metaconstant.")

        (not= (matches-symbols-in-semi-sweet-or-sweet-ns? '(arrow) =contains=>))
        (user-error-report-form
          form
          "Assigning values to a metaconstant requires =contains=>")

        :else
        (rest form)))

(defmethod validate "expect" [form]
  (if (< (count form) 4)
    (user-error-report-form form
      (cl-format nil "    This form: ~A" form)
      (cl-format nil "Doesn't match: (~A <actual> => <expected> [<keyword-value pairs>*])" (first form)))
    (rest form)))
{'fraction_non_alphanumeric': 0.15121163166397414, 'fraction_numerical': 0.0006462035541195477, 'mean_word_length': 2.8222222222222224, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '6952186', 'n_tokens_mistral': 1042, 'n_tokens_neox': 995, 'n_words': 266}