Skip to content

Add wordy - #495

Merged
keiravillekode merged 3 commits into
exercism:mainfrom
keiravillekode:wordy
Sep 30, 2025
Merged

keiravillekode merged 3 commits into
exercism:mainfrom
keiravillekode:wordy

Conversation

@keiravillekode

Copy link
Copy Markdown
Contributor

No description provided.

@keiravillekode
keiravillekode marked this pull request as ready for review September 29, 2025 10:16

## Zig-specific instructions

If an error occurs, return `null`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not return an exception that (hopefully) provides a directive message on how to avoid raising that exception instead? This is a practice exercise, and as a library should not swallow exceptions.

Comment thread exercises/practice/wordy/test_wordy.zig Outdated
}

test "Non math question" {
try testing.expectError(ArgumentError.UnknownOperation, answer("Who is the President of the United States?"));

@kotp kotp Sep 30, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this unknown operation instead of something like improper question? (Naming is hard, unsure what to name the error, but this seems "wrong" as the operation may be wrong, but the operands also seem wrong, but really because it is the wrong kind of question.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The canonical data has "unknown operation" and "syntax error". I added division by zero as a third error type.

I have now renamed UnknownOperation to UnsupportedQuestion, so it fits both

- Unsupported operations ("What is 52 cubed?")
- Non-math questions ("Who is the President of the United States")

@keiravillekode
keiravillekode merged commit 32aaed3 into exercism:main Sep 30, 2025
7 checks passed
@keiravillekode
keiravillekode deleted the wordy branch September 30, 2025 01:16
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