<commit_before>(ns com.nomistech.clojure-the-language.c-200-clojure-basics.s-600-clojure-spec
  (:require [clojure.spec.alpha :as s]
            [midje.sweet :refer :all]))

;;;; ___________________________________________________________________________
;;;; Stuff from https://clojure.org/guides/spec

(fact "Intro to `conform`: spec X value -> value"
  (fact (s/conform even? 1000) => 1000)
  (fact (s/conform even? 1001) => :clojure.spec.alpha/invalid))

(fact "Intro to `valid?`: spec X value -> boolean"
  (fact (s/valid? even? 1000) => true)
  (fact (s/valid? even? 1001) => false))<commit_msg>clojure.spec: Can use arbitrary functions as specs<commit_after>(ns com.nomistech.clojure-the-language.c-200-clojure-basics.s-600-clojure-spec
  (:require [clojure.spec.alpha :as s]
            [midje.sweet :refer :all])
  (:import java.util.Date))

;;;; ___________________________________________________________________________
;;;; Stuff from https://clojure.org/guides/spec

(fact "Intro to `conform`: spec X value -> value"
  (fact (s/conform even? 1000) => 1000)
  (fact (s/conform even? 1001) => :clojure.spec.alpha/invalid))

(fact "Intro to `valid?`: spec X value -> boolean"
  (fact (s/valid? even? 1000) => true)
  (fact (s/valid? even? 1001) => false))

(fact "Can use arbitrary functions as specs"
  (fact (s/valid? nil? nil) => true)
  (fact (s/valid? string? "abc") => true)
  (fact (s/valid? #(> % 5) 10) => true)
  (fact (s/valid? #(> % 5) 0) => false)
  (fact (s/valid? inst? (Date.)) => true))

(fact "Can use sets as predicates (because sets are functions)"
  (fact (s/valid? #{:club :diamond :heart :spade} :club) => true)
  (fact (s/valid? #{:club :diamond :heart :spade} 42) => false)
  (fact (s/valid? #{42} 42) => true))
{'fraction_non_alphanumeric': 0.18259874069834, 'fraction_numerical': 0.03606182026330853, 'mean_word_length': 4.2023809523809526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '6651403', 'n_tokens_mistral': 689, 'n_tokens_neox': 617, 'n_words': 166}