From 56d59182d164c23ffacdb978eaa87d886e74ca04 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 16 Feb 2008 19:21:50 +0100 Subject: [PATCH] new tests for 'in' operator --- tests/run/inop.pyx | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/run/notinop.pyx | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/run/inop.pyx create mode 100644 tests/run/notinop.pyx 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 -- 2.26.2