Skip to content

Add more cases to test_patma #106135

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

Closed
sobolevn opened this issue Jun 27, 2023 · 3 comments
Closed

Add more cases to test_patma #106135

sobolevn opened this issue Jun 27, 2023 · 3 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Jun 27, 2023

While anwsering #106133 I've noticed that test_patma does not have tests for some corner-cases:

  1. Case case [x] | x: ... is mentined in https://peps.python.org/pep-0634/#capture-patterns but is never tested, the closest we have to it is case [z] | [1, (0 | 1 as z)] | [z]:, which is not the same
  2. Guards can have side effects according to https://peps.python.org/pep-0634/#guards but it is never tested
  3. Guards are never tested with: mapping patterns, dotted value patterns
  4. In ClassPattern section PEP says: If name_or_attr is not an instance of the builtin type, TypeError is raised. It is never tested in TestTypeErrors
  5. LiteralPattern might have some more expected SyntaxError cases, like using * and /, using three numbers like 0 + 0j + 0
  6. LiteralPattern says: The singleton literals None, True and False are compared using the is operator., but only None is checked

I would like to send a PR with the new test cases.

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jun 27, 2023
@sobolevn sobolevn self-assigned this Jun 27, 2023
@terryjreedy
Copy link
Member

Seems like a good idea. Question: case x, x: pass evokes SyntaxError: incomplete input for any statement. Does this seem right or should I open an issue?

@sobolevn
Copy link
Member Author

@terryjreedy yes, this is not allowed: https://peps.python.org/pep-0634/#capture-patterns

This disallows for example case x, x: ...

@brandtbucher
Copy link
Member

Thanks for taking this on, it's definitely appreciated! Please ping me for review once it's ready. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants