-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
implement exercise binary-search-tree #412
base: main
Are you sure you want to change the base?
Conversation
Hello @voila! As we have canonical data available in JSON format, could you please open a PR at https://github.com/exercism/erlang-tests-generator, adding the testgenerator and then pushing the generated tests on this branch? I totally understand if you prefer to have the manually implemented tests merged as they are, but then you have to wait up to the end of the month before I can do a proper review (of course I try to as fast as possible). |
Hello @voila! Do you want me to review as is or do you want to give the test-generator a try? |
@@ -0,0 +1,112 @@ | |||
%% Based on canonical data version 1.4.0 | |||
%% https://github.com/exercism/problem-specifications/raw/master/exercises/bob/canonical-data.json | |||
%% This file is automatically generated from the exercises canonical data. |
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.
If the test suite is created manually (ie, there is no test generator), this line is wrong...
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 were even wrong if it were from the generator, as it claims to be generated from bob
s canonical data…
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.
@voila you have been pretty active with your other PR. Please show some activity here as well and answer at least the open question, as well as fixing merge conflicts and obviously wrong comment in the test file. I'm feeling forced to close this in ~2 days otherwise. |
Can you review as is, please ? |
713ec86
to
28905b8
Compare
I'll do first comments through the day, though I'll be on a business trip for a few days then. Not sure if I will be able to continue review before Thursday, so you can take your time for doing the actual changes then. |
There are some tests in the suite like In the canonical data, the property is called You should either align the function name with the canonical data (which is what I would suggest/prefer), or accept any order of items (which would go against what is in the canonical data and thereby make implementing a test generator more difficult, so I don't recommend it). @NobbZ thoughts? |
As we have canonical data, I prefer to be as close as possible, and of course I also expect the corresponding version to be set in I'll do a more in depth review later. |
config.json
Outdated
} | ||
] | ||
} | ||
} |
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.
Please add a newline here!
2 6 | ||
/ \ / \ | ||
1 3 5 7 | ||
## Source |
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.
Sections "Running tests" and "Questions?" are missing, please use confliglet generate
to generate the README.md
.
@@ -0,0 +1,9 @@ | |||
{application, binary_search_tree, | |||
[{description, "exercism.io - binary-search-tree"}, | |||
{vsn, "0.0.1"}, |
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.
Canonical data is at version 1.0.0.
{applications, [kernel, | ||
stdlib]}, | ||
{env, []} | ||
]}. |
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.
Newline please.
insert(_BST, _Value) -> undefined. | ||
|
||
%% convert _BST to a sorted list | ||
to_list(_BST) -> undefined. |
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.
Newline please.
Also this should really be sorted_data/1
as in the problem specification.
T = binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:empty(), | ||
2), | ||
1), |
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.
Could you please unnest function calls and use numbered variables? (see above)
T = binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:empty(), | ||
2), | ||
2), |
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.
Could you please unnest function calls and use numbered variables? (see above)
T = binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:empty(), | ||
2), | ||
3), |
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.
Could you please unnest function calls and use numbered variables? (see above)
T = binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:insert( | ||
binary_search_tree:empty(), | ||
2), | ||
1), | ||
3), | ||
6), | ||
7), | ||
5), |
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.
Could you please unnest function calls and use numbered variables? (see above)
?assertMatch(4, binary_search_tree:value(T)), | ||
?assertMatch(2, binary_search_tree:value(binary_search_tree:left(T))), | ||
?assertMatch(1, binary_search_tree:value( | ||
binary_search_tree:left( | ||
binary_search_tree:left(T)))), | ||
?assertMatch(3, binary_search_tree:value( | ||
binary_search_tree:right( | ||
binary_search_tree:left(T)))), | ||
?assertMatch(6, binary_search_tree:value(binary_search_tree:right(T))), | ||
?assertMatch(5, binary_search_tree:value( | ||
binary_search_tree:left( | ||
binary_search_tree:right(T)))), | ||
?assertMatch(7, binary_search_tree:value( | ||
binary_search_tree:right( | ||
binary_search_tree:right(T)))). |
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 do not really like the look of the multi line matches, but aside from introducing further intermediate variables that destructure the tree again, I have no idea how to clean that up…
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.
Sorry, I misclicked! Please consider all comments as request to change!
Looks good to me, @juhlig can you please take another look and merge, I am on mobile only and am a bit frightened that I've overlooked something. |
Sorry, I missed you mentioning my name ;) I think this one is good to go, as far as I can see. |
No description provided.