File tree 9 files changed +20
-23
lines changed
difference-of-squares/.meta
largest-series-product/.meta
9 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ There are two ways in which you can transform test cases:
42
42
To update individual test cases, define the following function:
43
43
44
44
``` clojure
45
- (defn- transform -test-case
45
+ (defn update -test-case
46
46
" Update a test case"
47
47
[test-case]
48
48
; ; function body
@@ -56,7 +56,7 @@ This example removes all but the last element of the `:path` value (shortening t
56
56
``` clojure
57
57
(ns difference-of-squares-generator )
58
58
59
- (defn- transform -test-case [test-case]
59
+ (defn update -test-case [test-case]
60
60
(update test-case :path #(take-last 1 %)))
61
61
```
62
62
@@ -65,15 +65,15 @@ This example removes all but the last element of the `:path` value (shortening t
65
65
To update individual test cases, define the following function:
66
66
67
67
``` clojure
68
- (defn- transform -test-cases
68
+ (defn add-remove -test-cases
69
69
" Add/remove test case(s)"
70
70
[test-cases]
71
71
; ; function body
72
72
)
73
73
```
74
74
75
75
``` exercism/note
76
- If you define _both_ functions, `transform- test-cases` is called first and `transform -test-case` second.
76
+ If you define _both_ functions, `add-remove- test-cases` is called first and `update -test-case` second.
77
77
```
78
78
79
79
### Step 4: render the test cases
Original file line number Diff line number Diff line change 1
1
(ns difference-of-squares-generator )
2
2
3
- (defn- update-path [path]
4
- (take-last 1 path))
5
-
6
- (defn transform [test-cases]
7
- (map #(update % :path update-path) test-cases))
3
+ (defn update-test-case [test-case]
4
+ (update test-case :path #(take-last 1 %)))
Original file line number Diff line number Diff line change 1
1
(ns high-scores-generator )
2
2
3
- (defn- transform -test-case [test-case]
3
+ (defn update -test-case [test-case]
4
4
(-> test-case
5
5
(update-in [:input :scores ] #(apply list %))
6
6
(update-in [:expected ] #(if (vector? %) (apply list %) %))))
Original file line number Diff line number Diff line change 1
1
(ns largest-series-product-generator )
2
2
3
- (defn transform -test-case [test-case]
3
+ (defn update -test-case [test-case]
4
4
(if-let [error (get-in test-case [:expected :error ])]
5
5
(assoc-in test-case [:expected :error ] (str " ^" error " $" ))
6
6
test-case))
Original file line number Diff line number Diff line change 8
8
(defn- transform-input [input]
9
9
(update input :matrix #(if (empty? (flatten %)) [] %)))
10
10
11
- (defn- transform -test-case [test-case]
11
+ (defn update -test-case [test-case]
12
12
(-> test-case
13
13
(update :input transform-input)
14
14
(update :expected transform-expected)))
Original file line number Diff line number Diff line change 1
1
(ns sum-of-multiples-generator )
2
2
3
- (defn- transform -test-case [test-case]
3
+ (defn update -test-case [test-case]
4
4
(update-in test-case [:input :factors ] #(apply list %)))
Original file line number Diff line number Diff line change 5
5
" ^syntax error$"
6
6
(str " ^" error " $" )))
7
7
8
- (defn transform -test-case [test-case]
8
+ (defn update -test-case [test-case]
9
9
(if-let [error (get-in test-case [:expected :error ])]
10
10
(assoc-in test-case [:expected :error ] (normalize-error test-case error))
11
11
test-case))
Original file line number Diff line number Diff line change 2
2
(:require [hbs.helper :refer [safe-str]]
3
3
[clojure.string :as str]))
4
4
5
- (defn transform -test-case [test-case]
5
+ (defn update -test-case [test-case]
6
6
(update test-case :expected #(safe-str (str/lower-case (keyword %)))))
Original file line number Diff line number Diff line change 61
61
:error (get-in node [:expected :error ]))
62
62
(dissoc :reimplements :comments :scenarios )))
63
63
64
- (defn- transform-all -test-cases [generator-ns test-cases]
65
- (if-let [transform- fn (ns-resolve generator-ns (symbol " transform " ))]
66
- (transform -fn test-cases)
64
+ (defn- add-remove -test-cases [generator-ns test-cases]
65
+ (if-let [add-remove-test-cases- fn (ns-resolve generator-ns (symbol " add-remove-test-cases " ))]
66
+ (add-remove-test-cases -fn test-cases)
67
67
test-cases))
68
68
69
- (defn- transform-individual -test-cases [generator-ns test-cases]
70
- (if-let [transform -test-case-fn (ns-resolve generator-ns (symbol " transform -test-case" ))]
71
- (mapv transform -test-case-fn test-cases)
69
+ (defn- update -test-cases [generator-ns test-cases]
70
+ (if-let [update -test-case-fn (ns-resolve generator-ns (symbol " update -test-case" ))]
71
+ (mapv update -test-case-fn test-cases)
72
72
test-cases))
73
73
74
74
(defn- transform [slug test-cases]
77
77
(let [generator-ns (symbol (str slug " -generator" ))]
78
78
(load-file (str transform-file))
79
79
(->> test-cases
80
- (transform-all -test-cases generator-ns)
81
- (transform-individual -test-cases generator-ns)))
80
+ (add-remove -test-cases generator-ns)
81
+ (update -test-cases generator-ns)))
82
82
test-cases)))
83
83
84
84
(defn- test-cases->data [slug test-cases]
You can’t perform that action at this time.
0 commit comments