File tree Expand file tree Collapse file tree 5 files changed +15
-12
lines changed
difference-of-squares/.meta Expand file tree Collapse file tree 5 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 11(ns atbash-cipher-generator )
22
33(defn update-test-case [test-case]
4- (-> test-case
5- (update :path #(take-last 1 %))))
4+ (assoc test-case :context (:description test-case)))
Original file line number Diff line number Diff line change 11(ns difference-of-squares-generator )
22
33(defn update-test-case [test-case]
4- (update test-case :path #( take-last 1 % )))
4+ (assoc test-case :context ( :description test-case )))
Original file line number Diff line number Diff line change 11(ns dnd-character-generator
2- (:require [hbs.helper :refer [safe-str]]))
2+ (:require [hbs.helper :refer [safe-str]]
3+ [clojure.string :as str]))
34
45(def random-abilities [:strength :dexterity :charisma :wisdom :intelligence :constitution ])
56
67(defn- expand-character-test-case [test-case]
78 (map
89 (fn [ability]
910 (-> test-case
10- (update :path #( conj % (name ability)))
11+ (assoc :context ( str/join " ▶ " ( conj ( :path test-case) (name ability) )))
1112 (assoc :ability (safe-str (str ability))))) random-abilities))
1213
1314(defn- expand-test-case [test-case]
1415 (case (:property test-case)
1516 " character" (expand-character-test-case test-case)
16- " modifier" [(update test-case :path #( take-last 1 % ))]
17+ " modifier" [(assoc test-case :context ( :description test-case ))]
1718 [test-case]))
1819
1920(defn add-remove-test-cases [test-cases]
Original file line number Diff line number Diff line change 88(defn update-test-case [test-case]
99 (-> test-case
1010 (update :expected update-expected)
11- (update :path #( take-last 1 % ))))
11+ (assoc :context ( :description test-case ))))
Original file line number Diff line number Diff line change 3636 (map #(-> % (.getParentFile ) (.getParentFile ) (.getName )))
3737 (into (sorted-set ))))
3838
39- (defn- test-case->data [idx node]
39+ (defn- pre-process-test-case [node]
40+ (assoc node :context (str/join " ▶ " (:path node))))
41+
42+ (defn- post-process-test-case [idx node]
4043 (-> node
4144 (assoc :idx (inc idx)
42- :context (str/join " ▶ " (:path node))
4345 :error (get-in node [:expected :error ]))
44- (dissoc :reimplements :comments :scenarios )))
46+ (dissoc :reimplements :comments )))
4547
4648(defn- add-remove-test-cases [generator-ns test-cases]
4749 (if-let [add-remove-test-cases-fn (ns-resolve generator-ns (symbol " add-remove-test-cases" ))]
6466 test-cases)))
6567
6668(defn- test-cases->data [slug test-cases]
67- (let [transformed (transform slug test-cases)
69+ (let [augmented (map pre-process-test-case test-cases)
70+ transformed (transform slug augmented)
6871 grouped (group-by :property transformed)
69- data (update-vals grouped #(map-indexed test-case->data %))]
72+ data (update-vals grouped #(map-indexed post-process- test-case %))]
7073 {:test_cases data}))
7174
7275(defn template [slug]
You can’t perform that action at this time.
0 commit comments