Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixes empty string bug in str isalpha method
  • Loading branch information
advikkabra committed Feb 5, 2024
commit 08e1f45025e56b3ba7978a32166ec269afbb5149
3 changes: 3 additions & 0 deletions integration_tests/test_str_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ def test_str_isalpha():
b: str = "hj kl"
c: str = "a12(){}A"
d: str = " "
e: str = ""
res: bool = a.isalpha()
res2: bool = b.isalpha()
res3: bool = c.isalpha()
res4: bool = d.isalpha()
res5: bool = e.isalpha()
assert res == True
assert res2 == False
assert res3 == False
assert res4 == False
assert res5 == False


def test_str_title():
Expand Down
1 change: 1 addition & 0 deletions lpython
Submodule lpython added at 467081
1 change: 1 addition & 0 deletions src/runtime/lpython_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ def _lpython_str_join(s:str, lis:list[str]) -> str:

def _lpython_str_isalpha(s: str) -> bool:
ch: str
if len(s) == 0: return False
for ch in s:
ch_ord: i32 = ord(ch)
if 65 <= ch_ord and ch_ord <= 90:
Expand Down