From 78df7dc4b726b599bb8343a5e9701b0e08146326 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 1 Jan 2008 13:17:33 +0100 Subject: [PATCH] loads of doctests --- tests/compile/classmethargdefault.pyx | 19 +++++++++-- tests/compile/pinard4.pyx | 6 ++++ tests/run/addop.pyx | 8 ++++- tests/run/ass2local.pyx | 6 ++++ tests/run/bishop1.pyx | 13 ++++++++ tests/run/boolop.pyx | 13 +++++++- tests/run/classpass.pyx | 11 +++++++ tests/run/concatcstrings.pyx | 5 +++ tests/run/cstringmul.pyx | 11 +++++-- tests/run/cvardef.pyx | 4 +++ tests/run/exarkun.pyx | 18 +++++++++-- tests/run/extclasspass.pyx | 7 +++- tests/run/extinstantiate.pyx | 6 ++++ tests/run/if.pyx | 37 ++++++++++++++++++--- tests/run/ishimoto3.pyx | 10 ++++++ tests/run/kostyrka.pyx | 6 ++++ tests/run/kostyrka2.pyx | 6 ++++ tests/run/lepage_1.pyx | 18 +++++++++++ tests/run/list.pyx | 27 +++++++++++++++- tests/run/literals.pyx | 4 +++ tests/run/multass.pyx | 34 ++++++++++++++++++-- tests/run/pass.pyx | 4 +++ tests/run/pinard6.pyx | 5 +++ tests/run/pinard8.pyx | 21 ++++++++++++ tests/run/print.pyx | 10 +++++- tests/run/pyintop.pyx | 37 ++++++++++++++++++--- tests/run/r_jiba1.pyx | 18 ++++++++--- tests/run/r_mcintyre1.pyx | 8 +++++ tests/run/r_mitch_chapman_2.pyx | 5 +++ tests/run/r_vree_1.pyx | 13 ++++++++ tests/run/rodriguez_1.pyx | 6 ++++ tests/run/simpcall.pyx | 26 +++++++++++++-- tests/run/slice2.pyx | 30 +++++++++++++++++ tests/run/strconstinclass.pyx | 6 ++++ tests/run/tuple.pyx | 46 +++++++++++++++++++++++++++ tests/run/unop.pyx | 12 ++++++- tests/run/unpack.pyx | 9 ++++-- 37 files changed, 491 insertions(+), 34 deletions(-) diff --git a/tests/compile/classmethargdefault.pyx b/tests/compile/classmethargdefault.pyx index 8c827f1f..72bdb1c5 100644 --- a/tests/compile/classmethargdefault.pyx +++ b/tests/compile/classmethargdefault.pyx @@ -1,5 +1,20 @@ +__doc__ = """ + >>> s = Swallow() + >>> s.spam(1) + 1 42 'grail' True + >>> s.spam(1, 2) + 1 2 'grail' True + >>> s.spam(1, z = 2) + 1 42 'grail' 2 + >>> s.spam(1, y = 2) + 1 42 2 True + >>> s.spam(1, x = 2, y = 'test') + 1 2 'test' True +""" + +swallow = True + class Swallow: def spam(w, int x = 42, y = "grail", z = swallow): - pass - + print w, x, y, z diff --git a/tests/compile/pinard4.pyx b/tests/compile/pinard4.pyx index 69e9a56c..c9f66f45 100644 --- a/tests/compile/pinard4.pyx +++ b/tests/compile/pinard4.pyx @@ -1 +1,7 @@ +__doc__ = """ + >>> fiches_CP + [] +""" + +fiches_CP = [1,2,3] fiches_CP[:] = [] diff --git a/tests/run/addop.pyx b/tests/run/addop.pyx index 6f44d038..0bf19e5c 100644 --- a/tests/run/addop.pyx +++ b/tests/run/addop.pyx @@ -1,6 +1,12 @@ +__doc__ = """ + >>> +""" + def f(): cdef int int1, int2, int3 cdef char *ptr1, *ptr2, *ptr3 + int2 = 10 + int3 = 20 obj1 = 1 obj2 = 2 obj3 = 3 @@ -8,4 +14,4 @@ def f(): ptr1 = ptr2 + int3 ptr1 = int2 + ptr3 obj1 = obj2 + int3 - \ No newline at end of file + return int1, obj1 diff --git a/tests/run/ass2local.pyx b/tests/run/ass2local.pyx index 20524b1c..c929027b 100644 --- a/tests/run/ass2local.pyx +++ b/tests/run/ass2local.pyx @@ -1,2 +1,8 @@ +__doc__ = """ + >>> f() + 42 +""" + def f(): a = 42 + return a diff --git a/tests/run/bishop1.pyx b/tests/run/bishop1.pyx index 7b9b6208..52c3468c 100644 --- a/tests/run/bishop1.pyx +++ b/tests/run/bishop1.pyx @@ -1,3 +1,13 @@ +__doc__ = """ + >>> m = fmatrix() + >>> m[1] = True + >>> m.getfoo() + 1 + >>> m[0] = True + >>> m.getfoo() + 0 +""" + cdef class fmatrix: cdef int foo @@ -6,3 +16,6 @@ cdef class fmatrix: self.foo = value return self.foo = not value + + def getfoo(self): + return self.foo diff --git a/tests/run/boolop.pyx b/tests/run/boolop.pyx index dfafab45..bdc3e83f 100644 --- a/tests/run/boolop.pyx +++ b/tests/run/boolop.pyx @@ -1,7 +1,17 @@ -cdef void foo(obj1, obj2, obj3, obj4, obj5): +__doc__ = """ + >>> foo(True, False, 23, 'test', 1) + (0, 1, False, False) +""" + +def foo(obj1, obj2, obj3, obj4, obj5): cdef int bool1, bool2, bool3, bool4 cdef char *ptr cdef float f + bool1 = 1 + bool2 = 0 + ptr = NULL + f = 0.0 + bool3 = bool1 and bool2 bool3 = bool1 or bool2 bool3 = obj1 and obj2 @@ -11,3 +21,4 @@ cdef void foo(obj1, obj2, obj3, obj4, obj5): bool4 = bool1 or bool2 and bool3 obj4 = obj1 and obj2 and obj3 obj5 = (obj1 + obj2 + obj3) and obj4 + return bool3, bool4, obj4, obj5 diff --git a/tests/run/classpass.pyx b/tests/run/classpass.pyx index f644f35f..603d1422 100644 --- a/tests/run/classpass.pyx +++ b/tests/run/classpass.pyx @@ -1,2 +1,13 @@ +__doc__ = """ + >>> s = Spam() + >>> print s.__class__.__name__ + Spam + + >>> s = SpamT() + >>> print type(s).__name__ + SpamT +""" + class Spam: pass +class SpamT(object): pass diff --git a/tests/run/concatcstrings.pyx b/tests/run/concatcstrings.pyx index ce1b92c2..a524e9e7 100644 --- a/tests/run/concatcstrings.pyx +++ b/tests/run/concatcstrings.pyx @@ -1,2 +1,7 @@ +__doc__ = """ + >>> spam == "C string 1" + "C string 2" + True +""" + spam = "C string 1" + "C string 2" diff --git a/tests/run/cstringmul.pyx b/tests/run/cstringmul.pyx index bef435ad..6f76adad 100644 --- a/tests/run/cstringmul.pyx +++ b/tests/run/cstringmul.pyx @@ -1,3 +1,10 @@ -spam = "eggs" * 42 -grail = 17 * "tomato" +__doc__ = """ + >>> print spam + eggseggseggseggs + >>> print grail + tomatotomatotomatotomatotomatotomatotomato +""" + +spam = "eggs" * 4 +grail = 7 * "tomato" diff --git a/tests/run/cvardef.pyx b/tests/run/cvardef.pyx index 57d4be3c..7ae03133 100644 --- a/tests/run/cvardef.pyx +++ b/tests/run/cvardef.pyx @@ -1,3 +1,7 @@ +__doc__ = """ + >>> f() +""" + def f(): cdef char a_char cdef short a_short diff --git a/tests/run/exarkun.pyx b/tests/run/exarkun.pyx index 4ca7ad11..2803e4c5 100644 --- a/tests/run/exarkun.pyx +++ b/tests/run/exarkun.pyx @@ -1,3 +1,14 @@ +__doc__ = """ + >>> p = Point(1,2,3) + >>> p.gettuple() + (1.0, 2.0, 3.0) + >>> q = p + Point(2,3,4) + >>> q.gettuple() + (3.0, 5.0, 7.0) + >>> p.gettuple() + (1.0, 2.0, 3.0) +""" + cdef class Point: cdef double x, y, z def __init__(self, double x, double y, double z): @@ -5,6 +16,9 @@ cdef class Point: self.y = y self.z = z - # XXX - def __add__(self, other): + # XXX: originally, this said "def __add__(self, other)" + def __add__(Point self, Point other): return Point(self.x + other.x, self.y + other.y, self.z + other.z) + + def gettuple(self): + return (self.x, self.y, self.z) diff --git a/tests/run/extclasspass.pyx b/tests/run/extclasspass.pyx index b8b19eed..528e23e5 100644 --- a/tests/run/extclasspass.pyx +++ b/tests/run/extclasspass.pyx @@ -1,2 +1,7 @@ -cdef class Eggs: pass +__doc__ = """ + >>> e = Eggs() + >>> print type(e).__name__ + Eggs +""" +cdef class Eggs: pass diff --git a/tests/run/extinstantiate.pyx b/tests/run/extinstantiate.pyx index d64ad0a7..b6f1e937 100644 --- a/tests/run/extinstantiate.pyx +++ b/tests/run/extinstantiate.pyx @@ -1,5 +1,11 @@ +__doc__ = """ + >>> print type(f()).__name__ + Spam +""" + cdef class Spam: pass def f(): s = Spam() + return s diff --git a/tests/run/if.pyx b/tests/run/if.pyx index e3176a3f..a1d9dac2 100644 --- a/tests/run/if.pyx +++ b/tests/run/if.pyx @@ -1,19 +1,48 @@ +__doc__ = """ + >>> f(0,0) + 0 + >>> f(1,2) + 2 + >>> f(1,-1) + 1 + + >>> g(1,2) + 1 + >>> g(0,2) + 2 + >>> g(0,0) + 0 + + >>> h(1,2) + 1 + >>> h(0,2) + 2 + >>> h(0,0) + 3 +""" + def f(a, b): + x = 0 if a: x = 1 - if a+b: - x = 1 - + x = 2 + return x + +def g(a, b): + x = 0 if a: x = 1 elif b: x = 2 + return x +def h(a, b): + x = 0 if a: x = 1 elif b: x = 2 else: x = 3 - \ No newline at end of file + return x diff --git a/tests/run/ishimoto3.pyx b/tests/run/ishimoto3.pyx index 1baf0b84..4954547e 100644 --- a/tests/run/ishimoto3.pyx +++ b/tests/run/ishimoto3.pyx @@ -1,3 +1,10 @@ +__doc__ = """ + >>> c1 = C1() + >>> c2 = C2(c1) + >>> c1 is c2.getc1() + True +""" + cdef class C1: pass @@ -6,3 +13,6 @@ cdef class C2: def __init__(self, arg): self.c1 = arg + + def getc1(self): + return self.c1 diff --git a/tests/run/kostyrka.pyx b/tests/run/kostyrka.pyx index baef2ff8..2b7f9262 100644 --- a/tests/run/kostyrka.pyx +++ b/tests/run/kostyrka.pyx @@ -1,3 +1,9 @@ +__doc__ = """ + >>> t = TEST() + >>> 1 in t + True +""" + cdef class TEST: def __contains__(self, x): return 42 diff --git a/tests/run/kostyrka2.pyx b/tests/run/kostyrka2.pyx index 0dfe2e04..b85659e4 100644 --- a/tests/run/kostyrka2.pyx +++ b/tests/run/kostyrka2.pyx @@ -1,2 +1,8 @@ +__doc__ = """ + >>> x = X() + >>> x.slots + [''] +""" + class X: slots = ["", ] diff --git a/tests/run/lepage_1.pyx b/tests/run/lepage_1.pyx index 551bc7f9..0dd1980f 100644 --- a/tests/run/lepage_1.pyx +++ b/tests/run/lepage_1.pyx @@ -1,5 +1,23 @@ +__doc__ = """ + >>> a = A(1,2,3) + >>> a[0] + 1.0 + >>> a[1] + 2.0 + >>> a[2] + 3.0 +""" + cdef class A: cdef double x[3] + def __init__(self, *args): + cdef int i, max + max = len(args) + if max > 3: + max = 3 + for i from 0 <= i < max: + self.x[i] = args[i] + def __getitem__(self,i): return self.x[i] diff --git a/tests/run/list.pyx b/tests/run/list.pyx index 550494c4..40821b42 100644 --- a/tests/run/list.pyx +++ b/tests/run/list.pyx @@ -1,7 +1,32 @@ +__doc__ = """ + >>> f(1, 2, 3, 4, 5) + [] + >>> g(1, 2, 3, 4, 5) + [2] + >>> h(1, 2, 3, 4, 5) + [2, 3] + >>> j(1, 2, 3, 4, 5) + [2, 3, 4] + >>> k(1, 2, 3, 4, 5) + [17, 42, 88] +""" + def f(obj1, obj2, obj3, obj4, obj5): obj1 = [] + return obj1 + +def g(obj1, obj2, obj3, obj4, obj5): obj1 = [obj2] + return obj1 + +def h(obj1, obj2, obj3, obj4, obj5): obj1 = [obj2, obj3] + return obj1 + +def j(obj1, obj2, obj3, obj4, obj5): obj1 = [obj2, obj3, obj4] + return obj1 + +def k(obj1, obj2, obj3, obj4, obj5): obj1 = [17, 42, 88] - \ No newline at end of file + return obj1 diff --git a/tests/run/literals.pyx b/tests/run/literals.pyx index 158009a3..0421d7e3 100644 --- a/tests/run/literals.pyx +++ b/tests/run/literals.pyx @@ -1,3 +1,7 @@ +__doc__ = """ + >>> foo() +""" + def foo(): a = 42 a1 = 0123 diff --git a/tests/run/multass.pyx b/tests/run/multass.pyx index e5820657..735cee07 100644 --- a/tests/run/multass.pyx +++ b/tests/run/multass.pyx @@ -1,8 +1,36 @@ -cdef void f(): +__doc__ = """ + >>> f() + (1, 2, 1, 2) + >>> g() + (1, 1, 2, 2, 3, 3) + >>> h() + (1, 'test', 3, 1, 'test', 3) + >>> j() + (2, 1, 4, 2, 6, 3) +""" + +def f(): cdef object obj1a, obj2a, obj3a, obj1b, obj2b, obj3b - cdef int int1, int2 - cdef char *ptr1, *ptr2 + obj1b, obj2b, obj3b = 1, 2, 3 obj1a, obj2a = obj1b, obj2b + return obj1a, obj2a, obj1b, obj2b + +def g(): + cdef object obj1a, obj2a, obj3a, obj1b, obj2b, obj3b + obj1b, obj2b, obj3b = 1, 2, 3 obj1a, [obj2a, obj3a] = [obj1b, (obj2b, obj3b)] + return obj1a, obj1b, obj2a, obj2b, obj3a, obj3b + +def h(): + cdef object obj1a, obj2a, obj3a, obj1b, obj2b, obj3b + cdef int int1, int2 + cdef char *ptr1, *ptr2 + int2, ptr2, obj1b = 1, "test", 3 int1, ptr1, obj1a = int2, ptr2, obj1b + return int1, ptr1, obj1a, int2, ptr2, obj1b + +def j(): + cdef object obj1a, obj2a, obj3a, obj1b, obj2b, obj3b + obj1b, obj2b, obj3b = 1, 2, 3 obj1a, obj2a, obj3a = obj1b + 1, obj2b + 2, obj3b + 3 + return obj1a, obj1b, obj2a, obj2b, obj3a, obj3b diff --git a/tests/run/pass.pyx b/tests/run/pass.pyx index 4f28bc7a..88c7af0f 100644 --- a/tests/run/pass.pyx +++ b/tests/run/pass.pyx @@ -1,2 +1,6 @@ +__doc__ = """ + >>> f() +""" + def f(): pass diff --git a/tests/run/pinard6.pyx b/tests/run/pinard6.pyx index 98d03059..7fadadef 100644 --- a/tests/run/pinard6.pyx +++ b/tests/run/pinard6.pyx @@ -1,2 +1,7 @@ +__doc__ = """ + >>> x + (1, 2) +""" + x = 1, x = 1, 2, diff --git a/tests/run/pinard8.pyx b/tests/run/pinard8.pyx index aae2b506..e7232fca 100644 --- a/tests/run/pinard8.pyx +++ b/tests/run/pinard8.pyx @@ -1,5 +1,26 @@ +__doc__ = """ + >>> f = Fiche() + >>> f[0] = 1 + >>> f.geti() + 1 + + >>> f[1] = None + >>> f.geti() + 0 + + >>> f[0] = 1 + >>> f.geti() + 1 +""" + cdef class Fiche: + cdef int i def __setitem__(self, element, valeur): + self.i = 0 if valeur is None: return + self.i = 1 + + def geti(self): + return self.i diff --git a/tests/run/print.pyx b/tests/run/print.pyx index 650f05c9..67b7e1f4 100644 --- a/tests/run/print.pyx +++ b/tests/run/print.pyx @@ -1,7 +1,15 @@ +__doc__ = """ + >>> f(1, 'test') + + 1 + 1 test + 1 test 42 spam +""" + def f(a, b): print print a print a, b print a, b, print 42, "spam" - \ No newline at end of file + diff --git a/tests/run/pyintop.pyx b/tests/run/pyintop.pyx index f6f3eeab..29734260 100644 --- a/tests/run/pyintop.pyx +++ b/tests/run/pyintop.pyx @@ -1,11 +1,38 @@ -def f(): - obj1 = 1 - obj2 = 2 - obj3 = 3 +__doc__ = """ + >>> f(1,2,3) + 3 + >>> g(1,2,3) + 1 + >>> h(1,2,3) + 2 + >>> j(1,2,3) + 16 + >>> k(1,2,3) + 0 + >>> l(1,2,3) + 16 +""" + +def f(obj1, obj2, obj3): obj1 = obj2 | obj3 + return obj1 + +def g(obj1, obj2, obj3): obj1 = obj2 ^ obj3 + return obj1 + +def h(obj1, obj2, obj3): obj1 = obj2 & obj3 + return obj1 + +def j(obj1, obj2, obj3): obj1 = obj2 << obj3 + return obj1 + +def k(obj1, obj2, obj3): obj1 = obj2 >> obj3 + return obj1 + +def l(obj1, obj2, obj3): obj1 = obj2 << obj3 | obj2 >> obj3 - \ No newline at end of file + return obj1 diff --git a/tests/run/r_jiba1.pyx b/tests/run/r_jiba1.pyx index 2034b387..cce2b7f1 100644 --- a/tests/run/r_jiba1.pyx +++ b/tests/run/r_jiba1.pyx @@ -1,3 +1,10 @@ +__doc__ = """ + >>> test() + This parrot is resting. + Lovely plumage! +""" + + cdef class Parrot: cdef void describe(self): @@ -11,8 +18,9 @@ cdef class Norwegian(Parrot): cdef void describe(self): print "Lovely plumage!" -cdef Parrot p1, p2 -p1 = Parrot() -p2 = Norwegian() -p1.describe() -p2.describe() +def test(): + cdef Parrot p1, p2 + p1 = Parrot() + p2 = Norwegian() + p1.describe() + p2.describe() diff --git a/tests/run/r_mcintyre1.pyx b/tests/run/r_mcintyre1.pyx index b0d19cef..a047ffcf 100644 --- a/tests/run/r_mcintyre1.pyx +++ b/tests/run/r_mcintyre1.pyx @@ -1,3 +1,11 @@ +__doc__ = """ + >>> b = Bicycle() + >>> b.fall_off() + Falling off extremely hard + >>> b.fall_off("somewhat") + Falling off somewhat hard +""" + class Bicycle: def fall_off(self, how_hard = "extremely"): diff --git a/tests/run/r_mitch_chapman_2.pyx b/tests/run/r_mitch_chapman_2.pyx index afbed934..003f0b51 100644 --- a/tests/run/r_mitch_chapman_2.pyx +++ b/tests/run/r_mitch_chapman_2.pyx @@ -1,3 +1,8 @@ +__doc__ = """ + >>> boolExpressionsFail() + 'Not 2b' +""" + def boolExpressionsFail(): dict = {1: 1} if not dict.has_key("2b"): diff --git a/tests/run/r_vree_1.pyx b/tests/run/r_vree_1.pyx index 257d67c5..a520d2e9 100644 --- a/tests/run/r_vree_1.pyx +++ b/tests/run/r_vree_1.pyx @@ -1,3 +1,16 @@ +__doc__ = """ + >>> test(0) + 0L + >>> test(1) + 1L + >>> 2**36 + 68719476736L + >>> test(2**36) + 0L + >>> test(2L**36) + 0L +""" + def test(k): cdef unsigned long m m = k diff --git a/tests/run/rodriguez_1.pyx b/tests/run/rodriguez_1.pyx index f8cd04d5..01838c31 100644 --- a/tests/run/rodriguez_1.pyx +++ b/tests/run/rodriguez_1.pyx @@ -1,3 +1,9 @@ +__doc__ = """ + >>> b = B() + >>> b.t + {1: ((1, 2, 3),), 2: (1, 2, 3)} +""" + class B: def __init__(self): self.t = { diff --git a/tests/run/simpcall.pyx b/tests/run/simpcall.pyx index db8ed964..0f93f69b 100644 --- a/tests/run/simpcall.pyx +++ b/tests/run/simpcall.pyx @@ -1,3 +1,18 @@ +__doc__ = """ + >>> z(1,9.2,'test') + >>> failtype() + Traceback (most recent call last): + TypeError: an integer is required + + >>> fail0(1,2) + Traceback (most recent call last): + TypeError: function takes exactly 2 arguments (0 given) + + >>> fail1(1,2) + Traceback (most recent call last): + TypeError: function takes exactly 2 arguments (1 given) +""" + def f(x, y): x = y @@ -8,11 +23,16 @@ cdef h(int i, obj): i = obj def z(a, b, c): - f() - f(a) f(a, b) f(a, b,) g(1, 2.0, "spam") g(a, b, c) + +def fail0(a, b): + f() + +def fail1(a, b): + f(a) + +def failtype(): h(42, "eggs") - \ No newline at end of file diff --git a/tests/run/slice2.pyx b/tests/run/slice2.pyx index 437dcaee..ffbd5155 100644 --- a/tests/run/slice2.pyx +++ b/tests/run/slice2.pyx @@ -1,5 +1,35 @@ +__doc__ = """ + >>> l = [1,2,3,4] + + >>> f(1, l, 2, 3) + [1, 2, 3, 4] + >>> l == f(1, l, 2, 3) + True + >>> l is f(1, l, 2, 3) + False + + >>> g(1, [1,2,3,4], 2, 3) + [3, 4] + + >>> h(1, [1,2,3,4], 2, 3) + [1, 2, 3] + + >>> j(1, [1,2,3,4], 2, 3) + [3] +""" + def f(obj1, obj2, obj3, obj4): obj1 = obj2[:] + return obj1 + +def g(obj1, obj2, obj3, obj4): obj1 = obj2[obj3:] + return obj1 + +def h(obj1, obj2, obj3, obj4): obj1 = obj2[:obj4] + return obj1 + +def j(obj1, obj2, obj3, obj4): obj1 = obj2[obj3:obj4] + return obj1 diff --git a/tests/run/strconstinclass.pyx b/tests/run/strconstinclass.pyx index 67e662e4..9088a168 100644 --- a/tests/run/strconstinclass.pyx +++ b/tests/run/strconstinclass.pyx @@ -1,3 +1,9 @@ +__doc__ = """ + >>> c = C() + >>> print c.x + foo +""" + class C: x = "foo" diff --git a/tests/run/tuple.pyx b/tests/run/tuple.pyx index 6ff23885..99eb05bb 100644 --- a/tests/run/tuple.pyx +++ b/tests/run/tuple.pyx @@ -1,7 +1,53 @@ +__doc__ = """ + >>> f(1,2,3,4,5) + () + >>> g(1,2,3,4,5) + (2,) + >>> h(1,2,3,4,5) + (2, 3) + >>> j(1,2,3,4,5) + (2, 3, 4) + >>> k(1,2,3,4,5) + (2, 3, 4) + >>> l(1,2,3,4,5) + (17, 42, 88) +""" + def f(obj1, obj2, obj3, obj4, obj5): + obj1 = () + return obj1 + +def g(obj1, obj2, obj3, obj4, obj5): + obj1 = () + obj1 = (obj2,) + return obj1 + +def h(obj1, obj2, obj3, obj4, obj5): + obj1 = () + obj1 = (obj2,) + obj1 = obj2, obj3 + return obj1 + +def j(obj1, obj2, obj3, obj4, obj5): + obj1 = () + obj1 = (obj2,) + obj1 = obj2, obj3 + obj1 = (obj2, obj3, obj4) + return obj1 + +def k(obj1, obj2, obj3, obj4, obj5): + obj1 = () + obj1 = (obj2,) + obj1 = obj2, obj3 + obj1 = (obj2, obj3, obj4) + obj1 = (obj2, obj3, obj4,) + return obj1 + +def l(obj1, obj2, obj3, obj4, obj5): obj1 = () obj1 = (obj2,) obj1 = obj2, obj3 obj1 = (obj2, obj3, obj4) obj1 = (obj2, obj3, obj4,) obj1 = 17, 42, 88 + return obj1 diff --git a/tests/run/unop.pyx b/tests/run/unop.pyx index 2311415f..1ea4f60a 100644 --- a/tests/run/unop.pyx +++ b/tests/run/unop.pyx @@ -1,7 +1,17 @@ +__doc__ = """ + >>> f(1, 2, 3) + (-3, -4, 1) +""" + def f(obj1, obj2, obj3): cdef int bool1, bool2 cdef int int1, int2 cdef char *str1 + + int2 = obj3 + str1 = NULL + bool2 = 0 + bool1 = not bool2 obj1 = not obj2 bool1 = not str1 @@ -11,4 +21,4 @@ def f(obj1, obj2, obj3): obj1 = -obj2 int1 = ~int2 obj1 = ~obj2 - \ No newline at end of file + return obj1, int1, bool1 diff --git a/tests/run/unpack.pyx b/tests/run/unpack.pyx index 3a7c3b8c..3bd36e1a 100644 --- a/tests/run/unpack.pyx +++ b/tests/run/unpack.pyx @@ -1,7 +1,12 @@ +__doc__ = """ + >>> f(1, (2,), (3,4,5), (6,(7,(8,9))), 0) + (8, 9, (8, 9), (6, (7, (8, 9))), 0) +""" + def f(obj1, obj2, obj3, obj4, obj5): obj1, = obj2 - obj1, = obj2 + obj3 + obj1, obj2 = obj2 + obj2 obj1, obj2, obj3 = obj3 obj1, (obj2, obj3) = obj4 [obj1, obj2] = obj3 - \ No newline at end of file + return obj1, obj2, obj3, obj4, obj5 -- 2.26.2