Skip to content

Commit

Permalink
Add formatter test file [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Nov 16, 2021
1 parent ee3bf28 commit 71acfcf
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test-data/formatter_sandbox.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(def colt-express
{:name "Colt Express"
:categories ["Family"
"Strategy"]
:play-time 40
:ratings {:pez 5.0
:kat 5.0
:wiw 5.0
:vig 3.0
:rex 5.0
:lun 4.0}})

(defn- configure
[{:keys [alphabet vowels pirate-char]}]
(let [alphabet (set (seq (string/upper-case alphabet)))
vowels (set (seq (string/upper-case vowels)))
consonants (set (remove vowels alphabet))
pirates (if (vowels pirate-char)
vowels
consonants)]
{:pirate-char pirate-char
:pirates pirates}))

(reg-event-fx
::foo
(fn []
(let [foo (-> bar baz)]) ; slurp was broken here
(prn foo bar)
{:fx [[:dispatch [:nav :bar]]]}))

(defn component []
(html
[:div {:style ^:foo {:foo :bar} {:background "#FFF"
:color "#000"}}]
[:h1 "title"]))

(defn foo [a b]
(let [x + a b]
(println "sum is" x)))


(defn to-pirate-talk
[text language]
(let [{:keys [pirate-char pirates]} (configure language)]
(apply str (mapcat (fn [c]
(if (pirates (first (string/upper-case c)))
(interpose pirate-char (repeat 2 c))
[c]))
text))))

(defn from-pirate-talk
[text language]
(let [{:keys [pirate-char pirates]} (configure language)
pattern (re-pattern (str "(?i)([" (apply str pirates) "])" pirate-char "\\1"))]
(string/replace text pattern "$1")))

0 comments on commit 71acfcf

Please sign in to comment.