From: Stefan Behnel Date: Sat, 16 Feb 2008 18:21:50 +0000 (+0100) Subject: new tests for 'in' operator X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=56d59182d164c23ffacdb978eaa87d886e74ca04;p=cython.git new tests for 'in' operator --- diff --git a/tests/run/inop.pyx b/tests/run/inop.pyx new file mode 100644 index 00000000..ae5a027c --- /dev/null +++ b/tests/run/inop.pyx @@ -0,0 +1,43 @@ +__doc__ = """ + >>> f(1,[1,2,3]) + True + >>> f(5,[1,2,3]) + False + >>> f(2,(1,2,3)) + True + + >>> g(1,[1,2,3]) + 1 + >>> g(5,[1,2,3]) + 0 + >>> g(2,(1,2,3)) + 1 + + >>> h([1,2,3,4]) + True + >>> h([1,3,4]) + False + + >>> j([1,2,3,4]) + 1 + >>> j([1,3,4]) + 0 +""" + +def f(a,b): + result = a in b + return result + +def g(a,b): + cdef int result + result = a in b + return result + +def h(b): + result = 2 in b + return result + +def j(b): + cdef int result + result = 2 in b + return result diff --git a/tests/run/notinop.pyx b/tests/run/notinop.pyx new file mode 100644 index 00000000..f4aae7a6 --- /dev/null +++ b/tests/run/notinop.pyx @@ -0,0 +1,43 @@ +__doc__ = """ + >>> f(1,[1,2,3]) + False + >>> f(5,[1,2,3]) + True + >>> f(2,(1,2,3)) + False + + >>> g(1,[1,2,3]) + 0 + >>> g(5,[1,2,3]) + 1 + >>> g(2,(1,2,3)) + 0 + + >>> h([1,2,3,4]) + False + >>> h([1,3,4]) + True + + >>> j([1,2,3,4]) + 0 + >>> j([1,3,4]) + 1 +""" + +def f(a,b): + result = a not in b + return result + +def g(a,b): + cdef int result + result = a not in b + return result + +def h(b): + result = 2 not in b + return result + +def j(b): + cdef int result + result = 2 not in b + return result