Skip to content

Commit

Permalink
Fixed Type Conflict by renaming test case functions
Browse files Browse the repository at this point in the history
  • Loading branch information
harshsingh-24 committed Apr 25, 2023
1 parent a2b8249 commit 4360d56
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 24 deletions.
115 changes: 107 additions & 8 deletions examples/expr2.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,109 @@
def main0():
x: i32
x = (2+3)*5
print(x)
def is_lower():
# Case 1: When constant string is present
assert "".islower() == False
assert "APPLE".islower() == False
assert "4432632479".islower() == False
assert "%#$#$#32a".islower() == True
assert "apple".islower() == True
assert "apple is a fruit".islower() == True

main0()
# Case 2: When variable string is present
s: str
s = ""
assert s.islower() == False
s = "APPLE"
assert s.islower() == False
s = "238734587"
assert s.islower() == False
s = "%#$#$#32a"
assert s.islower() == True
s = "apple"
assert s.islower() == True
s = "apple is a fruit"
assert s.islower() == True

# Not implemented yet in LPython:
#if __name__ == "__main__":
# main()
def is_upper():
# Case 1: When constant string is present
assert "".isupper() == False
assert "apple".isupper() == False
assert "4432632479".isupper() == False
assert "%#$#$#32A".isupper() == True
assert "APPLE".isupper() == True
assert "APPLE IS A FRUIT".isupper() == True

# Case 2: When variable string is present
s: str
s = ""
assert s.isupper() == False
s = "apple"
assert s.isupper() == False
s = "238734587"
assert s.isupper() == False
s = "%#$#$#32A"
assert s.isupper() == True
s = "APPLE"
assert s.isupper() == True
s = "APPLE IS A FRUIT"
assert s.isupper() == True

def is_decimal():
# Case 1: When constant string is present
assert "".isdecimal() == False
assert "apple".isdecimal() == False
assert "4432632479".isdecimal() == True
assert "%#$#$#32A".isdecimal() == False
assert "1.25".isdecimal() == False
assert "-325".isdecimal() == False
assert "12 35".isdecimal() == False

# Case 2: When variable string is present
s: str
s = ""
assert s.isdecimal() == False
s = "apple"
assert s.isdecimal() == False
s = "238734587"
assert s.isdecimal() == True
s = "%#$#$#32A"
assert s.isdecimal() == False
s = "1.35"
assert s.isdecimal() == False
s = "-42556"
assert s.isdecimal() == False
s = "12 34"
assert s.isdecimal() == False

def is_ascii():
# Case 1: When constant string is present
assert "".isascii() == True
assert " ".isascii() == True
assert "Hello, World123!".isascii() == True
assert "Hëllö, Wörld!".isascii() == False
assert "This is a test string with some non-ASCII characters: 🚀".isascii() == False
assert "\t\n\r".isascii() == True
assert "12 35".isascii() == True

# # Case 2: When variable string is present
s: str
s = ""
assert s.isascii() == True
s = " "
assert s.isascii() == True
s = "Hello, World!"
assert s.isascii() == True
s = "Hëllö, Wörld!"
assert s.isascii() == False
s = "This is a test string with some non-ASCII characters: 🚀"
assert s.isascii() == False
s = "\t\n\r"
assert s.isascii() == True
s = "123 45 6"
assert s.isascii() == True

def check():
is_lower()
is_upper()
is_decimal()
is_ascii()

check()
24 changes: 8 additions & 16 deletions integration_tests/test_str_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def partition():
seperator = "apple"
assert s.partition(seperator) == ("rendezvous 5", "", "")

def islower():
def is_lower():
# Case 1: When constant string is present
assert "".islower() == False
assert "APPLE".islower() == False
Expand All @@ -193,8 +193,6 @@ def islower():

# Case 2: When variable string is present
s: str
s = ""
assert s.islower() == False
s = "APPLE"
assert s.islower() == False
s = "238734587"
Expand All @@ -206,7 +204,7 @@ def islower():
s = "apple is a fruit"
assert s.islower() == True

def isupper():
def is_upper():
# Case 1: When constant string is present
assert "".isupper() == False
assert "apple".isupper() == False
Expand All @@ -217,8 +215,6 @@ def isupper():

# Case 2: When variable string is present
s: str
s = ""
assert s.isupper() == False
s = "apple"
assert s.isupper() == False
s = "238734587"
Expand All @@ -230,7 +226,7 @@ def isupper():
s = "APPLE IS A FRUIT"
assert s.isupper() == True

def isdecimal():
def is_decimal():
# Case 1: When constant string is present
assert "".isdecimal() == False
assert "apple".isdecimal() == False
Expand All @@ -242,8 +238,6 @@ def isdecimal():

# Case 2: When variable string is present
s: str
s = ""
assert s.isdecimal() == False
s = "apple"
assert s.isdecimal() == False
s = "238734587"
Expand All @@ -257,7 +251,7 @@ def isdecimal():
s = "12 34"
assert s.isdecimal() == False

def isascii():
def is_ascii():
# Case 1: When constant string is present
assert "".isascii() == True
assert " ".isascii() == True
Expand All @@ -269,8 +263,6 @@ def isascii():

# # Case 2: When variable string is present
s: str
s = ""
assert s.isascii() == True
s = " "
assert s.isascii() == True
s = "Hello, World!"
Expand All @@ -294,9 +286,9 @@ def check():
startswith()
endswith()
partition()
islower()
isupper()
isdecimal()
isascii()
is_lower()
is_upper()
is_decimal()
is_ascii()

check()

0 comments on commit 4360d56

Please sign in to comment.