Skip to content
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

pact_consumer term! example doesn't match prose, and appears to contain accidental copy-pasta #424

Closed
mjpieters opened this issue May 20, 2024 · 0 comments · Fixed by #425

Comments

@mjpieters
Copy link
Contributor

mjpieters commented May 20, 2024

This is the example given in the docstring for the term!() macro:

/// // Match a string consisting of numbers and lower case letters, and
/// // generate `"10a"`.$crate::patterns::
/// "id_string": term!("^[0-9a-z]$", "10a")

There are two issues here:

  • The regex given in the example will only match a single lowercase letter or number, because it lacks a quantifier for the [0-9a-z] group. It should have a + quantifier, matching at least one digit or lower-case letter:

    ^[0-9a-z]+$
    

    Without the + the example given won't match.

  • The comment text ends in $crate::patterns::, which looks like a copy-paste error to me; it is the prefix used in most of the macro definitions and doesn't fit in the comment text.

The same two issues apply to the matching_regex!() macro defined below this.

Side note: Could terms be automatically tested against the given example value? It'd be a good internal consistency check.

mjpieters added a commit to mjpieters/pact-reference that referenced this issue May 20, 2024
Correct the example regex used for the term! and matching_regex! docs,
and remove an accidental copy-pasta from the comment string in the
example.

Fixes pact-foundation#424
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 a pull request may close this issue.

1 participant