-
-
Notifications
You must be signed in to change notification settings - Fork 553
kindergarten-garden: add canonical data #770
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
kindergarten-garden: add canonical data #770
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
"description": "test Patricia's garden", | ||
"property": "plants", | ||
"students": ["Samantha", "Patricia", "Xander", "Roger"], | ||
"diagram": ["VCRRGVRG\nRVGCCGCV"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array -> string? None of the diagram
arrays have more than one element
{ | ||
"description": "test Bob's garden", | ||
"diagram": "VVCCGG\nVVCCGG", | ||
"property": "plants", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyone have a desire for consistent ordering? notice that property comes after diagram here, but before diagram in above cases
(has since been resolved)
"expected": ["grass", "clover", "clover", "grass"] | ||
}, | ||
{ | ||
"description": "test Larry's garden", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be useful to say in the description that Larry is the last student with plants in this garden (is that right? I am guessing)
] | ||
}, | ||
{ | ||
"description": "disordered tests", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unclear on what is disordered - I think "tests of disordered X" would help readers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is supposed to be the names. I'll update that description. The README doesn't specify this, but it seems that that the students gardens are in alphabetical order by name. Is that something that should be added to the README?
"description": "partial garden tests", | ||
"cases": [ | ||
{ | ||
"description": "test Alice's garden", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's just me, but it seemed more important to me to say that this tests a garden with only a single student, rather than stating the name of the student (already inferrable from "student":
key)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That definitely makes sense so it would explain the reasoning behind the test rather than just what it's doing. I'll fix that along with the similar ones below.
"expected": ["violets", "clover", "radishes", "clover"] | ||
}, | ||
{ | ||
"description": "test Bob's garden", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the same vein, it seems more valuable to me to say that now we're testing a garden with a second student
"expected": ["clover", "grass", "radishes", "clover"] | ||
}, | ||
{ | ||
"description": "test Bob and Charlie's garden", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too - three students.
Thanks for the feedback! I'll get right on those. Should I just push the new commits, and squash them when it's all approved? |
@holdenout yes, please push the new commits, then squash away 😄 |
5c3af76
to
fb9d6e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified with:
require 'json'
require_relative '../../verify'
DEFAULT_NAMES = %w(Alice Bob Charlie David Eve Fred Ginny Harriet Ileana Joseph Kincaid Larry).map(&:freeze).freeze
PLANTS = {
?C => 'clover',
?G => 'grass',
?R => 'radishes',
?V => 'violets',
}.freeze
PLANTS_PER_ROW_PER_KID = 2
json = JSON.parse(File.read(File.join(__dir__, 'canonical-data.json')))
cases = json['cases'].flat_map { |c| c['cases'].flat_map { |cc| cc['cases'] || cc } }
verify(cases, property: 'plants') { |c|
kid_names = (c['students'] || DEFAULT_NAMES).sort
rows = c['diagram'].split.map { |row|
row.each_char.each_slice(PLANTS_PER_ROW_PER_KID)
}
plant_groups = rows[0].zip(*rows[1..-1]).map { |group_rows|
group_rows.flatten.map(&PLANTS).freeze
}
plant_groups[kid_names.index(c['student'])]
}
All passed.
Okay, I think I have just a few small things to note now.
"Garden can be created with just a diagram or a diagram and students.", | ||
"Students' gardens are assigned in alphabetical order.", | ||
"The default students are:", | ||
" Alice, Bob, Charlie, David, Eve, Fred, Ginny, Harriet, Ileana, Joseph, Kincaid, and Larry." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this information is also in the https://github.com/exercism/x-common/blob/master/exercises/kindergarten-garden/description.md, any chance of it falling out date? I try to reduce duplication when possible. I am thinking it doesn't need to be put here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that does make sense. Were you referring to all 4 lines? I included the bit about the default students because I thought it might help clarify some of the issues brought up in #659. Would that still be considered unnecessary though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I was meaning to refer only to the list of the twelve default students...
But now that you bring it up, yes, "Students' gardens are assigned in alphabetical order." is also mentioned in the description! So I would also think that should be removed.
If there is to be clarification for #659, I would suggest it go in the description since the README is where students will likely go to look for instructions for how to do this exercise. It wouldn't be visible to students if it were placed in this canonical-data.json file. Since this PR is just dealing with the canonical data, we don't need to deal with this now, unless you would like to add another commit to this PR or a separate PR.
"description": "partial garden tests", | ||
"cases": [ | ||
{ | ||
"description": "test garden with single student", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point, all these descriptions begin with "test". I think the word could get removed from all of them, since it doesn't seem to be adding information to say that this is a test (should be self-evidence from its presence in this file, right?)
Sorry, I don't have a place where this "principle" (if it can even be called one) is documented, nor do I know for sure that all other files in the repo don't have "test" in their description (well, that can be found with grep...). So let me know what you think about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. The "test" prefix doesn't add anything as the description is only valid in the context of a test case :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to also remove trailing 'test's? For example, "partial garden" instead of "partial garden tests".
It appears that there now is a commit in this PR that modified the rail-fence-cipher canonical data. Is that correct? |
Please don't include my commit. |
Oops, I'm relatively inexperienced with git and did not mean to do that. I'll fix it up. |
Don't worry, we've all been there I'm sure. Feel free to yell if you need help (what I would personally do is to use an interactive rebase to remove it, but there could be various different ways to accomplish the goal so don't limit yourself to only what I say) |
67644e9
to
34276c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seems good to me. 48 hours for anyone else?
I have no objections to this being merged. 👍 |
|
C#/F# have search for a kid not in the class ("Potter" for four plants). JS/ES6/Ruby create multiple gardens with the same kids then check that the right plants are assigned to the right kids after both are created, ensuring that the multiple gardens don't improperly overwrite each other's data. (Perl has cases with the same data but doesn't create two gardens simultaneously) Lua checks that the kids and plants are case-insensitive. Go has a bunch of errors cases (unequal number of rows, missing newlines, odd number of columns, duplicate kid name, something other than RGCV in the diagram, kid not in the class like C#/F#) If anyone really wants these cases in the JSON, speak up soon. I'm not considering them blockers but they are useful to note down. |
I hate to block my own PR, but I'd be willing to either add some of that in (either as tests or just in the comments). I suppose another option could be merging and then raising an issue for those little bits. Not sure what would work best for the exercism workflow. Or it could be left as is. |
Well these are good questions. Depending on what the exercise is trying to teach (fun fact! it seems from exercism/discussions#78 that we don't even know!) those tests may or may not be appropriate. The error tests and case insensitivity test make sense and could be encoded in JSON, but don't appear to be strictly necessary. The test with two simultaneous gardens would at least need a comment to go along with it. I'm happy to stick with these as a first pass. Though note that I only did this exercise in one track so I am not the most knowledgeable about all the approaches! If in the future some track creates a test generator and finds that it deletes a test that track thought was essential, at that time we may see a proposal to add those tests to x-common. Thanks for your work! |
…nts (#525) Descriptions are clearer as to the significance of the garden size, or the fact that the given student list is non-alphabetical. The tests of the middle children in the full garden are elided. The canonical data file was added in exercism/problem-specifications#770
🎉 thanks @holdenout! |
Closes #565
Notes: