-
-
Notifications
You must be signed in to change notification settings - Fork 671
Description
Hey, with the changes in #2279 the structure of the exercise generators changed. We should update/add a part on how to develop a new generator for an exercise. The two significant changes:
The signature of func Gen changed. It now accepts a map[string]interface{} instead of interface{}. Additionally, it supports recursively searching the canonical-data.json for test cases. All cases are flattened to a list and grouped by the value of property of each test case. The exercise generator has to provide a pointer to a slice of test cases for each property. Example: the canonical-data.json contains test cases with the properties roll and score. Therefore two values have to be provided. The struct used for the properties can (of course) be different if the structure of the input or expected differ.
var j = map[string]interface{}{
"roll": &[]Case{},
"score": &[]Case{},
}
if err := gen.Gen("bowling", j, t); err != nil {
log.Fatal(err)
}
@junedev You can directly assign me and I will add a part to the README. As there is currently no part about adding a new exercise generator, where do you want it to be? here?