exercism / exercism/problem-specifications

Word Count: Apostrophe bug that users' submissions could plausibly include, that current tests won't detect

Open
#1,977 3 comments 3 reactions 0 assignees View on GitHub
new test case idea
Dominant language
Ruby
Stars
358
Forks
563
Avg merge
18h 41m
Merged PRs (30d)
2

Description

The current test suite for the [word-count exercise](https://github.com/exercism/problem-specifications/tree/main/exercises/word-count) tests for words containing apostrophes, but the only examples used in the test cases themselves are words that only have one letter after the apostrophe (specifically, "can't" and "don't").

As a consequence, if a user implements code that doesn't correctly handle words with more than one letter after the apostrophe (like I did, with a regex that looked like `/([a-z]+'[a-z]| ... )/`) the tests will not identify the problem. There aren't a lot of English examples where this might cause miscounts - the only one I could think of was "m'lord"/"m'lady", other than fantasy stuff like "bat'leth"/"bat'leths" - but the thought process that got me there seems pretty plausible as a mistake others might make (I looked at the test cases, saw "don't" and "can't", and thought of "I'm" and "he's", and _didn't_ think of "you're" and "they'll"), so it seems like something worth checking for in the test cases.

Seems like a pretty easy fix to update the "with apostrophes" test case to include a word like "you're" or whatever, I'm happy to submit a PR if it's agreed as worthwhile.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.