Skip to content
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

WIP - reserve #187 - pangram #223

Merged
merged 2 commits into from
Nov 9, 2017
Merged

Conversation

AtelesPaniscus
Copy link
Contributor

I've not done this yet ... I'm interested in trying out the 'generator' to see if that helps with this slug.

So let's estimate a solution for a week from now.

@NobbZ
Copy link
Member

NobbZ commented Nov 2, 2017

Even though I have less time to spare as I hopen in #217 when I promised a small write up until sunday, I do hope to finish it anyway ;)

At least I will be here to answer your questions, even though it might take some time ;)

@AtelesPaniscus
Copy link
Contributor Author

Please do not feel under extra pressure on my account. I though using the generator might help you (as much as i might help me). I can do it the hard way if you prefer.

Is there are thread on these generators I could read somewhere ? I think I may have got the wrong idea as to what the generator is intended to do (other than reduce tedium, of course).

Are you writing a generator in Erlang ? My first assumption was that these would be in Go as I read somewhere that Go is the Exercism project language. So then I assumed you would fork some reference implementation and make necessary and sufficient changes, many of which might be configuration changes rather than code changes.

@NobbZ
Copy link
Member

NobbZ commented Nov 2, 2017

Please do not feel under extra pressure on my account.

I do not ;) But I really need to write something as long as I remember what I did ;)

Is there are thread on these generators I could read somewhere ?

The word is said every now and then. But each track is free to choose if they use one at all or how they implement them.

Are you writing a generator in Erlang ?

Of course… It is the most straightforward thing to do… Erlang has a module to create some abstract code representation (not directly an AST) via erl_syntax and also it has pretty printer for this abstract representation in erl_prettyp, I do use those 2 to generate a module skeleton in src/foo.erl and a test file in test/foo_test.erl.

The generator itself lives in testgen/ folder of the repository, it reads canonical data from canonical-data (which is a git submodule which I will update about once a month after things have settled a bit, probably starting january).

Basically a generator for exercise ex has to get implemented in the module tgen_ex, implementing the behaviour tgen.

  • Module:available/0: should return true. This is (currently) necessary to discover available generators, I do hope to get rid of it sooner or later
  • Module:version/0: Should return an integer which simply represents the tests version. Its used to generate a pre-implemented test_version/0 in the stub and the accompanying version test.
  • Module:generate_test/1: Shall return a tuple {ok, Test, [{Name, Arguments}]} when Test :: erl_syntax:tree() | [erl_syntax:tree()], Name :: string(), Arguments :: [string()]. Test is one or more tests in abstract format, Name the name of all functions of the module to implement that are called during the generated test and Arguments is a list of strings which represents patterns for the function stub. I prefer them to be simply names of the arguments.

Copy link
Member

@NobbZ NobbZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I really like this!

-include("exercism.hrl").


% test cases adapted from `x-common//canonical-data.json` @ version: 1.3.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea! Makes it easier to check if there are upstream changes!

@NobbZ NobbZ merged commit f017299 into exercism:master Nov 9, 2017
@NobbZ NobbZ mentioned this pull request Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants