Skip to content

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

Open

Description

@rneilsen

The current test suite for the word-count exercise 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.

Activity

  1. ErikSchierboom commented on Mar 4, 2022

    @ErikSchierboom
    Member

    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.

    I like the suggestion. My only remark would be that it would have to be a new test case as test cases are immutable. We can discuss whether or not we want the new test case to supersede (reimplements in problem-specifications parlance) the current test case (I think we might).

  2. rneilsen commented on Mar 7, 2022

    @rneilsen
    ContributorAuthor

    Dang it, there's always a catch. Is there a documented procedure for creating a new test to replace an old one? I had a look but couldn't find anything - this section of CONTRIBUTING.md just says to submit a PR for the JSON file, but it doesn't give any details.

    I could probably write up a test, give it a new uuid, and submit a PR with the new test where the old one was, but I don't want to waste anyone else's time if there's a proper procedure to go through that I should be following.

  3. ErikSchierboom commented on Mar 7, 2022

    @ErikSchierboom
    Member

    @rneilsen There is a section in the README that explains how to do this: https://github.com/exercism/problem-specifications#changing-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions