-
-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
list of tracks with test generators #1411
Comments
I was pushed to this list today and wanted to add erlang to the list.
In the good case, there is not much to add, mostly mapping the named arguments from the JSON to an idiomatic order of positional arguments in the function call and spraying syntax generating functions around. This is at least for the simpler exercises which do not require state keeping. Of course we have to generate additional boilerplating code, if the test cases actually involve a sequence of calls of which we need to prepare state before and compare state after that. Also sometimes when the test deals with complex data, we need to map that to more idiomatic ways of data keeping. Erlang doesn't have objects, and the use of maps is not idiomatic for most of those types, such that we have to translate them into something that is called a "record" in erlang speak, basically a tuple with syntactic sugar such that we can use some syntax to refer to fields by names.
We manually map them into an idiomatic positional argument schema, as outlined above.
I have not yet seen those. |
Following up on @NobbZ's comment, Dart also has a test generator. It's in the bin/create_exercise.dart file.
The test generator does not meet all of our needs. So sometimes it may not accurately define what the expected value's type should be. In those cases it just sees an empty list and doesn't know if that's suppose to be a List of objects, strings, or anything. But that's just changing the type in a handful of cases.
We generally take the first input and make it the first parameter.
Unsure, as mentioned above specifying the type when the value is an empty collection (list, map, set, etc) could be useful, but types differ from one language to the other and I think that could make it more confusing for the maintainers of the test generators. |
Need to add https://github.com/exercism/python/blob/master/bin/generate_tests.py to this list The discussions repo got reopened so now there are two editable versions of this issue, but I'll decide that this one will be the canonical one going forward since I already spent time on it after discussions repo was closed. |
Added the Python generator + details. |
Well, since the repo of exercism/discussions#155 got closed, it's not possible to edit the issue text there anymore. It's not clear that there's a better home for this issue. I don't want to put it in https://github.com/orgs/exercism/teams/track-maintainers because then people not in the org can't see it, and I don't think this information should be withheld from people outside the org.
These are anything that use the canonical-data.json file from problem-specification and generate a test suite to be delivered to students of a given track.
If your track has these, I would be interested to hear about it.
I hope this can help tracks that don't have generators evaluate whether to have them, and allow tracks that already have generators to learn from each other.
Questions I would like to ask:
input
key, for exercises with more than one input, it's not certain what order they should go in. How do you deal with this?property
key? (In some JSON parsers in statically-typed languages, you must declare the types of all key/value pairs in a JSON object before you can parse it, but sometimes the key/value pairs present depend onproperty
)property
is read, then parse into different structs depending on whatproperty
is (clock: restore type-safety for different types of cases go#677).This issue will be closed immediately, because there's no need to have it take up space in the list of open issues (there's no call to action). Of course, even after it is closed, please feel free to comment with any additional answers.
If as a result there are any proposed changes to the schema, an appropriate issue can be created for that.
To give us a head start, here is what I know of some languages' generators.
Please forgive me for being greedy and filling in information for tracks that I am unfamiliar with.
Please correct these or add any additional tracks I missed.
In alphabetical order:
Bash
C#
property
: https://github.com/exercism/csharp/blob/master/generators/Exercises/Generators/Allergies.csIDictionary<string, dynamic>
, supporting values of any type.CFML
generateInput
for handling ofinput
.Common Lisp
Dart
https://github.com/exercism/dart/blob/master/bin/create_exercise.dart
Erlang
https://github.com/exercism/erlang/tree/master/testgen - see https://github.com/exercism/erlang/tree/master/testgen/src for per-exercise configuration.
Factor
Go
.meta/gen.go
in each exercise directory defines the structure that the file is expected to have.property
first in order to know how to parse the other key/value pairs.JavaScript
OCaml
Perl 6
Pharo (Smalltalk)
Python
Ruby
bin
directory: https://github.com/exercism/ruby/blob/master/bin/generatelib/generator
providing common-case parsing: https://github.com/exercism/ruby/tree/master/lib/generator.meta/generator
in each exercise directory containing a*_case.rb
file. If necessary a customtest_template.erb
can be provided. Most tests use a common default templateRust
Scala
Vimscript
The text was updated successfully, but these errors were encountered: