<commit_before>(ns purnam-karma-testing.test-sweet-doc
  (:use [purnam.cljs :only [aget-in aset-in js-equals]])
  (:use-macros [purnam.js :only [! ? f.n def.n obj arr]]
               [purnam.test :only [init describe is it]]
               [purnam.test.sweet :only [fact facts]]))

(init)

[[:chapter {:title "testing clojure"}]]

[[:section {:title "'pure' clojurescript hashmaps"}]]

(facts [[{:doc "Basic Hashmaps"
          :globals [o {:a 1 :b 2 :c 3}]}]]
  (o :a)       => 1 
  (o :a)       => #(not= 0 %)
  (get o :b)   => 2
  (:c o)       => 3
  (select-keys o [:a :b]) => {:a 1 :b 2})


[[:section {:title "native javascript objects"}]]

(facts [[{:doc "an example test description"
          :globals [ka "a"
                   kb "b"]
          :vars [o (obj :a 1 :b 2 :c 3)]}]]

 [[:subsection {:title "dot notation for native objects"}]]
 o.a => 1
 (+ o.a o.b o.c) => 6


 [[:subsection {:title "support for both native and cljs comparisons"}]]
 o => (obj :a 1 :b 2 :c 3)
 [1 2 3 4] => [1 2 3 4]

 [[:subsection {:title "support for function comparison"}]]
  2 => even?
  3 => (comp not even?)

  [[:subsection {:title "globals can be accessed"}]]
  o.|ka| => 1
  (+ o.|ka| o.|kb|) => 3

  [[:subsection {:title "vars can be rebound"}]]
  (! o (arr [1 2 3]
            [4 5 6]
            [7 8 9]))
          
  (- o.2.2 o.0.0) => 8)<commit_msg>refined midje-doc<commit_after>(ns purnam-karma-testing.test-sweet-doc
  (:use [purnam.cljs :only [aget-in aset-in js-equals]])
  (:use-macros [purnam.js :only [! ? f.n def.n obj arr]]
               [purnam.test :only [init describe is it]]
               [purnam.test.sweet :only [fact facts]]))

[[{:hide true}]]
(init)

[[:chapter {:title "testing clojure"}]]

[[:section {:title "'pure' clojurescript hashmaps"}]]

"Remember, these are tests in clojurescript!"

(def o {:a 1 :b 2 :c 3})

(facts [[{:doc "Basic Hashmaps"}]]
  (o :a)       => 1 
  (o :a)       => #(not= 0 %)
  (get o :b)   => 2
  (:c o)       => 3
  (select-keys o [:a :b]) => {:a 1 :b 2})


[[:section {:title "native javascript objects"}]]

"We now look at doing tests on native javascript objects"

(def o (obj :a 1 :b 2 :c 3))

(facts [[{:doc "an example test description"
          :globals [ka "a"
                   kb "b"]
          :vars [o (obj :a 1 :b 2 :c 3)]}]]
 
 "Here are some examples"
 
 [[:subsubsection {:title "dot notation for native objects"}]]
 o.a => 1
 (+ o.a o.b o.c) => 6


 [[:subsubsection {:title "support for both native and cljs comparisons"}]]
 o => (obj :a 1 :b 2 :c 3)
 [1 2 3 4] => [1 2 3 4]

 [[:subsubsection {:title "support for function comparison"}]]
  2 => even?
  3 => (comp not even?)

  [[:subsubsection {:title "globals can be accessed"}]]
  o.|ka| => 1
  (+ o.|ka| o.|kb|) => 3

  [[:subsubsection {:title "vars can be rebound"}]]
  (! o (arr [1 2 3]
            [4 5 6]
            [7 8 9]))
          
  (- o.2.2 o.0.0) => 8)
{'fraction_non_alphanumeric': 0.20309810671256454, 'fraction_numerical': 0.0306368330464716, 'mean_word_length': 2.418823529411765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '3425293', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1100, 'n_words': 381}