-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[mypyc] Implement str.lower()
and str.upper()
primitive
#19375
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
Draft
Jahongir-Qurbonov
wants to merge
10
commits into
python:master
Choose a base branch
from
Jahongir-Qurbonov:str-lower-upper
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d4ef31a
Add str.lower() and str.upper() primitives
Jahongir-Qurbonov 124dceb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8065f9c
Refactor tolower_ucs4 and toupper_ucs4 functions by removing fallback…
Jahongir-Qurbonov 1d40499
Optimize CPyStr_Lower and CPyStr_Upper for ASCII strings by removing …
Jahongir-Qurbonov 2750549
Optimize CPyStr_Lower and CPyStr_Upper for ASCII strings by removing …
Jahongir-Qurbonov 62520ef
Add test case for lower() method with special case for uppercase 'SS'
Jahongir-Qurbonov cc2ed14
Refactor CPyStr_Lower and CPyStr_Upper to use consistent variable nam…
Jahongir-Qurbonov 5cdca5a
Add test case for lower() method to handle Greek capital sigma
Jahongir-Qurbonov 7049d8b
Add commented-out test cases for lower() and upper() methods to handl…
Jahongir-Qurbonov bd4bde2
Merge branch 'python:master' into str-lower-upper
Jahongir-Qurbonov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -906,3 +906,30 @@ def test_count_multi_start_end_emoji() -> None: | |
assert string.count("😴😴😴", 0, 12) == 1, string.count("😴😴😴", 0, 12) | ||
assert string.count("🚀🚀🚀", 0, 12) == 2, string.count("🚀🚀🚀", 0, 12) | ||
assert string.count("ñññ", 0, 12) == 1, string.count("ñññ", 0, 12) | ||
|
||
[case testLower] | ||
def test_str_lower() -> None: | ||
assert "".lower() == "" | ||
assert "ABC".lower() == "abc" | ||
assert "abc".lower() == "abc" | ||
assert "AbC123".lower() == "abc123" | ||
assert "áÉÍ".lower() == "áéí" | ||
assert "😴🚀".lower() == "😴🚀" | ||
# Special | ||
assert "SS".lower() == "ss" | ||
assert "Σ".lower() == "σ" # Greek capital sigma -> small sigma | ||
#assert "İ".lower() == "i̇" # TODO: Latin capital letter I with dot above -> 'i' + combining dot | ||
#assert len("İ".lower()) == 2 # TODO: Confirms length change | ||
|
||
[case testUpper] | ||
def test_str_upper() -> None: | ||
assert "".upper() == "" | ||
assert "abc".upper() == "ABC" | ||
assert "ABC".upper() == "ABC" | ||
assert "AbC123".upper() == "ABC123" | ||
assert "áéí".upper() == "ÁÉÍ" | ||
assert "😴🚀".upper() == "😴🚀" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also test special case (verify that this agrees with normal Python semantics):
|
||
# Special | ||
#assert "ß".upper() == "SS" # TODO: German sharp S -> double S | ||
#assert "ffi".upper() == "FFI" # TODO: Ligature 'ffi' -> separate letters | ||
#assert len("ffi".upper()) == 3 # TODO: Confirm length increases |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test special cases (verify that this agrees with normal Python semantics):
'SS'.lower() == 'ss'
'Σ'.lower()
'İ'.lower()
(changes length!)