Skip to content

Replace specific error message check with error code check #247

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
merged 2 commits into from
Apr 3, 2025

Conversation

TheAhmir
Copy link
Contributor

The challenge does not specify that a specific error message should be thrown and requiring one might unintentionally hint at the solution. This change updates the test to check for an error code instead, allowing users more flexibility in how they implement error handling while still ensuring correctness.

Copy link

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.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@@ -32,23 +32,23 @@ fn test_error_0() {
if res := grains_on_square(0) {
assert false, 'invalid square number should return error'
} else {
assert err.msg() == 'square must be between 1 and 64'
assert err.code() == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests for collatz-conjecture, connect, robot-name, simple-linked-list, wordy have assert true

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 either could work and have made the appropriate changes so that this test uses the same approach.

@keiravillekode
Copy link
Contributor

The challenge does not specify that a specific error message should be thrown

Exercism uses a TDD approach, where tests are considered to provide the specification.

The cross-language canonical tests do specify error messages. Each track can choose between checking the specific error message, or not.

Currently, I think the following other tracks check the error message for this exercise.

awk
cairo
coffeescript
dart
elixir
erlang
euphoria
fsharp
java
javascript
perl5
pharo-smalltalk
powershell
pyret
python
raku
red
scheme
sml
tcl
uiua
vimscript
wren
yamlscript

Should we be checking the error message for this particular exercise? I don't mind either way.

@keiravillekode keiravillekode merged commit 4553aac into exercism:main Apr 3, 2025
4 checks passed
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.

2 participants