Skip to content

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

Merged

Conversation

holdenout
Copy link
Contributor

Closes #565

Notes:

  • The default students indicated in the README are assumed, and alternate students are indicated as input when appropriate.
  • While some tracks tested all 12 students for the full garden, it only seemed necessary to include a few tests here.

Copy link
Member

@petertseng petertseng left a 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"],
Copy link
Member

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",
Copy link
Member

@petertseng petertseng May 2, 2017

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",
Copy link
Member

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",
Copy link
Member

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

Copy link
Contributor Author

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",
Copy link
Member

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)

Copy link
Contributor Author

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",
Copy link
Member

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",
Copy link
Member

Choose a reason for hiding this comment

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

here too - three students.

@holdenout
Copy link
Contributor Author

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?

@hilary
Copy link
Contributor

hilary commented May 2, 2017

@holdenout yes, please push the new commits, then squash away 😄

Copy link
Member

@petertseng petertseng left a 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."
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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",
Copy link
Member

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.

Copy link
Member

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 :)

Copy link
Contributor Author

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".

@ErikSchierboom
Copy link
Member

It appears that there now is a commit in this PR that modified the rail-fence-cipher canonical data. Is that correct?

@petertseng
Copy link
Member

Please don't include my commit.

@holdenout
Copy link
Contributor Author

Oops, I'm relatively inexperienced with git and did not mean to do that. I'll fix it up.

@petertseng
Copy link
Member

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)

@holdenout holdenout force-pushed the canonical-kindergarten-garden branch from 67644e9 to 34276c0 Compare May 5, 2017 09:49
Copy link
Member

@petertseng petertseng left a 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?

@Insti
Copy link
Contributor

Insti commented May 6, 2017

I have no objections to this being merged. 👍
(but have not reviewed it closely enough to hit the approve button.)

@petertseng
Copy link
Member

petertseng commented May 6, 2017

"implementations": [
  {
    "track_id": "csharp",
    "url": "https://github.com/exercism/xcsharp/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "clojure",
    "url": "https://github.com/exercism/xclojure/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "ecmascript",
    "url": "https://github.com/exercism/xecmascript/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "elixir",
    "url": "https://github.com/exercism/xelixir/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "fsharp",
    "url": "https://github.com/exercism/xfsharp/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "go",
    "url": "https://github.com/exercism/xgo/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "haskell",
    "url": "https://github.com/exercism/xhaskell/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "javascript",
    "url": "https://github.com/exercism/xjavascript/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "lua",
    "url": "https://github.com/exercism/xlua/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "perl5",
    "url": "https://github.com/exercism/xperl5/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "python",
    "url": "https://github.com/exercism/xpython/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "ruby",
    "url": "https://github.com/exercism/xruby/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "scala",
    "url": "https://github.com/exercism/xscala/tree/master/exercises/kindergarten-garden"
  },
  {
    "track_id": "swift",
    "url": "https://github.com/exercism/xswift/tree/master/exercises/kindergarten-garden"
  }
]

@petertseng
Copy link
Member

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.

@holdenout
Copy link
Contributor Author

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.

@petertseng
Copy link
Member

petertseng commented May 8, 2017

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!

@petertseng petertseng merged commit 03d588d into exercism:master May 8, 2017
petertseng added a commit to exercism/haskell that referenced this pull request May 8, 2017
…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
@kytrinyx
Copy link
Member

kytrinyx commented May 8, 2017

🎉 thanks @holdenout!

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.

6 participants