From: Stefan Behnel Date: Fri, 11 Jul 2008 13:50:12 +0000 (+0200) Subject: more tests from Pyrex X-Git-Tag: 0.9.8.1~123^2~17 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fbbe557488b7db1c8c37542c0abe3b3aac67321b;p=cython.git more tests from Pyrex --- diff --git a/tests/broken/assert2.pyx b/tests/broken/assert2.pyx new file mode 100644 index 00000000..f34c0964 --- /dev/null +++ b/tests/broken/assert2.pyx @@ -0,0 +1,2 @@ +def f(a, b): + assert a, a+b diff --git a/tests/broken/b_extimpinherit.pyx b/tests/broken/b_extimpinherit.pyx new file mode 100644 index 00000000..b775fdbf --- /dev/null +++ b/tests/broken/b_extimpinherit.pyx @@ -0,0 +1,7 @@ +cdef class Parrot: + + cdef describe(self): + print "This is a parrot." + + cdef action(self): + print "Polly wants a cracker!" diff --git a/tests/broken/big_t.pyx b/tests/broken/big_t.pyx new file mode 100644 index 00000000..5c4a6d97 --- /dev/null +++ b/tests/broken/big_t.pyx @@ -0,0 +1,5 @@ +cdef extern from "foo.h": + ctypedef long long big_t + cdef void spam(big_t b) + +spam(grail) diff --git a/tests/broken/builtinconst.pyx b/tests/broken/builtinconst.pyx new file mode 100644 index 00000000..614fa2f0 --- /dev/null +++ b/tests/broken/builtinconst.pyx @@ -0,0 +1,66 @@ +cdef int f() except -1: + cdef type t + cdef object x + t = buffer + t = enumerate + t = file + t = float + t = int + t = long + t = open + t = property + t = str + t = tuple + t = xrange + x = True + x = False + x = Ellipsis + x = Exception + x = StopIteration + x = StandardError + x = ArithmeticError + x = LookupError + x = AssertionError + x = AssertionError + x = EOFError + x = FloatingPointError + x = EnvironmentError + x = IOError + x = OSError + x = ImportError + x = IndexError + x = KeyError + x = KeyboardInterrupt + x = MemoryError + x = NameError + x = OverflowError + x = RuntimeError + x = NotImplementedError + x = SyntaxError + x = IndentationError + x = TabError + x = ReferenceError + x = SystemError + x = SystemExit + x = TypeError + x = UnboundLocalError + x = UnicodeError + x = UnicodeEncodeError + x = UnicodeDecodeError + x = UnicodeTranslateError + x = ValueError + x = ZeroDivisionError + x = MemoryErrorInst + x = Warning + x = UserWarning + x = DeprecationWarning + x = PendingDeprecationWarning + x = SyntaxWarning + #x = OverflowWarning # Does not seem to exist in 2.5 + x = RuntimeWarning + x = FutureWarning + typecheck(x, Exception) + try: + pass + except ValueError: + pass diff --git a/tests/broken/builtindict.pyx b/tests/broken/builtindict.pyx new file mode 100644 index 00000000..96649f81 --- /dev/null +++ b/tests/broken/builtindict.pyx @@ -0,0 +1,15 @@ +cdef int f() except -1: + cdef dict d + cdef object x, z + cdef int i + z = dict + d = dict(x) + d = dict(*x) + d.clear() + z = d.copy() + z = d.items() + z = d.keys() + z = d.values() + d.merge(x, i) + d.update(x) + d.merge_pairs(x, i) diff --git a/tests/broken/builtinlist.pyx b/tests/broken/builtinlist.pyx new file mode 100644 index 00000000..3ad59425 --- /dev/null +++ b/tests/broken/builtinlist.pyx @@ -0,0 +1,12 @@ +cdef int f() except -1: + cdef list l + cdef object x, y, z + z = list + l = list(x) + l = list(*y) + z = l.insert + l.insert(17, 42) + l.append(88) + l.sort() + l.reverse() + z = l.as_tuple() diff --git a/tests/broken/builtinslice.pyx b/tests/broken/builtinslice.pyx new file mode 100644 index 00000000..5b9d6342 --- /dev/null +++ b/tests/broken/builtinslice.pyx @@ -0,0 +1,10 @@ +cdef int f() except -1: + cdef slice s + cdef object z + cdef int i + z = slice + s = slice(1, 2, 3) + z = slice.indices() + i = s.start + i = s.stop + i = s.step diff --git a/tests/broken/builtintype.pyx b/tests/broken/builtintype.pyx new file mode 100644 index 00000000..523bf22c --- /dev/null +++ b/tests/broken/builtintype.pyx @@ -0,0 +1,6 @@ +cdef int f() except -1: + cdef type t1, t2 + cdef object x + cdef int b + b = typecheck(x, t1) + b = issubtype(t1, t2) diff --git a/tests/broken/cascadedass.pyx b/tests/broken/cascadedass.pyx new file mode 100644 index 00000000..1f9a7ead --- /dev/null +++ b/tests/broken/cascadedass.pyx @@ -0,0 +1,8 @@ +cdef void foo(): + cdef int i, j, k + i = j = k + a = b = c + i = j = c + a = b = k + (a, b), c = (d, e), f = (x, y), z +# a, b = p, q = x, y \ No newline at end of file diff --git a/tests/broken/cdefemptysue.pyx b/tests/broken/cdefemptysue.pyx new file mode 100644 index 00000000..326637b6 --- /dev/null +++ b/tests/broken/cdefemptysue.pyx @@ -0,0 +1,14 @@ +cdef extern from "cdefemptysue.h": + + cdef struct spam: + pass + + ctypedef union eggs: + pass + + cdef enum ham: + pass + +cdef extern spam s +cdef extern eggs e +cdef extern ham h diff --git a/tests/broken/cdefexternblock.pyx b/tests/broken/cdefexternblock.pyx new file mode 100644 index 00000000..4d613cd3 --- /dev/null +++ b/tests/broken/cdefexternblock.pyx @@ -0,0 +1,19 @@ +cdef extern from "cheese.h": + + ctypedef int camembert + + struct roquefort: + int x + + char *swiss + + void cheddar() + + class external.runny [object runny_obj]: + cdef int a + def __init__(self): + pass + +cdef runny r +r = x +r.a = 42 diff --git a/tests/broken/cdefexternempty.pyx b/tests/broken/cdefexternempty.pyx new file mode 100644 index 00000000..be4d65ca --- /dev/null +++ b/tests/broken/cdefexternempty.pyx @@ -0,0 +1,3 @@ +cdef extern from "cheese.h": + pass + diff --git a/tests/broken/cexportfunc.pyx b/tests/broken/cexportfunc.pyx new file mode 100644 index 00000000..b71338f6 --- /dev/null +++ b/tests/broken/cexportfunc.pyx @@ -0,0 +1,5 @@ +cdef int f(): + pass + +cdef char *g(int k, float z): + pass diff --git a/tests/broken/cimport.pyx b/tests/broken/cimport.pyx new file mode 100644 index 00000000..f0187257 --- /dev/null +++ b/tests/broken/cimport.pyx @@ -0,0 +1,10 @@ +cimport spam +cimport pkg.eggs + +cdef spam.Spam yummy +cdef pkg.eggs.Eggs fried + +spam.eat(yummy) +spam.tons = 3.14 +ova = pkg.eggs +fried = pkg.eggs.Eggs() diff --git a/tests/broken/cimportfrom.pyx b/tests/broken/cimportfrom.pyx new file mode 100644 index 00000000..16991b64 --- /dev/null +++ b/tests/broken/cimportfrom.pyx @@ -0,0 +1,7 @@ +from spam cimport Spam +from pkg.eggs cimport Eggs as ova + +cdef extern Spam yummy +cdef ova fried + +fried = None diff --git a/tests/broken/cimportfrompkgdir.pyx b/tests/broken/cimportfrompkgdir.pyx new file mode 100644 index 00000000..0ad32953 --- /dev/null +++ b/tests/broken/cimportfrompkgdir.pyx @@ -0,0 +1,3 @@ +from package.inpackage cimport Spam + +cdef Spam s2 diff --git a/tests/broken/cimportfunc.pyx b/tests/broken/cimportfunc.pyx new file mode 100644 index 00000000..4cc40ecd --- /dev/null +++ b/tests/broken/cimportfunc.pyx @@ -0,0 +1 @@ +from cexportfunc cimport f, g diff --git a/tests/broken/ctypedefextern.pyx b/tests/broken/ctypedefextern.pyx new file mode 100644 index 00000000..b323cbc2 --- /dev/null +++ b/tests/broken/ctypedefextern.pyx @@ -0,0 +1,9 @@ +cdef extern from "ctypedefextern.h": + + ctypedef int some_int + ctypedef some_int *some_ptr + +cdef void spam(): + cdef some_int i + cdef some_ptr p + p[0] = i diff --git a/tests/broken/e_exestmtinexttype.pyx b/tests/broken/e_exestmtinexttype.pyx new file mode 100644 index 00000000..f152e067 --- /dev/null +++ b/tests/broken/e_exestmtinexttype.pyx @@ -0,0 +1,2 @@ +cdef class Spam: + answer = 42 diff --git a/tests/broken/e_nogil.pyx b/tests/broken/e_nogil.pyx new file mode 100644 index 00000000..b79165f2 --- /dev/null +++ b/tests/broken/e_nogil.pyx @@ -0,0 +1,84 @@ +cdef object f(object x) nogil: + pass + +cdef void g(int x) nogil: + cdef object z + z = None + +cdef void h(int x) nogil: + p() + +cdef object p() nogil: + pass + +cdef void r() nogil: + q() + +cdef void (*fp)() +cdef void (*fq)() nogil +cdef extern void u() + +cdef object m(): + global fp, fq + cdef object x, y, obj + cdef int i, j, k + global fred + q() + with nogil: + r() + q() + i = 42 + obj = None + 17L + 7j + asdf + `"Hello"` + import fred + from fred import obj + for x in obj: + pass + obj[i] + obj[i:j] + obj[i:j:k] + obj.fred + (x, y) + [x, y] + {x: y} + obj and x + t(obj) + f(42) + x + obj + -obj + x = y = obj + x, y = y, x + obj[i] = x + obj.fred = x + print obj + del fred + return obj + raise obj + if obj: + pass + while obj: + pass + for x <= obj <= y: + pass + try: + pass + except: + pass + try: + pass + finally: + pass + fq = u + fq = fp + +cdef void q(): + pass + +cdef class C: + pass + +cdef void t(C c) nogil: + pass diff --git a/tests/broken/externfunc.pyx b/tests/broken/externfunc.pyx new file mode 100644 index 00000000..49263f67 --- /dev/null +++ b/tests/broken/externfunc.pyx @@ -0,0 +1,3 @@ +cdef extern from "foo.h": + + int fred() diff --git a/tests/broken/externsue.pyx b/tests/broken/externsue.pyx new file mode 100644 index 00000000..1ebc3602 --- /dev/null +++ b/tests/broken/externsue.pyx @@ -0,0 +1,21 @@ +cdef extern from "externsue.h": + + enum Eggs: + runny, firm, hard + + struct Spam: + int i + + union Soviet: + char c + +cdef extern Eggs e +cdef extern Spam s +cdef extern Soviet u + +cdef void tomato(): + global e + e = runny + e = firm + e = hard + diff --git a/tests/broken/fwddeclcclass.pyx b/tests/broken/fwddeclcclass.pyx new file mode 100644 index 00000000..f41f7b5a --- /dev/null +++ b/tests/broken/fwddeclcclass.pyx @@ -0,0 +1,9 @@ +cdef class Widget: + pass + +cdef class Container: + pass + +cdef Widget w +cdef Container c +w.parent = c diff --git a/tests/broken/getattr.pyx b/tests/broken/getattr.pyx new file mode 100644 index 00000000..5877a7af --- /dev/null +++ b/tests/broken/getattr.pyx @@ -0,0 +1,5 @@ +cdef class Spam: + cdef public object eggs + + def __getattr__(self, name): + print "Spam getattr:", name diff --git a/tests/broken/getattr3ref.pyx b/tests/broken/getattr3ref.pyx new file mode 100644 index 00000000..5fb4fdb9 --- /dev/null +++ b/tests/broken/getattr3ref.pyx @@ -0,0 +1,2 @@ +cdef int f() except -1: + g = getattr3 diff --git a/tests/broken/i_public.pyx b/tests/broken/i_public.pyx new file mode 100644 index 00000000..126a242f --- /dev/null +++ b/tests/broken/i_public.pyx @@ -0,0 +1,8 @@ +cdef public int grail + +cdef public spam(int servings): + pass + +cdef public class sandwich [object sandwich, type sandwich_Type]: + cdef int tomato + cdef float lettuce diff --git a/tests/broken/includepublic.pyx b/tests/broken/includepublic.pyx new file mode 100644 index 00000000..2232b9aa --- /dev/null +++ b/tests/broken/includepublic.pyx @@ -0,0 +1,2 @@ +include "i_public.pxi" + diff --git a/tests/broken/inplace_lhs.pyx b/tests/broken/inplace_lhs.pyx new file mode 100644 index 00000000..21bddccc --- /dev/null +++ b/tests/broken/inplace_lhs.pyx @@ -0,0 +1,24 @@ +cdef struct S: + int q + +cdef int f() except -1: + cdef int i, j, k + cdef float x, y, z + cdef object a, b, c, d, e + cdef int m[3] + cdef S s + global g + i += j + k + x += y + z + x += i + a += b + c + g += a + m[i] += j + a[i] += b + c + a[b + c] += d + (a + b)[c] += d + a[i : j] += b + (a + b)[i : j] += c + a.b += c + d + (a + b).c += d + s.q += i diff --git a/tests/broken/inplace_ops.pyx b/tests/broken/inplace_ops.pyx new file mode 100644 index 00000000..4a34c63f --- /dev/null +++ b/tests/broken/inplace_ops.pyx @@ -0,0 +1,17 @@ +cdef int f() except -1: + cdef object a, b + cdef char *p + a += b + a -= b + a *= b + a /= b + a %= b + a **= b + a <<= b + a >>= b + a &= b + a ^= b + a |= b + p += 42 + p -= 42 + p += a diff --git a/tests/broken/intindex.pyx b/tests/broken/intindex.pyx new file mode 100644 index 00000000..120133d7 --- /dev/null +++ b/tests/broken/intindex.pyx @@ -0,0 +1,10 @@ +cdef int f() except -1: + cdef object x, y, z + cdef int i + cdef unsigned int ui + z = x[y] + z = x[i] + x[y] = z + x[i] = z + z = x[ui] + x[ui] = z diff --git a/tests/broken/invalid-module-name.pyx b/tests/broken/invalid-module-name.pyx new file mode 100644 index 00000000..e69de29b diff --git a/tests/broken/l_capi.pyx b/tests/broken/l_capi.pyx new file mode 100644 index 00000000..9c139031 --- /dev/null +++ b/tests/broken/l_capi.pyx @@ -0,0 +1,2 @@ +cdef api float f(float x): + return 0.5 * x * x diff --git a/tests/broken/l_cfuncexport.pyx b/tests/broken/l_cfuncexport.pyx new file mode 100644 index 00000000..a901f48f --- /dev/null +++ b/tests/broken/l_cfuncexport.pyx @@ -0,0 +1,5 @@ +cdef int f(int x): + return x * x + +cdef int g(int x): + return 5 * x diff --git a/tests/broken/naanou_1.pyx b/tests/broken/naanou_1.pyx new file mode 100644 index 00000000..d79ad652 --- /dev/null +++ b/tests/broken/naanou_1.pyx @@ -0,0 +1,2 @@ +def f(a, *p, **n): + pass diff --git a/tests/broken/newstyleintforloop.pyx b/tests/broken/newstyleintforloop.pyx new file mode 100644 index 00000000..d1bfad3a --- /dev/null +++ b/tests/broken/newstyleintforloop.pyx @@ -0,0 +1,4 @@ +cdef int f() except -1: + cdef int i, x, y + for x < i < y: + pass diff --git a/tests/broken/oldstyleintforloop.pyx b/tests/broken/oldstyleintforloop.pyx new file mode 100644 index 00000000..9081411b --- /dev/null +++ b/tests/broken/oldstyleintforloop.pyx @@ -0,0 +1,4 @@ +cdef int f() except -1: + cdef int i, x, y + for i from x < i < y: + pass diff --git a/tests/broken/pkg.cimport.pyx b/tests/broken/pkg.cimport.pyx new file mode 100644 index 00000000..7864e193 --- /dev/null +++ b/tests/broken/pkg.cimport.pyx @@ -0,0 +1,6 @@ +cimport spam, eggs + +cdef extern spam.Spam yummy +cdef eggs.Eggs fried + +fried = None diff --git a/tests/broken/pkg.cimportfrom.pyx b/tests/broken/pkg.cimportfrom.pyx new file mode 100644 index 00000000..fce7be1a --- /dev/null +++ b/tests/broken/pkg.cimportfrom.pyx @@ -0,0 +1,7 @@ +from spam cimport Spam +from eggs cimport Eggs + +cdef extern Spam yummy +cdef Eggs fried + +fried = None diff --git a/tests/broken/r_builtinlist.pyx b/tests/broken/r_builtinlist.pyx new file mode 100644 index 00000000..3fa2a210 --- /dev/null +++ b/tests/broken/r_builtinlist.pyx @@ -0,0 +1,6 @@ +def f(): + cdef list l + l = list() + l.append("second") + l.insert(0, "first") + return l diff --git a/tests/broken/r_capi.pyx b/tests/broken/r_capi.pyx new file mode 100644 index 00000000..70628348 --- /dev/null +++ b/tests/broken/r_capi.pyx @@ -0,0 +1,8 @@ +cdef extern from "l_capi_api.h": + float f(float) + int import_l_capi() except -1 + +def test(): + print f(3.1415) + +import_l_capi() diff --git a/tests/broken/r_cfuncimport.pyx b/tests/broken/r_cfuncimport.pyx new file mode 100644 index 00000000..5ee1a82c --- /dev/null +++ b/tests/broken/r_cfuncimport.pyx @@ -0,0 +1,5 @@ +cimport l_cfuncexport +from l_cfuncexport cimport g + +print l_cfuncexport.f(42) +print g(42) diff --git a/tests/broken/r_classdoc.pyx b/tests/broken/r_classdoc.pyx new file mode 100644 index 00000000..e4b48cf5 --- /dev/null +++ b/tests/broken/r_classdoc.pyx @@ -0,0 +1,3 @@ +class Spam: + """Spam, glorious spam!""" + diff --git a/tests/broken/r_classmodname.pyx b/tests/broken/r_classmodname.pyx new file mode 100644 index 00000000..7e75c6fd --- /dev/null +++ b/tests/broken/r_classmodname.pyx @@ -0,0 +1,2 @@ +class Spam: + pass diff --git a/tests/broken/r_excval.pyx b/tests/broken/r_excval.pyx new file mode 100644 index 00000000..bb1982f0 --- /dev/null +++ b/tests/broken/r_excval.pyx @@ -0,0 +1,19 @@ +cdef int tomato() except -1: + print "Entering tomato" + raise Exception("Eject! Eject! Eject!") + print "Leaving tomato" + +cdef void sandwich(): + print "Entering sandwich" + tomato() + print "Leaving sandwich" + +def snack(): + print "Entering snack" + tomato() + print "Leaving snack" + +def lunch(): + print "Entering lunch" + sandwich() + print "Leaving lunch" diff --git a/tests/broken/r_extcmethod.pyx b/tests/broken/r_extcmethod.pyx new file mode 100644 index 00000000..cf2fe8fc --- /dev/null +++ b/tests/broken/r_extcmethod.pyx @@ -0,0 +1,28 @@ +cdef class SpamDish: + cdef int spam + + cdef void describe(self): + print "This dish contains", self.spam, "tons of spam." + + +cdef class FancySpamDish(SpamDish): + cdef int lettuce + + cdef void describe(self): + print "This dish contains", self.spam, "tons of spam", + print "and", self.lettuce, "milligrams of lettuce." + + +cdef void describe_dish(SpamDish d): + d.describe() + +def test(): + cdef SpamDish s + cdef FancySpamDish ss + s = SpamDish() + s.spam = 42 + ss = FancySpamDish() + ss.spam = 88 + ss.lettuce = 5 + describe_dish(s) + describe_dish(ss) diff --git a/tests/broken/r_extimpinherit.pyx b/tests/broken/r_extimpinherit.pyx new file mode 100644 index 00000000..b454d99c --- /dev/null +++ b/tests/broken/r_extimpinherit.pyx @@ -0,0 +1,24 @@ +from b_extimpinherit cimport Parrot + + +cdef class Norwegian(Parrot): + + cdef action(self): + print "This parrot is resting." + + cdef plumage(self): + print "Lovely plumage!" + + +def main(): + cdef Parrot p + cdef Norwegian n + p = Parrot() + n = Norwegian() + print "Parrot:" + p.describe() + p.action() + print "Norwegian:" + n.describe() + n.action() + n.plumage() diff --git a/tests/broken/r_extinherit.pyx b/tests/broken/r_extinherit.pyx new file mode 100644 index 00000000..804e2414 --- /dev/null +++ b/tests/broken/r_extinherit.pyx @@ -0,0 +1,16 @@ +cdef class Parrot: + + cdef object plumage + + def __init__(self): + self.plumage = "yellow" + + def describe(self): + print "This bird has lovely", self.plumage, "plumage." + + +cdef class Norwegian(Parrot): + + def __init__(self): + self.plumage = "blue" + diff --git a/tests/broken/r_extmember.pyx b/tests/broken/r_extmember.pyx new file mode 100644 index 00000000..71088fd9 --- /dev/null +++ b/tests/broken/r_extmember.pyx @@ -0,0 +1,12 @@ +cdef class Spam: + cdef public int tons + cdef readonly float tastiness + cdef int temperature + + def __init__(self, tons, tastiness, temperature): + self.tons = tons + self.tastiness = tastiness + self.temperature = temperature + + def get_temperature(self): + return self.temperature diff --git a/tests/broken/r_extnumeric2.pyx b/tests/broken/r_extnumeric2.pyx new file mode 100644 index 00000000..3dd6d421 --- /dev/null +++ b/tests/broken/r_extnumeric2.pyx @@ -0,0 +1,22 @@ +cdef extern from "numeric.h": + + struct PyArray_Descr: + int type_num, elsize + char type + + ctypedef class Numeric.ArrayType [object PyArrayObject]: + cdef char *data + cdef int nd + cdef int *dimensions, *strides + cdef object base + cdef PyArray_Descr *descr + cdef int flags + +def ogle(ArrayType a): + print "No. of dimensions:", a.nd + print " Dim Value" + for i in range(a.nd): + print "%5d %5d" % (i, a.dimensions[i]) + print "flags:", a.flags + print "Type no.", a.descr.type_num + print "Element size:", a.descr.elsize diff --git a/tests/broken/r_extproperty.pyx b/tests/broken/r_extproperty.pyx new file mode 100644 index 00000000..d575fe98 --- /dev/null +++ b/tests/broken/r_extproperty.pyx @@ -0,0 +1,18 @@ +cdef class CheeseShop: + cdef object cheeses + + def __cinit__(self): + self.cheeses = [] + + property cheese: + + "A senseless waste of a property." + + def __get__(self): + return "We don't have: %s" % self.cheeses + + def __set__(self, value): + self.cheeses.append(value) + + def __del__(self): + del self.cheeses[:] diff --git a/tests/broken/r_extweakref.pyx b/tests/broken/r_extweakref.pyx new file mode 100644 index 00000000..6b6c736d --- /dev/null +++ b/tests/broken/r_extweakref.pyx @@ -0,0 +1,3 @@ +cdef class Animal: + cdef object __weakref__ + cdef public object name diff --git a/tests/broken/r_getattr3.pyx b/tests/broken/r_getattr3.pyx new file mode 100644 index 00000000..91544e24 --- /dev/null +++ b/tests/broken/r_getattr3.pyx @@ -0,0 +1,2 @@ +def test(obj, attr, dflt): + return getattr3(obj, attr, dflt) diff --git a/tests/broken/r_import.pyx b/tests/broken/r_import.pyx new file mode 100644 index 00000000..3840912f --- /dev/null +++ b/tests/broken/r_import.pyx @@ -0,0 +1,8 @@ +import spam +print "Imported spam" +print dir(spam) + +import sys +print "Imported sys" +print sys + diff --git a/tests/broken/r_inhcmethcall.pyx b/tests/broken/r_inhcmethcall.pyx new file mode 100644 index 00000000..181e72a3 --- /dev/null +++ b/tests/broken/r_inhcmethcall.pyx @@ -0,0 +1,18 @@ +cdef class Parrot: + + cdef void describe(self): + print "This parrot is resting." + + +cdef class Norwegian(Parrot): + + cdef void describe(self): + Parrot.describe(self) + print "Lovely plumage!" + + +cdef Parrot p1, p2 +p1 = Parrot() +p2 = Norwegian() +p1.describe() +p2.describe() diff --git a/tests/broken/r_kwonlyargs.pyx b/tests/broken/r_kwonlyargs.pyx new file mode 100644 index 00000000..f13bed3d --- /dev/null +++ b/tests/broken/r_kwonlyargs.pyx @@ -0,0 +1,25 @@ +def pd(d): + l = [] + i = d.items() + i.sort() + for kv in i: + l.append("%r: %r" % kv) + return "{%s}" % ", ".join(l) + +def c(a, b, c): + print "a =", a, "b =", b, "c =", c + +def d(a, b, *, c = 88): + print "a =", a, "b =", b, "c =", c + +def e(a, b, c = 88, **kwds): + print "a =", a, "b =", b, "c =", c, "kwds =", pd(kwds) + +def f(a, b, *, c, d = 42): + print "a =", a, "b =", b, "c =", c, "d =", d + +def g(a, b, *, c, d = 42, e = 17, f, **kwds): + print "a =", a, "b =", b, "c =", c, "d =", d, "e =", e, "f =", f, "kwds =", pd(kwds) + +def h(a, b, *args, c, d = 42, e = 17, f, **kwds): + print "a =", a, "b =", b, "args =", args, "c =", c, "d =", d, "e =", e, "f =", f, "kwds =", pd(kwds) diff --git a/tests/broken/r_newstyleclass.pyx b/tests/broken/r_newstyleclass.pyx new file mode 100644 index 00000000..e1a155f4 --- /dev/null +++ b/tests/broken/r_newstyleclass.pyx @@ -0,0 +1,5 @@ +class Inquisition(object): + """Something that nobody expects.""" + + def __repr__(self): + return "Surprise!" diff --git a/tests/broken/r_simpcall.pyx b/tests/broken/r_simpcall.pyx new file mode 100644 index 00000000..5793be26 --- /dev/null +++ b/tests/broken/r_simpcall.pyx @@ -0,0 +1,4 @@ +def f(): + print "Spam!" + +f() diff --git a/tests/broken/r_tbfilename.pyx b/tests/broken/r_tbfilename.pyx new file mode 100644 index 00000000..28d04648 --- /dev/null +++ b/tests/broken/r_tbfilename.pyx @@ -0,0 +1,2 @@ +def foo(): + raise Exception diff --git a/tests/broken/r_traceback.pyx b/tests/broken/r_traceback.pyx new file mode 100644 index 00000000..fb85e8a1 --- /dev/null +++ b/tests/broken/r_traceback.pyx @@ -0,0 +1,9 @@ +cdef int spam() except -1: + raise Exception("Spam error") + +cdef int grail() except -1: + spam() + +def tomato(): + grail() + diff --git a/tests/broken/r_unpack.pyx b/tests/broken/r_unpack.pyx new file mode 100644 index 00000000..a51ea6d4 --- /dev/null +++ b/tests/broken/r_unpack.pyx @@ -0,0 +1,13 @@ +seq = [1, [2, 3]] + +def f(): + a, (b, c) = [1, [2, 3]] + print a + print b + print c + +def g(): + a, b, c = seq + +def h(): + a, = seq diff --git a/tests/broken/retconvert.pyx b/tests/broken/retconvert.pyx new file mode 100644 index 00000000..c47895f2 --- /dev/null +++ b/tests/broken/retconvert.pyx @@ -0,0 +1,6 @@ +def f(): + return 42 + +cdef int g(): + cdef object x + return x diff --git a/tests/broken/specialfloatvals.pyx b/tests/broken/specialfloatvals.pyx new file mode 100644 index 00000000..4ad4ddf0 --- /dev/null +++ b/tests/broken/specialfloatvals.pyx @@ -0,0 +1,9 @@ +DEF nan = float('nan') +DEF inf = float('inf') +DEF minf = -float('inf') + +cdef int f() except -1: + cdef float x, y, z + x = nan + y = inf + z = minf diff --git a/tests/broken/test_include_options.pyx b/tests/broken/test_include_options.pyx new file mode 100644 index 00000000..a83ea75b --- /dev/null +++ b/tests/broken/test_include_options.pyx @@ -0,0 +1,5 @@ +import sys +from Pyrex.Compiler.Main import main + +sys.argv[1:] = "-I spam -Ieggs --include-dir ham".split() +main(command_line = 1) diff --git a/tests/broken/tslots.pyx b/tests/broken/tslots.pyx new file mode 100644 index 00000000..0ad1301b --- /dev/null +++ b/tests/broken/tslots.pyx @@ -0,0 +1,5 @@ +cdef class Spam: + pass + +def probe(): + pass diff --git a/tests/broken/typeofexttype.pyx b/tests/broken/typeofexttype.pyx new file mode 100644 index 00000000..bd13a7b6 --- /dev/null +++ b/tests/broken/typeofexttype.pyx @@ -0,0 +1,6 @@ +cdef class Spam: + pass + +cdef int f() except -1: + cdef type t + t = Spam diff --git a/tests/broken/voidstarcast.pyx b/tests/broken/voidstarcast.pyx new file mode 100644 index 00000000..ea66be00 --- /dev/null +++ b/tests/broken/voidstarcast.pyx @@ -0,0 +1,12 @@ +cdef class C: + cdef int i + +cdef int f() except -1: + cdef object x + cdef void *p + cdef int i + x = p + p = x + x = (p).foo + i = (p).i + (p).i = i