@@ -31,22 +31,50 @@ The test generator will remove any test cases that are marked as excluded (`incl
31
31
Some exercises might need some tweaks before rendering the data.
32
32
For example, you might want to make the description less verbose.
33
33
34
- To tweak the test cases, define a ` .meta/generator.clj ` file with a ` <slug>-generator ` namespace .
35
- Then, define a function called ` transform ` that takes a single argument — the parsed test cases — and returns the transformed test cases.
34
+ To tweak test cases, define a ` .meta/generator.clj ` file with a ` <slug>-generator ` namespace.
35
+ There are two ways in which you can transform test cases:
36
36
37
- Example:
37
+ - Update test case(s)
38
+ - Add/remove test case(s)
39
+
40
+ #### Update test case(s)
41
+
42
+ To update individual test cases, define the following function:
43
+
44
+ ``` clojure
45
+ (defn- transform-test-case
46
+ " Update a test case"
47
+ [test-case]
48
+ ; ; function body
49
+ )
50
+ ```
51
+
52
+ ##### Example
53
+
54
+ This example removes all but the last element of the ` :path ` value (shortening the description):
38
55
39
56
``` clojure
40
57
(ns difference-of-squares-generator )
41
58
42
- (defn- update-path [path]
43
- (take-last 1 path))
59
+ (defn- transform-test-case [test-case]
60
+ (update test-case :path #(take-last 1 %)))
61
+ ```
62
+
63
+ #### Add or remove test case(s)
44
64
45
- (defn transform [test-cases]
46
- (map #(update % :path update-path) test-cases))
65
+ To update individual test cases, define the following function:
66
+
67
+ ``` clojure
68
+ (defn- transform-test-cases
69
+ " Add/remove test case(s)"
70
+ [test-cases]
71
+ ; ; function body
72
+ )
47
73
```
48
74
49
- This step is entirely optional.
75
+ ``` exercism/note
76
+ If you define _both_ functions, `transform-test-cases` is called first and `transform-test-case` second.
77
+ ```
50
78
51
79
### Step 4: render the test cases
52
80
0 commit comments