Skip to content

Update of README to document how to add exercise generator #2300

@eklatzer

Description

@eklatzer

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?

Metadata

Metadata

Assignees

Labels

x:status/claimedSomeone is working on this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions