Add templates for exercises batch 3#1773
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
* Enhance underscore method to filter invalid characters and update test file naming convention * Add test case which test underscore for special characters * Use character classes in regex. Also expose description for nested test cases. * Underscore must not create multiple underscores around special characters
| @@ -47,7 +47,7 @@ def additional_json(json) | |||
| def remove_tests(uuid, json) | |||
| json["cases"].each_with_object([]) do |x, acc| | |||
| if x["cases"] | |||
There was a problem hiding this comment.
| if x["cases"] | |
| acc << if x["cases"] |
This, along with ...
There was a problem hiding this comment.
This seems to create error when I do it that way
There was a problem hiding this comment.
Can you show the patch, how you attempted this?
| acc << { "cases" => remove_tests(uuid, x), "description" => x["description"] } | ||
| elsif uuid.include?(x["uuid"]) | ||
| acc << x |
There was a problem hiding this comment.
... with this...
| acc << { "cases" => remove_tests(uuid, x), "description" => x["description"] } | |
| elsif uuid.include?(x["uuid"]) | |
| acc << x | |
| { "cases" => remove_tests(uuid, x), "description" => x["description"] } | |
| elsif uuid.include?(x["uuid"]) | |
| x |
... removes the unconditional work from the conditional branches.
I did not touch the double quotes, though. Unsure if that is already attended to in another place, if we are doing that.
| def test_largest_possible_diamond | ||
| skip | ||
| answer = Diamond.make_diamond('Z') | ||
| string = " A \n"\ |
There was a problem hiding this comment.
Consider using HereDoc for this, rather than consecutive string "trick".
There was a problem hiding this comment.
I tested it out but the problem I find is that for this exercise is trailing spaces important. So what end up happening is that each line is appended with #{' '}. Which in my opinion, looks just weird.
There was a problem hiding this comment.
I agree with that, many people do not notice the white space that is not supposed to be there, they are surely going to miss the whitespace that is supposed to be there.
I have done it with a HereDoc and dynamic format codes, and have done it with append and multiplied spaces, so there are a few ways to address that... but for the tests, it needs to be clear to the reader.
| class CircularBufferTest < Minitest::Test | ||
| <% json["cases"].each do |cases| %> | ||
| def test_<%= underscore(cases["description"]) %> | ||
| <%= skip? %> |
There was a problem hiding this comment.
| <%= skip? %> | |
| <%= skip? %> |
| class DartsTest < Minitest::Test | ||
| <% json["cases"].each do |cases| %> | ||
| def test_<%= underscore(cases["description"]) %> | ||
| <%= skip? %> |
There was a problem hiding this comment.
| <%= skip? %> | |
| <%= skip? %> |
| <% json["cases"].each do |cases| %> | ||
| <% cases["cases"].each do |sub_case| %> | ||
| def test_<%= underscore(sub_case["description"]) %> | ||
| <%= skip? %> |
There was a problem hiding this comment.
| <%= skip? %> | |
| <%= skip? %> |
Includes: