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

isupper bug #43

Open
thekevinscott opened this issue Feb 20, 2024 · 2 comments · May be fixed by #45
Open

isupper bug #43

thekevinscott opened this issue Feb 20, 2024 · 2 comments · May be fixed by #45

Comments

@thekevinscott
Copy link
Contributor

The javascript definition of isupper is defined here:

function isupper(a) {
  return /^[A-Z_$]*$/.test(a);
}

This is slightly different from the Python implementation, with respect to digits:

'__IGNORE_0'.isupper()
# True
/^[A-Z_$]*$/.test('__IGNORE_0');
// false

The regex should be updated to /^[A-Z0-9_$]*$/

@erezsh
Copy link
Member

erezsh commented Feb 20, 2024

Okay, thanks for reporting it!

It still isn't right, because in Python '0'.isupper() == False. But you're right that it needs fixing.

@thekevinscott thekevinscott linked a pull request Feb 23, 2024 that will close this issue
@thekevinscott
Copy link
Contributor Author

Ah, very true. Good catch!

https://docs.python.org/3/library/stdtypes.html#str.isupper

Return True if all cased characters [4] in the string are uppercase and there is at least one cased character, False otherwise.

It sounds like the main edge case is that there must be one cased character.

I opened a PR here that adds test cases that I think covers all the edge cases: #45

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.

2 participants