Skip to content

Commit

Permalink
Merge pull request #2746 from wolfv/strings
Browse files Browse the repository at this point in the history
add string.py with constants
  • Loading branch information
certik authored Jul 25, 2024
2 parents fa9df0a + 08dd40d commit 0e2a5ba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/os.py" "${CMAKE_CURRENT_
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/platform.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/platform.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/random.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/random.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/statistics.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/statistics.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/string.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/string.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/sys.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/sys.py")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/time.py" "${CMAKE_CURRENT_BINARY_DIR}/src/runtime/time.py")

Expand Down
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ RUN(NAME test_str_03 LABELS cpython llvm llvm_jit c)
RUN(NAME test_str_04 LABELS cpython llvm llvm_jit c wasm)
RUN(NAME test_str_05 LABELS cpython llvm llvm_jit c)
RUN(NAME test_str_06 LABELS cpython llvm llvm_jit c)
RUN(NAME test_string_01 LABELS cpython llvm llvm_jit c)
RUN(NAME test_list_01 LABELS cpython llvm llvm_jit c)
RUN(NAME test_list_02 LABELS cpython llvm llvm_jit c)
RUN(NAME test_list_03 LABELS cpython llvm llvm_jit c NOFAST)
Expand Down
7 changes: 7 additions & 0 deletions integration_tests/test_string_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from string import ascii_lowercase, ascii_letters

def test_string():
assert ascii_lowercase == 'abcdefghijklmnopqrstuvwxyz'
assert ascii_letters == 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

print(ascii_lowercase)
9 changes: 9 additions & 0 deletions src/runtime/string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
whitespace : str = ' \t\n\r\v\f'
ascii_lowercase : str = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase : str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters : str = ascii_lowercase + ascii_uppercase
digits : str = '0123456789'
hexdigits : str = digits + 'abcdef' + 'ABCDEF'
octdigits : str = '01234567'
punctuation : str = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
printable : str = digits + ascii_letters + punctuation + whitespace

0 comments on commit 0e2a5ba

Please sign in to comment.