-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
zipper: add canonical data #934
zipper: add canonical data #934
Conversation
For history, these are the tracks that had implemented this exercise when I created this branch:
By "common", I mean that the track had the same test cases as every other track. By "augmented", I mean the track had additional test cases. Both "augmented" tracks had the same additional test cases. |
I used the elixir tests as base when I created the erlang version. It was the most logical thing for me, because both languages share the same virtual machine and therefore the same base types. Can you tell which cases are the additional ones? |
Here you go: Categorizing Test CasesCommon
Augmented
Additional
Missed
Work to be doneI didn't realize until now that there was one test case that was included in the "common" set of tracks but not in the "augmented" tracks, and that is "different paths to same zipper". In my current version of
OCaml specifically differentiates between comparing Also, should the "expected" value be encoded with either just a static value OR an initial tree and a sequence of operations? I would love any input. ExampleThe way I see it, explicit type encodings would be the most consistent and useful. The only part about this that I don't totally feel comfortable with is the difference between value based encoding of zippers and operation based encoding of zippers...is the fact that one has a "value" member and one has "initialTree" and "operations" members make them different enough to make it easy to parse? Tree"expected": {
"type": "tree",
"value": {
"value": 1,
"left": null,
"right": null
}
} Int"expected": {
"type": "int",
"value": 3
} ZipperValue based encoding"expected": {
"type": "zipper",
"value": null
} Operations based encoding"expected": {
"type": "zipper",
"initialTree": {
"value": 1,
"left": null,
"right": null
},
"operations": [
{
"operation": "from_tree"
},
{
"operation": "right"
}
]
} |
I'll recuse myself from this one due to lack of familiarity with the exercise, but I'd like to say a big thankyou to you @HarrisonMc555 for tackling this! ⭐ ❤️ ⭐️ |
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.
Nice, you'll have to wait a while for me to write the code, but I'll try to get it done within the next few hours.
exercises/zipper/canonical-data.json
Outdated
"cases": [ | ||
{ | ||
"description": "data is retained", | ||
"property": "property", |
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 understand that there is no real good name for this property, but I hope there is at least a way to sneak a little bit of usefulness in here rather than leaving it as "property".
What of the suggestion of https://github.com/exercism/problem-specifications/blob/master/exercises/circular-buffer/canonical-data.json ("run") or https://github.com/exercism/problem-specifications/blob/master/exercises/react/canonical-data.json ("react")? Are they suitable for use 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.
I meant to decide on a good name but forgot 😅
Do you have any suggestions?
Would we possibly use the property to categorize what kind of test we're running, i.e. function(input) == output
vs. function(input) == function(input)
?
exercises/zipper/canonical-data.json
Outdated
"cases": [ | ||
{ | ||
"description": "Creating a zipper for a binary tree", | ||
"cases": [ |
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.
far as I can tell the only reason for this second level of nesting under cases
is to attach a description to this entire group? I feel like we could do without, and just one level of nesting under cases
. Yes? No?
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.
This...was a mistake. I think I copied another exercise as a starting point and didn't realize this was happening. I just changed 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.
The from_tree
operation only makes sense when given a tree (initialTree
). And it appears that initialTree
is not used anywhere else.
Therefore, I ask:
What about making the initialTree
instead a tree
key to those operations
whose type
are from_tree
?
Alternatively, given that from_tree
is the first operation of of all the lists of operations
:
Leave initialTree
in place but remove from_tree
. All other operations need a zipper
to act on, so it's implicit that that zipper is the zipper resulting from using from_tree
on initialTree
.
exercises/zipper/canonical-data.json
Outdated
} | ||
}, | ||
{ | ||
"description": "set_right with subtree", |
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.
"set_right with subtree" case currently is missing a to_tree
as its last operation. The operations
result in a zipper, but the expected value is a tree.
OK, I managed to finish https://github.com/petertseng/exercism-problem-specifications/blob/verify-zipper/exercises/zipper/verify.rb . I have reported all problems it found. One test is missing a |
|
I'm still trying to decide on what to use for the Would something like |
Looks like an acceptable use of |
https://github.com/petertseng/exercism-problem-specifications/blob/verify-zipper/exercises/zipper/verify.rb has been updated (remove nesting, and use |
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.
given that verify.rb says it is OK, I would be happy with this file as-is. You are free to ask for another look if you would like something done with property
, of course.
Ok I changed the property values. I think I'm good to go. Thanks @petertseng! |
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.
Agreed. This property
separation makes sense. If it's expectedValue
, then you check that you get the value in expected
-> value
. If it's sameResultFromOperations
you check that the zipper is the same as the one from initialTree
and operations
in expected
. Nice work. I am ready for this.
(I advise squashing)
Use explicit type encoding, add another test case Remove unnecessary `cases` nesting Fix bug in test case In the "set_right with subtree" test case, it was missing "to_tree" as the final operation. Remove "from_tree" operations Use property to encode type of test
fa44378
to
e014a5d
Compare
Done, ready to merge. |
Great, thanks. I hope I am not remiss in merging. I figure that if anyone wanted to chime in, they've had 72 hours to do so. |
Closes #593.
Of the five tracks that had already implemented this exercise, five had the exact same test cases, and the other two had the same test cases plus a few more (identical) test cases. I opted to simply list all of the test cases I found in the order they were in.
I ran the test against the
canonical-schema.json
and it said the file is valid.