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

implement exercise binary-search-tree #412

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

voila
Copy link
Contributor

@voila voila commented Oct 2, 2019

No description provided.

@voila
Copy link
Contributor Author

voila commented Oct 2, 2019

#191

@NobbZ
Copy link
Member

NobbZ commented Oct 5, 2019

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

@NobbZ
Copy link
Member

NobbZ commented Oct 8, 2019

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.
Copy link
Contributor

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

Copy link
Member

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 bobs canonical data…

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.

Could you also please rebase on master or cherry pick d8c83e7 and 7210cc1 into your PR, such that the tests are run against your PR?

@NobbZ
Copy link
Member

NobbZ commented Oct 10, 2019

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

@voila
Copy link
Contributor Author

voila commented Oct 10, 2019

Do you want me to review as is or do you want to give the test-generator a try?

Can you review as is, please ?

@NobbZ
Copy link
Member

NobbZ commented Oct 11, 2019

Can you review as is, please ?

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.

@juhlig
Copy link
Contributor

juhlig commented Oct 11, 2019

There are some tests in the suite like ..._can_sort_..., based on this set of tests in the canonical data.

In the canonical data, the property is called sortedData, but your implementation uses to_list. I think this may be misleading to students, as nothing really tells them that the result should be a sorted list. Your tests however, fix the order of the elements in the expected result.

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?

@NobbZ
Copy link
Member

NobbZ commented Oct 11, 2019

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 *.app.src and as a comment in the test suite.

I'll do a more in depth review later.

@NobbZ NobbZ mentioned this pull request Oct 11, 2019
config.json Outdated
}
]
}
}
Copy link
Member

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

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

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, []}
]}.
Copy link
Member

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.
Copy link
Member

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.

Comment on lines 71 to 75
T = binary_search_tree:insert(
binary_search_tree:insert(
binary_search_tree:empty(),
2),
1),
Copy link
Member

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)

Comment on lines 79 to 83
T = binary_search_tree:insert(
binary_search_tree:insert(
binary_search_tree:empty(),
2),
2),
Copy link
Member

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)

Comment on lines 87 to 91
T = binary_search_tree:insert(
binary_search_tree:insert(
binary_search_tree:empty(),
2),
3),
Copy link
Member

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)

Comment on lines 95 to 107
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),
Copy link
Member

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)

Comment on lines 50 to 64
?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)))).
Copy link
Member

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…

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.

Sorry, I misclicked! Please consider all comments as request to change!

@NobbZ
Copy link
Member

NobbZ commented Oct 14, 2019

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.

@juhlig
Copy link
Contributor

juhlig commented Nov 1, 2019

Sorry, I missed you mentioning my name ;) I think this one is good to go, as far as I can see.

Base automatically changed from master to main January 28, 2021 19:17
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.

None yet

3 participants