summaryrefslogtreecommitdiff
path: root/tests/errors
diff options
context:
space:
mode:
authorSpencer Brown <spencerb21@live.com>2021-05-26 16:46:22 +1000
committerGitHub <noreply@github.com>2021-05-26 08:46:22 +0200
commitf902c26b5516d44e6f41deb815cbfc5f4aa7aaf3 (patch)
tree2c8b8dd3d66b4e1090b76372e0b5e414465907cd /tests/errors
parenta0a105d305f910c63dd0b12481842fd17580cb6e (diff)
downloadcython-f902c26b5516d44e6f41deb815cbfc5f4aa7aaf3.tar.gz
Implement @total_ordering decorator for extension types (GH-3626)
Implements https://github.com/cython/cython/issues/2090
Diffstat (limited to 'tests/errors')
-rw-r--r--tests/errors/e_exttype_total_ordering.pyx178
1 files changed, 178 insertions, 0 deletions
diff --git a/tests/errors/e_exttype_total_ordering.pyx b/tests/errors/e_exttype_total_ordering.pyx
new file mode 100644
index 000000000..6d5dd34e6
--- /dev/null
+++ b/tests/errors/e_exttype_total_ordering.pyx
@@ -0,0 +1,178 @@
+# mode: error
+# tag: total_ordering, warnings
+
+cimport cython
+
+
+# Test all combinations with not enough methods.
+
+@cython.total_ordering
+cdef class ExtNoFuncs:
+ pass
+
+@cython.total_ordering
+cdef class ExtGe:
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLe:
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLeGe:
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGt:
+ def __gt__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGtGe:
+ def __gt__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGtLe:
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGtLeGe:
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLt:
+ def __lt__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGe:
+ def __lt__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtLe:
+ def __lt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtLeGe:
+ def __lt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGt:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGtGe:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGtLe:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGtLeGe:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtNe:
+ def __ne__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtEq:
+ def __eq__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtEqNe:
+ def __eq__(self, other):
+ return False
+
+ def __ne__(self, other):
+ return False
+
+
+_WARNINGS = """
+10:5: total_ordering directive used, but no comparison and equality methods defined
+14:5: total_ordering directive used, but no equality method defined
+19:5: total_ordering directive used, but no equality method defined
+24:5: total_ordering directive used, but no equality method defined
+32:5: total_ordering directive used, but no equality method defined
+37:5: total_ordering directive used, but no equality method defined
+45:5: total_ordering directive used, but no equality method defined
+53:5: total_ordering directive used, but no equality method defined
+64:5: total_ordering directive used, but no equality method defined
+69:5: total_ordering directive used, but no equality method defined
+77:5: total_ordering directive used, but no equality method defined
+85:5: total_ordering directive used, but no equality method defined
+96:5: total_ordering directive used, but no equality method defined
+104:5: total_ordering directive used, but no equality method defined
+115:5: total_ordering directive used, but no equality method defined
+126:5: total_ordering directive used, but no equality method defined
+140:5: total_ordering directive used, but no comparison methods defined
+145:5: total_ordering directive used, but no comparison methods defined
+150:5: total_ordering directive used, but no comparison methods defined
+"""