diff options
Diffstat (limited to 'tests/run/extra_patma.pyx')
-rw-r--r-- | tests/run/extra_patma.pyx | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/tests/run/extra_patma.pyx b/tests/run/extra_patma.pyx index 3bded3426..76357f36f 100644 --- a/tests/run/extra_patma.pyx +++ b/tests/run/extra_patma.pyx @@ -5,6 +5,41 @@ cimport cython import array +import sys + +__doc__ = "" + + +cdef bint is_null(int* x): + return False # disabled - currently just a parser test + match x: + case NULL: + return True + case _: + return False + + +def test_is_null(): + """ + >>> test_is_null() + """ + cdef int some_int = 1 + return # disabled - currently just a parser test + assert is_null(&some_int) == False + assert is_null(NULL) == True + + +if sys.version_info[0] > 2: + __doc__ += """ + array.array doesn't have the buffer protocol in Py2 and + this doesn't really feel worth working around to test + >>> print(test_memoryview(array.array('i', [0, 1, 2]))) + a 1 + >>> print(test_memoryview(array.array('i', []))) + b + >>> print(test_memoryview(array.array('i', [5]))) + c [5] + """ # goes via .shape instead @cython.test_fail_if_path_exists("//CallNode//NameNode[@name = 'len']") @@ -12,14 +47,8 @@ import array @cython.test_fail_if_path_exists("//PythonCapiCallNode//PythonCapiFunctionNode[@cname = '__Pyx_MatchCase_IsSequence']") def test_memoryview(int[:] x): """ - >>> print(test_memoryview(array.array('i', [0, 1, 2]))) - a 1 - >>> print(test_memoryview(array.array('i', []))) - b >>> print(test_memoryview(None)) no! - >>> print(test_memoryview(array.array('i', [5]))) - c [5] """ match x: case [0, y, 2]: @@ -45,6 +74,7 @@ def test_list_to_sequence(list x): case _: return False + @cython.test_fail_if_path_exists("//PythonCapiCallNode//PythonCapiFunctionNode[@cname = '__Pyx_MatchCase_IsSequence']") @cython.test_fail_if_path_exists("//CmpNode") # There's nothing to compare - it always succeeds! def test_list_not_None_to_sequence(list x not None): @@ -89,7 +119,7 @@ def class_attr_lookup(x): assert cython.typeof(y) == "double", cython.typeof(y) return y -class PyClass: +class PyClass(object): pass @cython.test_assert_path_exists("//PythonCapiFunctionNode[@cname='__Pyx_TypeCheck']") @@ -110,6 +140,7 @@ def class_typecheck_exists(x): case _: return False + @cython.test_fail_if_path_exists("//NameNode[@name='isinstance']") @cython.test_fail_if_path_exists("//PythonCapiFunctionNode[@cname='__Pyx_TypeCheck']") def class_typecheck_doesnt_exist(C x): |