collection of regression tests (based on Greg's test suite)
authorStefan Behnel <scoder@users.berlios.de>
Mon, 31 Dec 2007 14:44:11 +0000 (15:44 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 31 Dec 2007 14:44:11 +0000 (15:44 +0100)
270 files changed:
Makefile
runtests.py [new file with mode: 0644]
tests/broken/anonymousenum.pyx [new file with mode: 0644]
tests/broken/arraytoptrarg.pyx [new file with mode: 0644]
tests/broken/ass2cglobal.pyx [new file with mode: 0644]
tests/broken/ass2longlong.pyx [new file with mode: 0644]
tests/broken/builtinfuncs.pyx [new file with mode: 0644]
tests/broken/cascmp.pyx [new file with mode: 0644]
tests/broken/cassign.pyx [new file with mode: 0644]
tests/broken/casttoexttype.pyx [new file with mode: 0644]
tests/broken/cnamespec.pyx [new file with mode: 0644]
tests/broken/cnumop.pyx [new file with mode: 0644]
tests/broken/cstringmeth.pyx [new file with mode: 0644]
tests/broken/ct_IF.pyx [new file with mode: 0644]
tests/broken/cunsignedlong.pyx [new file with mode: 0644]
tests/broken/del.pyx [new file with mode: 0644]
tests/broken/delslice.pyx [new file with mode: 0644]
tests/broken/drake1.pyx [new file with mode: 0644]
tests/broken/eqcmp.pyx [new file with mode: 0644]
tests/broken/ewing1.pyx [new file with mode: 0644]
tests/broken/ewing5.pyx [new file with mode: 0644]
tests/broken/excvalcheck.pyx [new file with mode: 0644]
tests/broken/excvalreturn.pyx [new file with mode: 0644]
tests/broken/extcmethod.pyx [new file with mode: 0644]
tests/broken/extcoerce.pyx [new file with mode: 0644]
tests/broken/extdescrdel.pyx [new file with mode: 0644]
tests/broken/extdescrget.pyx [new file with mode: 0644]
tests/broken/extdescrset.pyx [new file with mode: 0644]
tests/broken/extexttype.pyx [new file with mode: 0644]
tests/broken/extgetitem.pyx [new file with mode: 0644]
tests/broken/extpropertyall.pyx [new file with mode: 0644]
tests/broken/extpropertyref.pyx [new file with mode: 0644]
tests/broken/extpymemberdef.pyx [new file with mode: 0644]
tests/broken/forfromelse.pyx [new file with mode: 0644]
tests/broken/gencall.pyx [new file with mode: 0644]
tests/broken/getattr3call.pyx [new file with mode: 0644]
tests/broken/globalstmt.pyx [new file with mode: 0644]
tests/broken/gustafsson2.pyx [new file with mode: 0644]
tests/broken/index.pyx [new file with mode: 0644]
tests/broken/inhcmethcall.pyx [new file with mode: 0644]
tests/broken/jiba5.pyx [new file with mode: 0644]
tests/broken/jiba6.pyx [new file with mode: 0644]
tests/broken/johnson1.pyx [new file with mode: 0644]
tests/broken/king1.pyx [new file with mode: 0644]
tests/broken/magcmp.pyx [new file with mode: 0644]
tests/broken/menten1.pyx [new file with mode: 0644]
tests/broken/none.pyx [new file with mode: 0644]
tests/broken/nononetypecheck.pyx [new file with mode: 0644]
tests/broken/notnonearg.pyx [new file with mode: 0644]
tests/broken/onelinesuite.pyx [new file with mode: 0644]
tests/broken/plex2.pyx [new file with mode: 0644]
tests/broken/powop.pyx [new file with mode: 0644]
tests/broken/r_pernici1.pyx [new file with mode: 0644]
tests/broken/raise.pyx [new file with mode: 0644]
tests/broken/ref2global.pyx [new file with mode: 0644]
tests/broken/slicex.pyx [new file with mode: 0644]
tests/broken/tandemstats.pyx [new file with mode: 0644]
tests/broken/traceback.pyx [new file with mode: 0644]
tests/broken/tryexceptelse.pyx [new file with mode: 0644]
tests/broken/watts1.pyx [new file with mode: 0644]
tests/broken/watts2.pyx [new file with mode: 0644]
tests/compile/a_capi.pyx [new file with mode: 0644]
tests/compile/altet1.h [new file with mode: 0644]
tests/compile/altet1.pyx [new file with mode: 0644]
tests/compile/argdefault.pyx [new file with mode: 0644]
tests/compile/arrayptrcompat.pyx [new file with mode: 0644]
tests/compile/behnel4.pyx [new file with mode: 0644]
tests/compile/belchenko1.pyx [new file with mode: 0644]
tests/compile/belchenko2.h [new file with mode: 0644]
tests/compile/belchenko2.pyx [new file with mode: 0644]
tests/compile/builtin.pyx [new file with mode: 0644]
tests/compile/burton1.pyx [new file with mode: 0644]
tests/compile/callingconvention.pyx [new file with mode: 0644]
tests/compile/cargdef.pyx [new file with mode: 0644]
tests/compile/cdefexternfromstar.pyx [new file with mode: 0644]
tests/compile/cenum.pyx [new file with mode: 0644]
tests/compile/cforfromloop.pyx [new file with mode: 0644]
tests/compile/classmethargdefault.pyx [new file with mode: 0644]
tests/compile/coercearraytoptr.pyx [new file with mode: 0644]
tests/compile/coercetovoidptr.pyx [new file with mode: 0644]
tests/compile/complexbasetype.pyx [new file with mode: 0644]
tests/compile/constexpr.pyx [new file with mode: 0644]
tests/compile/coventry1.pyx [new file with mode: 0644]
tests/compile/cstructreturn.pyx [new file with mode: 0644]
tests/compile/ct_DEF.pyx [new file with mode: 0644]
tests/compile/ctypedef.pyx [new file with mode: 0644]
tests/compile/ctypedefclass.pyx [new file with mode: 0644]
tests/compile/ctypedefenum.pyx [new file with mode: 0644]
tests/compile/ctypedefstruct.pyx [new file with mode: 0644]
tests/compile/ctypedefunion.pyx [new file with mode: 0644]
tests/compile/cverylongtypes.pyx [new file with mode: 0644]
tests/compile/declandimpl.pxd [new file with mode: 0644]
tests/compile/declandimpl.pyx [new file with mode: 0644]
tests/compile/declarations.pyx [new file with mode: 0644]
tests/compile/doda1.pyx [new file with mode: 0644]
tests/compile/emptytry.pyx [new file with mode: 0644]
tests/compile/enumintcompat.pyx [new file with mode: 0644]
tests/compile/ewing3.pyx [new file with mode: 0644]
tests/compile/ewing4.pyx [new file with mode: 0644]
tests/compile/ewing6.pyx [new file with mode: 0644]
tests/compile/ewing7.pyx [new file with mode: 0644]
tests/compile/ewing8.pxd [new file with mode: 0644]
tests/compile/ewing8.pyx [new file with mode: 0644]
tests/compile/ewing9.pxd [new file with mode: 0644]
tests/compile/ewing9.pyx [new file with mode: 0644]
tests/compile/excvaldecl.pyx [new file with mode: 0644]
tests/compile/extargdefault.pyx [new file with mode: 0644]
tests/compile/extcmethcall.pyx [new file with mode: 0644]
tests/compile/extdelattr.pyx [new file with mode: 0644]
tests/compile/extdelitem.pyx [new file with mode: 0644]
tests/compile/extdelslice.pyx [new file with mode: 0644]
tests/compile/extern.pyx [new file with mode: 0644]
tests/compile/extforward.pyx [new file with mode: 0644]
tests/compile/extgetattr.pyx [new file with mode: 0644]
tests/compile/exthash.pyx [new file with mode: 0644]
tests/compile/extimported.pyx [new file with mode: 0644]
tests/compile/extindex.pyx [new file with mode: 0644]
tests/compile/extinheritdel.pyx [new file with mode: 0644]
tests/compile/extinheritset.pyx [new file with mode: 0644]
tests/compile/extpropertydel.pyx [new file with mode: 0644]
tests/compile/extpropertydoc.pyx [new file with mode: 0644]
tests/compile/extpropertyget.pyx [new file with mode: 0644]
tests/compile/extpropertyset.pyx [new file with mode: 0644]
tests/compile/extsetattr.pyx [new file with mode: 0644]
tests/compile/extsetitem.pyx [new file with mode: 0644]
tests/compile/extsetslice.pyx [new file with mode: 0644]
tests/compile/for.pyx [new file with mode: 0644]
tests/compile/formfeed.pyx [new file with mode: 0644]
tests/compile/fromimport.pyx [new file with mode: 0644]
tests/compile/funcptr.pyx [new file with mode: 0644]
tests/compile/getattr3ref.pyx [new file with mode: 0644]
tests/compile/globalonly.pyx [new file with mode: 0644]
tests/compile/globvardef.pyx [new file with mode: 0644]
tests/compile/hinsen1.h [new file with mode: 0644]
tests/compile/hinsen1.pyx [new file with mode: 0644]
tests/compile/hinsen2.pyx [new file with mode: 0644]
tests/compile/huss2.pyx [new file with mode: 0644]
tests/compile/ia_cdefblock.pyx [new file with mode: 0644]
tests/compile/import.pyx [new file with mode: 0644]
tests/compile/ishimoto1.pyx [new file with mode: 0644]
tests/compile/ishimoto4.pyx [new file with mode: 0644]
tests/compile/jiba3.pyx [new file with mode: 0644]
tests/compile/jiba4.pyx [new file with mode: 0644]
tests/compile/johnson2.pyx [new file with mode: 0644]
tests/compile/khavkine1.pyx [new file with mode: 0644]
tests/compile/kleckner1.pyx [new file with mode: 0644]
tests/compile/lepage_2.pyx [new file with mode: 0644]
tests/compile/longunsigned.pyx [new file with mode: 0644]
tests/compile/nogil.pyx [new file with mode: 0644]
tests/compile/nonctypedefclass.pyx [new file with mode: 0644]
tests/compile/nullptr.pyx [new file with mode: 0644]
tests/compile/omittedargnames.pyx [new file with mode: 0644]
tests/compile/pinard4.pyx [new file with mode: 0644]
tests/compile/pyclass.pyx [new file with mode: 0644]
tests/compile/signedtypes.pyx [new file with mode: 0644]
tests/compile/specmethargdefault.pyx [new file with mode: 0644]
tests/compile/specmethdocstring.pyx [new file with mode: 0644]
tests/compile/specmethextarg.pyx [new file with mode: 0644]
tests/compile/tryexcept.pyx [new file with mode: 0644]
tests/compile/tryfinally.pyx [new file with mode: 0644]
tests/compile/typecast.pyx [new file with mode: 0644]
tests/compile/varargdecl.pyx [new file with mode: 0644]
tests/compile/while.pyx [new file with mode: 0644]
tests/compile/withgil.pyx [new file with mode: 0644]
tests/compile/withnogil.pyx [new file with mode: 0644]
tests/run/addop.pyx [new file with mode: 0644]
tests/run/addressof.pyx [new file with mode: 0644]
tests/run/altet2.pyx [new file with mode: 0644]
tests/run/ass2global.pyx [new file with mode: 0644]
tests/run/ass2local.pyx [new file with mode: 0644]
tests/run/assert.pyx [new file with mode: 0644]
tests/run/attr.pyx [new file with mode: 0644]
tests/run/baas3.pyx [new file with mode: 0644]
tests/run/backquote.pyx [new file with mode: 0644]
tests/run/behnel1.pyx [new file with mode: 0644]
tests/run/behnel2.pyx [new file with mode: 0644]
tests/run/behnel3.pyx [new file with mode: 0644]
tests/run/bishop1.pyx [new file with mode: 0644]
tests/run/bishop2.pyx [new file with mode: 0644]
tests/run/boolop.pyx [new file with mode: 0644]
tests/run/cfuncdef.pyx [new file with mode: 0644]
tests/run/cintop.pyx [new file with mode: 0644]
tests/run/classpass.pyx [new file with mode: 0644]
tests/run/concatcstrings.pyx [new file with mode: 0644]
tests/run/cstringmul.pyx [new file with mode: 0644]
tests/run/cstruct.pyx [new file with mode: 0644]
tests/run/cunion.pyx [new file with mode: 0644]
tests/run/cvardef.pyx [new file with mode: 0644]
tests/run/dict.pyx [new file with mode: 0644]
tests/run/dietachmayer1.pyx [new file with mode: 0644]
tests/run/docstrings.pyx [new file with mode: 0644]
tests/run/exarkun.pyx [new file with mode: 0644]
tests/run/extclasspass.pyx [new file with mode: 0644]
tests/run/extinherit.pyx [new file with mode: 0644]
tests/run/extinstantiate.pyx [new file with mode: 0644]
tests/run/extlen.pyx [new file with mode: 0644]
tests/run/extstarargs.pyx [new file with mode: 0644]
tests/run/exttype.pyx [new file with mode: 0644]
tests/run/filenames.pxi [new file with mode: 0644]
tests/run/filenames.pyx [new file with mode: 0644]
tests/run/if.pyx [new file with mode: 0644]
tests/run/ishimoto2.pyx [new file with mode: 0644]
tests/run/ishimoto3.pyx [new file with mode: 0644]
tests/run/jarausch1.pyx [new file with mode: 0644]
tests/run/kostyrka.pyx [new file with mode: 0644]
tests/run/kostyrka2.pyx [new file with mode: 0644]
tests/run/kwonlyargs.pyx [new file with mode: 0644]
tests/run/lepage_1.pyx [new file with mode: 0644]
tests/run/list.pyx [new file with mode: 0644]
tests/run/literals.pyx [new file with mode: 0644]
tests/run/modbody.pyx [new file with mode: 0644]
tests/run/modop.pyx [new file with mode: 0644]
tests/run/multass.pyx [new file with mode: 0644]
tests/run/naanou_1.pyx [new file with mode: 0644]
tests/run/new_style_exceptions.pyx [new file with mode: 0644]
tests/run/pass.pyx [new file with mode: 0644]
tests/run/pinard5.pyx [new file with mode: 0644]
tests/run/pinard6.pyx [new file with mode: 0644]
tests/run/pinard7.pyx [new file with mode: 0644]
tests/run/pinard8.pyx [new file with mode: 0644]
tests/run/print.pyx [new file with mode: 0644]
tests/run/pycmp.pyx [new file with mode: 0644]
tests/run/pyextattrref.pyx [new file with mode: 0644]
tests/run/pyintop.pyx [new file with mode: 0644]
tests/run/pynumop.pyx [new file with mode: 0644]
tests/run/r_addint.pyx [new file with mode: 0644]
tests/run/r_argdefault.pyx [new file with mode: 0644]
tests/run/r_barbieri1.pyx [new file with mode: 0644]
tests/run/r_bishop3.pyx [new file with mode: 0644]
tests/run/r_bowden1.pyx [new file with mode: 0644]
tests/run/r_delgado_1.pyx [new file with mode: 0644]
tests/run/r_docstrings.pyx [new file with mode: 0644]
tests/run/r_extcomplex2.pyx [new file with mode: 0644]
tests/run/r_extstarargs.pyx [new file with mode: 0644]
tests/run/r_forloop.pyx [new file with mode: 0644]
tests/run/r_hordijk1.pyx [new file with mode: 0644]
tests/run/r_huss3.pyx [new file with mode: 0644]
tests/run/r_jeff_epler_1.pyx [new file with mode: 0644]
tests/run/r_jiba1.pxd [new file with mode: 0644]
tests/run/r_jiba1.pyx [new file with mode: 0644]
tests/run/r_lepage_3.pyx [new file with mode: 0644]
tests/run/r_mang1.pyx [new file with mode: 0644]
tests/run/r_mcintyre1.pyx [new file with mode: 0644]
tests/run/r_mitch_chapman_2.pyx [new file with mode: 0644]
tests/run/r_primes.pyx [new file with mode: 0644]
tests/run/r_print.pyx [new file with mode: 0644]
tests/run/r_pyclass.pyx [new file with mode: 0644]
tests/run/r_pyclassdefault.pyx [new file with mode: 0644]
tests/run/r_pythonapi.pyx [new file with mode: 0644]
tests/run/r_spamtype.pyx [new file with mode: 0644]
tests/run/r_starargcall.pyx [new file with mode: 0644]
tests/run/r_starargs.pyx [new file with mode: 0644]
tests/run/r_starargsonly.pyx [new file with mode: 0644]
tests/run/r_toofewargs.pyx [new file with mode: 0644]
tests/run/r_vree_1.pyx [new file with mode: 0644]
tests/run/ref2local.pyx [new file with mode: 0644]
tests/run/return.pyx [new file with mode: 0644]
tests/run/rodriguez_1.pyx [new file with mode: 0644]
tests/run/simpcall.pyx [new file with mode: 0644]
tests/run/sizeof.pyx [new file with mode: 0644]
tests/run/slice2.pyx [new file with mode: 0644]
tests/run/slice3.pyx [new file with mode: 0644]
tests/run/starargs.pyx [new file with mode: 0644]
tests/run/strconstinclass.pyx [new file with mode: 0644]
tests/run/subop.pyx [new file with mode: 0644]
tests/run/tuple.pyx [new file with mode: 0644]
tests/run/unop.pyx [new file with mode: 0644]
tests/run/unpack.pyx [new file with mode: 0644]
tests/run/varargcall.pyx [new file with mode: 0644]
tests/run/wundram1.pyx [new file with mode: 0644]

index 1ac8bc527c6132c7c32a8b326adc73d7ed111c06..73a57dd4e9dd5b0353bc9521823b5cfba696177a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
 VERSION = 0.9.6.3
+PYTHON?=python
 
 version:
        @echo "Setting version to $(VERSION)"
@@ -10,3 +11,9 @@ clean:
        @rm -f *~ */*~ */*/*~
        @rm -f core */core
        @(cd Demos; $(MAKE) clean)
+
+testclean:
+       rm -fr BUILD
+
+test:  testclean
+       ${PYTHON} runtests.py
diff --git a/runtests.py b/runtests.py
new file mode 100644 (file)
index 0000000..fdea5c2
--- /dev/null
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+
+import os, sys, unittest, doctest
+
+from Cython.Distutils.build_ext import build_ext
+from Cython.Distutils.extension import Extension
+
+from distutils.dist import Distribution
+distutils_distro = Distribution()
+
+TEST_DIRS = ['compile', 'run']
+TEST_RUN_DIRS = ['run']
+
+INCLUDE_DIRS = os.getenv('INCLUDE', '').split(os.pathsep)
+CFLAGS = os.getenv('CFLAGS', '').split()
+
+class TestBuilder(object):
+    def __init__(self, rootdir, workdir):
+        self.rootdir = rootdir
+        self.workdir = workdir
+
+    def build_suite(self):
+        suite = unittest.TestSuite()
+        for filename in os.listdir(self.rootdir):
+            path = os.path.join(self.rootdir, filename)
+            if os.path.isdir(path) and filename in TEST_DIRS:
+                suite.addTest(
+                    self.handle_directory(path, filename in TEST_RUN_DIRS))
+        return suite
+
+    def handle_directory(self, path, run_module):
+        suite = unittest.TestSuite()
+        for filename in os.listdir(path):
+            if not filename.endswith(".pyx"):
+                continue
+            module = filename[:-4]
+            suite.addTest(
+                CythonCompileTestCase(path, self.workdir, module))
+            if run_module:
+                suite.addTest(
+                    CythonRunTestCase(self.workdir, module))
+        return suite
+
+class CythonCompileTestCase(unittest.TestCase):
+    def __init__(self, directory, workdir, module):
+        self.directory = directory
+        self.workdir = workdir
+        self.module = module
+        unittest.TestCase.__init__(self)
+
+    def shortDescription(self):
+        return "compiling " + self.module
+
+    def runTest(self):
+        self.compile(self.directory, self.module, self.workdir)
+
+    def compile(self, directory, module, workdir):
+        build_extension = build_ext(distutils_distro)
+        build_extension.include_dirs = INCLUDE_DIRS[:]
+        build_extension.include_dirs.append(directory)
+        build_extension.finalize_options()
+
+        extension = Extension(
+            module,
+            sources = [os.path.join(directory, module + '.pyx')],
+            extra_compile_args = CFLAGS,
+            pyrex_c_in_temp = 1
+            )
+        build_extension.extensions = [extension]
+        build_extension.build_temp = workdir
+        build_extension.build_lib  = workdir
+        build_extension.pyrex_c_in_temp = 1
+        build_extension.run()
+
+class CythonRunTestCase(unittest.TestCase):
+    def __init__(self, rootdir, module):
+        self.rootdir, self.module = rootdir, module
+        unittest.TestCase.__init__(self)
+
+    def shortDescription(self):
+        return "running " + self.module
+
+    def runTest(self):
+        self.run(self)
+
+    def run(self, result=None):
+        sys.path.insert(0, self.rootdir)
+        if result is None: result = self.defaultTestResult()
+        try:
+            try:
+                doctest.DocTestSuite(self.module).run(result)
+            except ImportError:
+                result.startTest(self)
+                result.addFailure(self, sys.exc_info())
+                result.stopTest(self)
+        except Exception:
+            result.startTest(self)
+            result.addError(self, sys.exc_info())
+            result.stopTest(self)
+
+if __name__ == '__main__':
+    # RUN ALL TESTS!
+    ROOTDIR = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'tests')
+    WORKDIR = os.path.join(os.getcwd(), 'BUILD')
+    if not os.path.exists(WORKDIR):
+        os.makedirs(WORKDIR)
+
+    tests = TestBuilder(ROOTDIR, WORKDIR)
+    unittest.TextTestRunner(verbosity=2).run( tests.build_suite() )
diff --git a/tests/broken/anonymousenum.pyx b/tests/broken/anonymousenum.pyx
new file mode 100644 (file)
index 0000000..65d4c17
--- /dev/null
@@ -0,0 +1,7 @@
+cdef enum:
+    spam = 42
+    grail = 17
+
+cdef int i
+i = spam
+
diff --git a/tests/broken/arraytoptrarg.pyx b/tests/broken/arraytoptrarg.pyx
new file mode 100644 (file)
index 0000000..243a8d6
--- /dev/null
@@ -0,0 +1,6 @@
+cdef void f1(char *argv[]):
+    f2(argv)
+
+cdef void f2(char *argv[]):
+    pass
+
diff --git a/tests/broken/ass2cglobal.pyx b/tests/broken/ass2cglobal.pyx
new file mode 100644 (file)
index 0000000..f049647
--- /dev/null
@@ -0,0 +1,7 @@
+cdef int i
+cdef x
+
+def f(a):
+    global i, x
+    i = 42
+    x = a
diff --git a/tests/broken/ass2longlong.pyx b/tests/broken/ass2longlong.pyx
new file mode 100644 (file)
index 0000000..0628530
--- /dev/null
@@ -0,0 +1,8 @@
+cdef void spam():
+    cdef long long L
+    cdef unsigned long long U
+    cdef object x
+    L = x
+    x = L
+    U = x
+    x = U
diff --git a/tests/broken/builtinfuncs.pyx b/tests/broken/builtinfuncs.pyx
new file mode 100644 (file)
index 0000000..48a92fa
--- /dev/null
@@ -0,0 +1,23 @@
+cdef int f() except -1:
+    cdef object x, y, z, w
+    cdef int i
+    x = abs(y)
+    delattr(x, 'spam')
+    x = dir(y)
+    x = divmod(y, z)
+    x = getattr(y, 'spam')
+    i = hasattr(y, 'spam')
+    i = hash(y)
+    x = intern(y)
+    i = isinstance(y, z)
+    i = issubclass(y, z)
+    x = iter(y)
+    i = len(x)
+    x = open(y, z)
+    x = pow(y, z, w)
+    x = reload(y)
+    x = repr(y)
+    setattr(x, y, z)
+    #i = typecheck(x, y)
+    #i = issubtype(x, y)
+    x = abs
diff --git a/tests/broken/cascmp.pyx b/tests/broken/cascmp.pyx
new file mode 100644 (file)
index 0000000..9fe84cc
--- /dev/null
@@ -0,0 +1,13 @@
+cdef void foo():
+    cdef int bool, int1, int2, int3, int4
+    cdef object obj1, obj2, obj3, obj4
+    obj1 = 1
+    obj2 = 2
+    obj3 = 3
+    obj4 = 4
+    bool = int1 < int2 < int3
+    bool = obj1 < obj2 < obj3
+    bool = int1 < int2 < obj3
+    bool = obj1 < 2 < 3
+    bool = obj1 < 2 < 3 < 4
+    bool = int1 < (int2 == int3) < int4
diff --git a/tests/broken/cassign.pyx b/tests/broken/cassign.pyx
new file mode 100644 (file)
index 0000000..0b35298
--- /dev/null
@@ -0,0 +1,12 @@
+cdef void foo():
+    cdef int i1, i2
+    cdef char c1, c2
+    cdef char *p1, *p2
+    i1 = i2
+    i1 = c1
+    p1 = p2
+    obj1 = i1
+    i1 = obj1
+    p1 = obj1  
+    p1 = "spanish inquisition"
+    
\ No newline at end of file
diff --git a/tests/broken/casttoexttype.pyx b/tests/broken/casttoexttype.pyx
new file mode 100644 (file)
index 0000000..caab600
--- /dev/null
@@ -0,0 +1,9 @@
+cdef extern class external.Spam:
+    pass
+
+cdef void foo(object x):
+    pass
+
+cdef void blarg(void *y, object z):
+    foo(<Spam>y)
+    foo(<Spam>z)
diff --git a/tests/broken/cnamespec.pyx b/tests/broken/cnamespec.pyx
new file mode 100644 (file)
index 0000000..fec88d3
--- /dev/null
@@ -0,0 +1,17 @@
+cdef extern int a "c_a", b "c_b"
+
+cdef struct foo "c_foo":
+    int i "c_i"
+
+ctypedef enum blarg "c_blarg":
+    x "c_x"
+    y "c_y" = 42
+
+cdef double spam "c_spam" (int i, float f):
+    cdef double d "c_d"
+    cdef foo *p
+    global b
+    d = spam(a, f)
+    b = p.i
+    p.i = x
+    p.i = y
diff --git a/tests/broken/cnumop.pyx b/tests/broken/cnumop.pyx
new file mode 100644 (file)
index 0000000..309e122
--- /dev/null
@@ -0,0 +1,11 @@
+def f():
+    cdef int int1, int2, int3
+    cdef char char1
+    cdef long long1, long2
+    cdef float float1, float2
+    cdef double double1
+    int1 = int2 * int3
+    int1 = int2 / int3
+    long1 = long2 * char1
+    float1 = int1 * float2
+    double1 = float1 * int2
diff --git a/tests/broken/cstringmeth.pyx b/tests/broken/cstringmeth.pyx
new file mode 100644 (file)
index 0000000..389c0a5
--- /dev/null
@@ -0,0 +1,2 @@
+x = "foo".join(y)
+
diff --git a/tests/broken/ct_IF.pyx b/tests/broken/ct_IF.pyx
new file mode 100644 (file)
index 0000000..8cb1941
--- /dev/null
@@ -0,0 +1,29 @@
+DEF NO = 0
+DEF YES = 1
+
+cdef void f():
+    cdef int i
+    IF YES:
+        i = 1
+    ELIF NO:
+        i = 2
+    ELSE:
+        i = 3
+
+cdef void g():
+    cdef int i
+    IF NO:
+        i = 1
+    ELIF YES:
+        i = 2
+    ELSE:
+        i = 3
+
+cdef void h():
+    cdef int i
+    IF NO:
+        i = 1
+    ELIF NO:
+        i = 2
+    ELSE:
+        i = 3
diff --git a/tests/broken/cunsignedlong.pyx b/tests/broken/cunsignedlong.pyx
new file mode 100644 (file)
index 0000000..7e7d819
--- /dev/null
@@ -0,0 +1,5 @@
+cdef void f():
+    cdef unsigned long x
+    cdef object y
+    x = y
+    y = x
diff --git a/tests/broken/del.pyx b/tests/broken/del.pyx
new file mode 100644 (file)
index 0000000..a89761b
--- /dev/null
@@ -0,0 +1,7 @@
+def f(a, b):
+    global g
+    del g
+    del a[b]
+    del a[b][42]
+    del a.spam
+    del a.spam.eggs
diff --git a/tests/broken/delslice.pyx b/tests/broken/delslice.pyx
new file mode 100644 (file)
index 0000000..b1e0d46
--- /dev/null
@@ -0,0 +1,3 @@
+cdef void spam():
+    cdef object x
+    del x[17:42]
diff --git a/tests/broken/drake1.pyx b/tests/broken/drake1.pyx
new file mode 100644 (file)
index 0000000..afb09f0
--- /dev/null
@@ -0,0 +1,2 @@
+cdef char *s
+s = r'\"HT\"'
diff --git a/tests/broken/eqcmp.pyx b/tests/broken/eqcmp.pyx
new file mode 100644 (file)
index 0000000..fbc810e
--- /dev/null
@@ -0,0 +1,14 @@
+cdef void foo():
+    cdef int bool, int1, int2
+    cdef float float1, float2
+    cdef char *ptr1, *ptr2
+    cdef int *ptr3
+    bool = int1 == int2
+    bool = int1 <> int2
+    bool = int1 != int2
+    bool = float1 == float2
+    bool = ptr1 == ptr2
+    bool = int1 == float2
+    bool = ptr1 is ptr2
+    bool = ptr1 is not ptr2
+    
\ No newline at end of file
diff --git a/tests/broken/ewing1.pyx b/tests/broken/ewing1.pyx
new file mode 100644 (file)
index 0000000..1b2e306
--- /dev/null
@@ -0,0 +1,8 @@
+cdef int blarg(int i):
+    pass
+
+cdef void foo():
+    cdef float f
+    cdef int i
+    if blarg(<int> f):
+        pass
diff --git a/tests/broken/ewing5.pyx b/tests/broken/ewing5.pyx
new file mode 100644 (file)
index 0000000..33ced96
--- /dev/null
@@ -0,0 +1,2 @@
+cdef char *f():
+    raise Exception
diff --git a/tests/broken/excvalcheck.pyx b/tests/broken/excvalcheck.pyx
new file mode 100644 (file)
index 0000000..3b7f45c
--- /dev/null
@@ -0,0 +1,11 @@
+cdef extern int spam() except -1
+cdef extern void grail() except *
+cdef extern char *tomato() except? NULL
+
+cdef void eggs():
+    cdef int i
+    cdef char *p
+    i = spam()
+    grail()
+    p = tomato()
+
diff --git a/tests/broken/excvalreturn.pyx b/tests/broken/excvalreturn.pyx
new file mode 100644 (file)
index 0000000..3ed6266
--- /dev/null
@@ -0,0 +1,3 @@
+cdef int spam() except -1:
+    eggs = 42
+
diff --git a/tests/broken/extcmethod.pyx b/tests/broken/extcmethod.pyx
new file mode 100644 (file)
index 0000000..44d1eb3
--- /dev/null
@@ -0,0 +1,15 @@
+cdef class Spam:
+
+    cdef int tons
+    
+    cdef void add_tons(self, int x):
+        self.tons = self.tons + x
+
+    cdef void eat(self):
+        self.tons = 0
+
+
+cdef class SuperSpam(Spam):
+
+    cdef void add_tons(self, int x):
+        self.tons = self.tons + 2 * x
diff --git a/tests/broken/extcoerce.pyx b/tests/broken/extcoerce.pyx
new file mode 100644 (file)
index 0000000..7533d4b
--- /dev/null
@@ -0,0 +1,24 @@
+cdef class Grail:
+
+    def __add__(int x, float y):
+        pass
+    
+    def __getslice__(self, i, j):
+        pass
+
+    def __setslice__(self, Py_ssize_t i, float j, x):
+        pass
+
+cdef class Swallow:
+    pass
+    
+def f(Grail g):
+    cdef int i
+    cdef Swallow s
+    g = x
+    x = g
+    g = i
+    i = g
+    g = s
+    s = g
+
diff --git a/tests/broken/extdescrdel.pyx b/tests/broken/extdescrdel.pyx
new file mode 100644 (file)
index 0000000..b49516a
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Foo:
+
+    def __delete__(self, i):
+        pass
diff --git a/tests/broken/extdescrget.pyx b/tests/broken/extdescrget.pyx
new file mode 100644 (file)
index 0000000..b988a46
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Foo:
+
+    def __get__(self, i, c):
+        pass
diff --git a/tests/broken/extdescrset.pyx b/tests/broken/extdescrset.pyx
new file mode 100644 (file)
index 0000000..50161aa
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Foo:
+
+    def __set__(self, i, v):
+        pass
diff --git a/tests/broken/extexttype.pyx b/tests/broken/extexttype.pyx
new file mode 100644 (file)
index 0000000..8d63dce
--- /dev/null
@@ -0,0 +1,13 @@
+cdef extern class external.Spam [object SpamObject]:
+    pass
+
+ctypedef extern class external.Grail [object Grail]:
+    pass
+
+cdef extern from "food.h":
+
+    class external.Tomato [object Tomato]:
+        pass
+
+    class external.Bicycle [object Bicycle]:
+        pass
diff --git a/tests/broken/extgetitem.pyx b/tests/broken/extgetitem.pyx
new file mode 100644 (file)
index 0000000..2f5cc7e
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class Spam:
+
+    def __getitem__(self, x):
+        pass
+
diff --git a/tests/broken/extpropertyall.pyx b/tests/broken/extpropertyall.pyx
new file mode 100644 (file)
index 0000000..ee0ca8f
--- /dev/null
@@ -0,0 +1,15 @@
+cdef class Spam:
+
+    property eggs:
+
+        "Ova"
+    
+        def __get__(self):
+            pass
+        
+        def __set__(self, x):
+            pass
+        
+        def __del__(self):
+            pass
+
diff --git a/tests/broken/extpropertyref.pyx b/tests/broken/extpropertyref.pyx
new file mode 100644 (file)
index 0000000..86609eb
--- /dev/null
@@ -0,0 +1,12 @@
+cdef class Spam:
+
+    property eggs:
+    
+        def __get__(self):
+            pass
+
+cdef void tomato():
+    cdef Spam spam
+    cdef object lettuce
+    lettuce = spam.eggs
+
diff --git a/tests/broken/extpymemberdef.pyx b/tests/broken/extpymemberdef.pyx
new file mode 100644 (file)
index 0000000..58a62a3
--- /dev/null
@@ -0,0 +1,14 @@
+cdef class Spam:
+    cdef public char c
+    cdef public int i
+    cdef public long l
+    cdef public unsigned char uc
+    cdef public unsigned int ui
+    cdef public unsigned long ul
+    cdef public float f
+    cdef public double d
+    cdef public char *s
+    cdef public char a[42]
+    cdef public object o
+    cdef readonly int r
+    cdef readonly Spam e
diff --git a/tests/broken/forfromelse.pyx b/tests/broken/forfromelse.pyx
new file mode 100644 (file)
index 0000000..014f42b
--- /dev/null
@@ -0,0 +1,7 @@
+cdef void spam():
+    cdef int i, j, k
+    for i from 0 <= i < 10:
+        j = k
+    else:
+        k = j
+
diff --git a/tests/broken/gencall.pyx b/tests/broken/gencall.pyx
new file mode 100644 (file)
index 0000000..54bfa2c
--- /dev/null
@@ -0,0 +1,11 @@
+def f(x, y):
+    x = y
+
+def z(a, b, c):
+    f(x = 42, y = "spam")
+    f(*a)
+    f(**b)
+    f(x = 42, **b)
+    f(a, *b)
+    f(a, x = 42, *b, **c)
+    
\ No newline at end of file
diff --git a/tests/broken/getattr3call.pyx b/tests/broken/getattr3call.pyx
new file mode 100644 (file)
index 0000000..015f458
--- /dev/null
@@ -0,0 +1,2 @@
+cdef int f(a, b, c) except -1:
+    d = getattr3(a, b, c)
diff --git a/tests/broken/globalstmt.pyx b/tests/broken/globalstmt.pyx
new file mode 100644 (file)
index 0000000..b0e84ee
--- /dev/null
@@ -0,0 +1,4 @@
+def f():
+    global a,b,c,d
+    a = b
+    c = d
diff --git a/tests/broken/gustafsson2.pyx b/tests/broken/gustafsson2.pyx
new file mode 100644 (file)
index 0000000..de3c992
--- /dev/null
@@ -0,0 +1,9 @@
+ctypedef enum someenum_t:
+    ENUMVALUE_1
+    ENUMVALUE_2
+
+cdef somefunction(someenum_t val):
+    if val == ENUMVALUE_1:
+        pass
+
+
diff --git a/tests/broken/index.pyx b/tests/broken/index.pyx
new file mode 100644 (file)
index 0000000..0dc3beb
--- /dev/null
@@ -0,0 +1,16 @@
+def f(obj1, obj2, obj3):
+    cdef int int1, int2, int3
+    cdef float flt1, *ptr1
+    cdef int array1[42]
+    int1 = array1[int2]
+    flt1 = ptr1[int2]
+    array1[int1] = int2
+    ptr1[int1] = int2
+    obj1 = obj2[obj3]
+    int1 = array1[obj3]
+    obj1 = obj2[int3]
+    obj1[obj2] = obj3
+    array1[obj2] = int3
+    obj1[int2] = obj3
+    obj1[obj2] = 42
+    
\ No newline at end of file
diff --git a/tests/broken/inhcmethcall.pyx b/tests/broken/inhcmethcall.pyx
new file mode 100644 (file)
index 0000000..1793f35
--- /dev/null
@@ -0,0 +1,10 @@
+cdef class Parrot:
+
+  cdef void describe(self):
+    pass
+
+
+cdef class Norwegian(Parrot):
+
+  cdef void describe(self):
+    Parrot.describe(self)
diff --git a/tests/broken/jiba5.pyx b/tests/broken/jiba5.pyx
new file mode 100644 (file)
index 0000000..7c6071b
--- /dev/null
@@ -0,0 +1,5 @@
+def f():
+    cdef int i
+    global mylist
+    del mylist[i]
+    return
diff --git a/tests/broken/jiba6.pyx b/tests/broken/jiba6.pyx
new file mode 100644 (file)
index 0000000..60bba58
--- /dev/null
@@ -0,0 +1,8 @@
+cdef extern from "string.h":
+    void memcpy(void* des, void* src, int size)
+
+cdef void f():
+    cdef float f1[3]
+    cdef float* f2
+    f2 = f1 + 1
+    memcpy(f1, f2, 1)
diff --git a/tests/broken/johnson1.pyx b/tests/broken/johnson1.pyx
new file mode 100644 (file)
index 0000000..d6013ef
--- /dev/null
@@ -0,0 +1,7 @@
+ctypedef enum foo:
+    FOO
+
+cdef void func():
+    cdef foo x
+    map = [FOO]
+    x = map[0]
diff --git a/tests/broken/king1.pyx b/tests/broken/king1.pyx
new file mode 100644 (file)
index 0000000..507b2c2
--- /dev/null
@@ -0,0 +1,7 @@
+DEF STUFF = "Spam"
+
+cdef void f():
+    IF STUFF == "Spam":
+        print "It works!"
+    ELSE:
+        print "Doesn't work"
diff --git a/tests/broken/magcmp.pyx b/tests/broken/magcmp.pyx
new file mode 100644 (file)
index 0000000..c2a133b
--- /dev/null
@@ -0,0 +1,8 @@
+cdef void foo():
+    cdef int bool, int1, int2
+    bool = int1 < int2
+    bool = int1 > int2
+    bool = int1 <= int2
+    bool = int1 >= int2
+    
+    
diff --git a/tests/broken/menten1.pyx b/tests/broken/menten1.pyx
new file mode 100644 (file)
index 0000000..d788e7e
--- /dev/null
@@ -0,0 +1,5 @@
+cdef loops():
+    cdef int k
+    for i from 0 <= i < 5:
+        for j from 0 <= j < 2:
+            k = i + j
diff --git a/tests/broken/none.pyx b/tests/broken/none.pyx
new file mode 100644 (file)
index 0000000..afe1188
--- /dev/null
@@ -0,0 +1,3 @@
+cdef void spam():
+    eggs = None
+
diff --git a/tests/broken/nononetypecheck.pyx b/tests/broken/nononetypecheck.pyx
new file mode 100644 (file)
index 0000000..2933bc1
--- /dev/null
@@ -0,0 +1,8 @@
+cdef class Spam:
+    pass
+
+cdef f(Spam s):
+    pass
+
+cdef g():
+    f(None)
diff --git a/tests/broken/notnonearg.pyx b/tests/broken/notnonearg.pyx
new file mode 100644 (file)
index 0000000..711cf9e
--- /dev/null
@@ -0,0 +1,5 @@
+cdef extern class external.Spam [object Spam]: pass
+cdef extern class external.Eggs [object Eggs]: pass
+
+def ham(Spam s, Eggs e not None):
+    pass
diff --git a/tests/broken/onelinesuite.pyx b/tests/broken/onelinesuite.pyx
new file mode 100644 (file)
index 0000000..ea4fa37
--- /dev/null
@@ -0,0 +1,2 @@
+if x: y = 42; z = 88
+def f(): return 17
diff --git a/tests/broken/plex2.pyx b/tests/broken/plex2.pyx
new file mode 100644 (file)
index 0000000..996d59d
--- /dev/null
@@ -0,0 +1,9 @@
+cdef class Spam:
+    pass
+
+cdef void foo(object blarg):
+    pass
+
+cdef void xyzzy():
+    cdef Spam spam
+    foo(spam)
diff --git a/tests/broken/powop.pyx b/tests/broken/powop.pyx
new file mode 100644 (file)
index 0000000..2a08358
--- /dev/null
@@ -0,0 +1,4 @@
+def f(obj1, obj2, obj3):
+    cdef float flt1, flt2, flt3
+    flt1 = flt2 ** flt3
+    obj1 = obj2 ** obj3
diff --git a/tests/broken/r_pernici1.pyx b/tests/broken/r_pernici1.pyx
new file mode 100644 (file)
index 0000000..df97cb5
--- /dev/null
@@ -0,0 +1,14 @@
+cdef extern from "math.h":
+  double M_PI
+
+#cdef unsigned long int n1
+#n1 = 4293858116
+
+cdef double pi
+pi = 3.14159265358979323846
+
+def main():
+  #print n1
+  print "%.18f" % M_PI
+  print "%.18f" % (<float> M_PI)
+  print "%.18f" % pi
diff --git a/tests/broken/raise.pyx b/tests/broken/raise.pyx
new file mode 100644 (file)
index 0000000..1e29b17
--- /dev/null
@@ -0,0 +1,8 @@
+def f(a, b, c):
+    #raise
+    raise a
+    raise "spam"
+    raise a, b
+    raise "spam", 42
+    raise a, b, c
+    raise "spam", 42, c()
diff --git a/tests/broken/ref2global.pyx b/tests/broken/ref2global.pyx
new file mode 100644 (file)
index 0000000..5dfed27
--- /dev/null
@@ -0,0 +1,4 @@
+def f(a):
+    a = f
+    a = g
+
diff --git a/tests/broken/slicex.pyx b/tests/broken/slicex.pyx
new file mode 100644 (file)
index 0000000..b18620b
--- /dev/null
@@ -0,0 +1,2 @@
+def f(a, b, c, d, e, f, g, h, i):
+    a = b[c:d, e:f:g, ..., h, :i:]
diff --git a/tests/broken/tandemstats.pyx b/tests/broken/tandemstats.pyx
new file mode 100644 (file)
index 0000000..91e5ba8
--- /dev/null
@@ -0,0 +1,4 @@
+cdef int i, j, k
+i = 17; j = 42; k = i * j
+if j > k: i = 88
+else: i = 99; j = k
diff --git a/tests/broken/traceback.pyx b/tests/broken/traceback.pyx
new file mode 100644 (file)
index 0000000..9edfc72
--- /dev/null
@@ -0,0 +1,9 @@
+def spam():
+    raise Exception
+
+cdef int grail() except -1:
+    raise Exception
+
+def tomato():
+    spam()
+    grail()
diff --git a/tests/broken/tryexceptelse.pyx b/tests/broken/tryexceptelse.pyx
new file mode 100644 (file)
index 0000000..373fedc
--- /dev/null
@@ -0,0 +1,23 @@
+def f():
+    cdef int i
+    try:
+        i = 1
+        raise x
+        i = 2
+    else:
+        i = 3
+        raise y
+        i = 4
+
+def g():
+    cdef int i
+    try:
+        i = 1
+        raise x
+        i = 2
+    except a:
+        i = 3
+    else:
+        i = 4
+        raise y
+        i = 5
diff --git a/tests/broken/watts1.pyx b/tests/broken/watts1.pyx
new file mode 100644 (file)
index 0000000..68eab30
--- /dev/null
@@ -0,0 +1,4 @@
+def test():
+    cdef int a,b
+    foo=(55,66)
+    a,b=foo
diff --git a/tests/broken/watts2.pyx b/tests/broken/watts2.pyx
new file mode 100644 (file)
index 0000000..f1f14d8
--- /dev/null
@@ -0,0 +1,2 @@
+cdef int x
+x = 0xFFFFFFFF
diff --git a/tests/compile/a_capi.pyx b/tests/compile/a_capi.pyx
new file mode 100644 (file)
index 0000000..f88ee92
--- /dev/null
@@ -0,0 +1,21 @@
+cdef public struct Foo:
+    int a, b
+    
+ctypedef struct Blarg:
+    int c, d
+
+ctypedef public Foo Zax
+
+cdef public class C[type C_Type, object C_Obj]:
+    pass
+
+cdef public Zax *blarg
+
+cdef api float f(Foo *x):
+    pass
+
+cdef public void g(Blarg *x):
+    pass
+
+cdef public api void h(Zax *x):
+    pass
diff --git a/tests/compile/altet1.h b/tests/compile/altet1.h
new file mode 100644 (file)
index 0000000..1d11294
--- /dev/null
@@ -0,0 +1,2 @@
+typedef int blarg;
+
diff --git a/tests/compile/altet1.pyx b/tests/compile/altet1.pyx
new file mode 100644 (file)
index 0000000..2a691cf
--- /dev/null
@@ -0,0 +1,9 @@
+cdef extern from "altet1.h":
+    ctypedef int blarg
+
+cdef blarg globvar
+
+def flub(blarg bobble):
+    print bobble
+
+globvar = 0
diff --git a/tests/compile/argdefault.pyx b/tests/compile/argdefault.pyx
new file mode 100644 (file)
index 0000000..e008fed
--- /dev/null
@@ -0,0 +1,5 @@
+cdef swallow
+
+def spam(w, int x = 42, y = "grail", z = swallow):
+    pass
+
diff --git a/tests/compile/arrayptrcompat.pyx b/tests/compile/arrayptrcompat.pyx
new file mode 100644 (file)
index 0000000..4ba8258
--- /dev/null
@@ -0,0 +1,17 @@
+cdef enum E:
+    z
+
+cdef void f():
+    cdef int *p
+    cdef void *v
+    cdef int a[5]
+    cdef int i
+    cdef E e
+    p = a
+    v = a
+    p = a + i
+    p = a + e
+    p = i + a
+    p = e + a
+    p = a - i
+    p = a - e
diff --git a/tests/compile/behnel4.pyx b/tests/compile/behnel4.pyx
new file mode 100644 (file)
index 0000000..37352e3
--- /dev/null
@@ -0,0 +1,5 @@
+cdef enum E:
+    spam, eggs
+
+cdef E f() except spam:
+    pass
diff --git a/tests/compile/belchenko1.pyx b/tests/compile/belchenko1.pyx
new file mode 100644 (file)
index 0000000..bae543a
--- /dev/null
@@ -0,0 +1,5 @@
+cdef extern from "stdint.h":
+    ctypedef int intptr_t
+
+cdef int _is_aligned(void *ptr):
+    return ((<intptr_t>ptr) & ((sizeof(int))-1)) == 0
diff --git a/tests/compile/belchenko2.h b/tests/compile/belchenko2.h
new file mode 100644 (file)
index 0000000..6f72e15
--- /dev/null
@@ -0,0 +1 @@
+void c_func(unsigned char pixel);
diff --git a/tests/compile/belchenko2.pyx b/tests/compile/belchenko2.pyx
new file mode 100644 (file)
index 0000000..59765f8
--- /dev/null
@@ -0,0 +1,12 @@
+cdef extern from "belchenko2.h":
+    void c_func(unsigned char pixel)
+
+def f(unsigned char pixel):
+    c_func(pixel)
+
+def g(signed char pixel):
+    c_func(pixel)
+
+def h(char pixel):
+    c_func(pixel)
+
diff --git a/tests/compile/builtin.pyx b/tests/compile/builtin.pyx
new file mode 100644 (file)
index 0000000..542e532
--- /dev/null
@@ -0,0 +1,2 @@
+def f():
+    x = open("foo")
diff --git a/tests/compile/burton1.pyx b/tests/compile/burton1.pyx
new file mode 100644 (file)
index 0000000..5bb64e7
--- /dev/null
@@ -0,0 +1,4 @@
+cdef void f():
+    cdef void (*p)()
+    p = <void(*)()>0
+    (<int (*)()>p)()
diff --git a/tests/compile/callingconvention.pyx b/tests/compile/callingconvention.pyx
new file mode 100644 (file)
index 0000000..6befb36
--- /dev/null
@@ -0,0 +1,7 @@
+cdef extern int f()
+
+cdef extern int __stdcall g()
+
+cdef extern int __cdecl h()
+
+cdef extern int (__stdcall *p)()
diff --git a/tests/compile/cargdef.pyx b/tests/compile/cargdef.pyx
new file mode 100644 (file)
index 0000000..c8064d0
--- /dev/null
@@ -0,0 +1,3 @@
+def f(obj, int i, float f, char *s1, char s2[]):
+    pass
+    
\ No newline at end of file
diff --git a/tests/compile/cdefexternfromstar.pyx b/tests/compile/cdefexternfromstar.pyx
new file mode 100644 (file)
index 0000000..11ecbdf
--- /dev/null
@@ -0,0 +1,3 @@
+cdef extern from *:
+    int spam
+
diff --git a/tests/compile/cenum.pyx b/tests/compile/cenum.pyx
new file mode 100644 (file)
index 0000000..00a7e31
--- /dev/null
@@ -0,0 +1,13 @@
+cdef enum Spam:
+    a
+    b, c,
+    d, e, f
+    g = 42
+
+cdef void eggs():
+    cdef Spam s1, s2
+    cdef int i
+    s1 = s2
+    s1 = c
+    i = s1
+    
\ No newline at end of file
diff --git a/tests/compile/cforfromloop.pyx b/tests/compile/cforfromloop.pyx
new file mode 100644 (file)
index 0000000..2466f82
--- /dev/null
@@ -0,0 +1,32 @@
+cdef int i, j, k
+cdef object a, b, x
+
+for i from 0 <= i < 10:
+    pass
+for i from 0 < i <= 10:
+    pass
+for i from 10 >= i > 0:
+    pass
+for i from 10 > i >= 0:
+    pass
+
+for x from 0 <= x <= 10:
+    pass
+
+for i from a <= i <= b:
+    pass
+
+for i from k <= i <= j:
+    pass
+
+for i from k * 42 <= i <= j / 18:
+    pass
+
+while j:
+    for i from 0 <= i <= 10:
+        continue
+        break
+    else:
+        continue
+        break
+
diff --git a/tests/compile/classmethargdefault.pyx b/tests/compile/classmethargdefault.pyx
new file mode 100644 (file)
index 0000000..8c827f1
--- /dev/null
@@ -0,0 +1,5 @@
+class Swallow:
+
+    def spam(w, int x = 42, y = "grail", z = swallow):
+        pass
+
diff --git a/tests/compile/coercearraytoptr.pyx b/tests/compile/coercearraytoptr.pyx
new file mode 100644 (file)
index 0000000..281de3d
--- /dev/null
@@ -0,0 +1,10 @@
+cdef extern void spam(char *s)
+
+cdef struct Grail:
+    char silly[42]
+
+cdef void eggs():
+    cdef char silly[42]
+    cdef Grail grail
+    spam(silly)
+    spam(grail.silly)
diff --git a/tests/compile/coercetovoidptr.pyx b/tests/compile/coercetovoidptr.pyx
new file mode 100644 (file)
index 0000000..c153316
--- /dev/null
@@ -0,0 +1,5 @@
+cdef void f():
+    cdef void *p
+    cdef char *q
+    p = q
+
diff --git a/tests/compile/complexbasetype.pyx b/tests/compile/complexbasetype.pyx
new file mode 100644 (file)
index 0000000..8531b0a
--- /dev/null
@@ -0,0 +1,4 @@
+cdef extern (int *[42]) spam, grail, swallow
+
+cdef (int (*)()) brian():
+    pass
diff --git a/tests/compile/constexpr.pyx b/tests/compile/constexpr.pyx
new file mode 100644 (file)
index 0000000..c76b5a3
--- /dev/null
@@ -0,0 +1,8 @@
+cdef enum Grail:
+    k = 42
+
+cdef enum Spam:
+    a = -1
+    b = 2 + 3
+    c = 42 > 17
+    d = k
diff --git a/tests/compile/coventry1.pyx b/tests/compile/coventry1.pyx
new file mode 100644 (file)
index 0000000..828c1fc
--- /dev/null
@@ -0,0 +1,2 @@
+cdef class Tst:
+    cdef foo,
diff --git a/tests/compile/cstructreturn.pyx b/tests/compile/cstructreturn.pyx
new file mode 100644 (file)
index 0000000..6066a7b
--- /dev/null
@@ -0,0 +1,5 @@
+ctypedef struct Foo:
+    int blarg
+
+cdef Foo f():
+    blarg = 1 + 2
diff --git a/tests/compile/ct_DEF.pyx b/tests/compile/ct_DEF.pyx
new file mode 100644 (file)
index 0000000..68a7c09
--- /dev/null
@@ -0,0 +1,25 @@
+DEF CHAR = c'x'
+DEF INT = 42
+DEF LONG = 666L
+DEF FLOAT = 17.88
+DEF STR = "spam"
+DEF TUPLE = (1, 2, "buckle my shoe")
+DEF TWO = TUPLE[1]
+DEF FIVE = TWO + 3
+
+cdef void f():
+    cdef char c
+    cdef int i
+    cdef long l
+    cdef float f
+    cdef char *s
+    cdef int two
+    cdef int five
+    c = CHAR
+    i = INT
+    l = LONG
+    f = FLOAT
+    s = STR
+    two = TWO
+    five = FIVE
+    
\ No newline at end of file
diff --git a/tests/compile/ctypedef.pyx b/tests/compile/ctypedef.pyx
new file mode 100644 (file)
index 0000000..6b55784
--- /dev/null
@@ -0,0 +1,4 @@
+ctypedef int *IntPtr
+ctypedef unsigned long ULong
+cdef extern IntPtr spam
+cdef extern ULong grail
diff --git a/tests/compile/ctypedefclass.pyx b/tests/compile/ctypedefclass.pyx
new file mode 100644 (file)
index 0000000..cebd75c
--- /dev/null
@@ -0,0 +1,6 @@
+ctypedef class spam:
+    pass
+
+cdef spam s
+
+s = None
diff --git a/tests/compile/ctypedefenum.pyx b/tests/compile/ctypedefenum.pyx
new file mode 100644 (file)
index 0000000..3810f48
--- /dev/null
@@ -0,0 +1,8 @@
+ctypedef enum parrot_state:
+    alive = 1
+    dead = 2
+
+cdef parrot_state polly
+
+polly = dead
+
diff --git a/tests/compile/ctypedefstruct.pyx b/tests/compile/ctypedefstruct.pyx
new file mode 100644 (file)
index 0000000..b52c215
--- /dev/null
@@ -0,0 +1,9 @@
+ctypedef struct order:
+    int spam
+    int eggs
+
+cdef order order1
+
+order1.spam = 7
+order1.eggs = 2
+
diff --git a/tests/compile/ctypedefunion.pyx b/tests/compile/ctypedefunion.pyx
new file mode 100644 (file)
index 0000000..aea4719
--- /dev/null
@@ -0,0 +1,9 @@
+ctypedef union pet:
+    int cat
+    float dog
+
+cdef pet sam
+
+sam.cat = 1
+sam.dog = 2.7
+
diff --git a/tests/compile/cverylongtypes.pyx b/tests/compile/cverylongtypes.pyx
new file mode 100644 (file)
index 0000000..47d3a73
--- /dev/null
@@ -0,0 +1,4 @@
+cdef extern short int s
+cdef extern long int l
+cdef extern long long ll
+cdef extern long double ld
diff --git a/tests/compile/declandimpl.pxd b/tests/compile/declandimpl.pxd
new file mode 100644 (file)
index 0000000..5d09d89
--- /dev/null
@@ -0,0 +1,6 @@
+cdef struct Sandwich:
+       int i
+       char *s
+
+cdef class Tomato:
+       cdef float danger
diff --git a/tests/compile/declandimpl.pyx b/tests/compile/declandimpl.pyx
new file mode 100644 (file)
index 0000000..760ba7a
--- /dev/null
@@ -0,0 +1,9 @@
+cdef class Tomato:
+
+    def eject(self):
+        pass
+
+cdef extern Sandwich butty
+cdef Tomato supertom
+
+supertom = None
diff --git a/tests/compile/declarations.pyx b/tests/compile/declarations.pyx
new file mode 100644 (file)
index 0000000..9f5259d
--- /dev/null
@@ -0,0 +1,20 @@
+cdef extern char *cp
+cdef extern char *cpa[5]
+cdef extern int (*ifnpa[5])()
+cdef extern char *(*cpfnpa[5])()
+cdef extern int (*ifnp)()
+cdef extern int (*iap)[5]
+
+cdef extern int ifn()
+cdef extern char *cpfn()
+cdef extern int (*iapfn())[5]
+cdef extern char *(*cpapfn())[5]
+cdef extern int fnargfn(int ())
+
+cdef void f():
+    cdef void *p
+    global ifnp, cpa
+    ifnp = <int (*)()>p
+
+cdef char *g():
+    pass
diff --git a/tests/compile/doda1.pyx b/tests/compile/doda1.pyx
new file mode 100644 (file)
index 0000000..fce4357
--- /dev/null
@@ -0,0 +1,11 @@
+cdef class Spam:
+    pass
+
+cdef Spam foo():
+    return blarg()
+    #cdef Spam grail
+    #grail = blarg()
+    #return grail
+
+cdef object blarg():
+    pass
diff --git a/tests/compile/emptytry.pyx b/tests/compile/emptytry.pyx
new file mode 100644 (file)
index 0000000..35e76b8
--- /dev/null
@@ -0,0 +1,5 @@
+cdef void f():
+    try:
+        pass
+    finally:
+        pass
diff --git a/tests/compile/enumintcompat.pyx b/tests/compile/enumintcompat.pyx
new file mode 100644 (file)
index 0000000..70c9b40
--- /dev/null
@@ -0,0 +1,25 @@
+cdef enum E:
+    a
+
+cdef enum G:
+    b
+
+cdef void f():
+    cdef E e
+    cdef G g
+    cdef int i, j
+    cdef float f, h
+    i = j | e
+    i = e | j
+    i = j ^ e
+    i = j & e
+    i = j << e
+    i = j >> e
+    i = j + e
+    i = j - e
+    i = j * e
+    i = j / e
+    i = j % e
+    # f = j ** e # Cython prohibits this
+    i = e + g
+    f = h
diff --git a/tests/compile/ewing3.pyx b/tests/compile/ewing3.pyx
new file mode 100644 (file)
index 0000000..1f02b7c
--- /dev/null
@@ -0,0 +1,3 @@
+cdef class C:
+    cdef f(self):
+        pass
diff --git a/tests/compile/ewing4.pyx b/tests/compile/ewing4.pyx
new file mode 100644 (file)
index 0000000..266ad47
--- /dev/null
@@ -0,0 +1,2 @@
+cdef void f():
+    "This is a pseudo doc string."
diff --git a/tests/compile/ewing6.pyx b/tests/compile/ewing6.pyx
new file mode 100644 (file)
index 0000000..390a6b9
--- /dev/null
@@ -0,0 +1,21 @@
+# Spurious gcc3.3 warnings about incompatible pointer
+# types passed to C method
+
+# Ordering of declarations in C code is important
+cdef class C
+cdef class D(C)
+cdef class E
+
+cdef class C:
+    cdef void a(self):
+        pass
+
+cdef class D(C):
+    cdef void m(self, E e):
+        pass
+
+cdef class E:
+    pass
+
+cdef void f(D d, E e):
+    d.m(e)
diff --git a/tests/compile/ewing7.pyx b/tests/compile/ewing7.pyx
new file mode 100644 (file)
index 0000000..e3028c7
--- /dev/null
@@ -0,0 +1,12 @@
+cdef class A:
+    cdef void f(self, x):
+        pass
+
+cdef class B(A):
+    cdef void f(self, object x):
+        pass
+
+cdef extern void g(A a, b)
+
+cdef extern void g(A a, b)
+
diff --git a/tests/compile/ewing8.pxd b/tests/compile/ewing8.pxd
new file mode 100644 (file)
index 0000000..b8c3122
--- /dev/null
@@ -0,0 +1,12 @@
+cdef struct Foo
+cdef class Blarg
+
+ctypedef Foo FooType
+ctypedef Blarg BlargType
+
+cdef struct Foo:
+       FooType *f
+
+cdef class Blarg:
+       cdef FooType *f
+       cdef BlargType b
diff --git a/tests/compile/ewing8.pyx b/tests/compile/ewing8.pyx
new file mode 100644 (file)
index 0000000..d6717bf
--- /dev/null
@@ -0,0 +1,2 @@
+cdef class Blarg:
+    pass
diff --git a/tests/compile/ewing9.pxd b/tests/compile/ewing9.pxd
new file mode 100644 (file)
index 0000000..8678427
--- /dev/null
@@ -0,0 +1 @@
+cdef struct xmlDoc
diff --git a/tests/compile/ewing9.pyx b/tests/compile/ewing9.pyx
new file mode 100644 (file)
index 0000000..e4b0365
--- /dev/null
@@ -0,0 +1,2 @@
+cdef struct xmlDoc:
+    int i
diff --git a/tests/compile/excvaldecl.pyx b/tests/compile/excvaldecl.pyx
new file mode 100644 (file)
index 0000000..6b99e39
--- /dev/null
@@ -0,0 +1,17 @@
+cdef int spam() except 42:
+    pass
+
+cdef float eggs() except 3.14:
+    pass
+
+cdef char *grail() except NULL:
+    pass
+
+cdef int tomato() except *:
+    pass
+
+cdef int brian() except? 0:
+    pass
+
+cdef int silly() except -1:
+    pass
diff --git a/tests/compile/extargdefault.pyx b/tests/compile/extargdefault.pyx
new file mode 100644 (file)
index 0000000..f6e070f
--- /dev/null
@@ -0,0 +1,7 @@
+cdef extern class somewhere.Swallow:
+    pass
+
+cdef Swallow swallow
+
+def spam(x = swallow, Swallow y = swallow):
+    pass
diff --git a/tests/compile/extcmethcall.pyx b/tests/compile/extcmethcall.pyx
new file mode 100644 (file)
index 0000000..2a25845
--- /dev/null
@@ -0,0 +1,18 @@
+cdef class Spam:
+
+    cdef int tons
+    
+    cdef void add_tons(self, int x):
+        pass
+
+
+cdef class SuperSpam(Spam):
+    pass
+
+
+cdef void tomato():
+    cdef Spam spam
+    cdef SuperSpam superspam
+    spam = superspam
+    spam.add_tons(42)
+    superspam.add_tons(1764)
diff --git a/tests/compile/extdelattr.pyx b/tests/compile/extdelattr.pyx
new file mode 100644 (file)
index 0000000..7236bcc
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+    
+    def __delattr__(self, n):
+        pass
diff --git a/tests/compile/extdelitem.pyx b/tests/compile/extdelitem.pyx
new file mode 100644 (file)
index 0000000..e7f4a7f
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+    
+    def __delitem__(self, i):
+        pass
diff --git a/tests/compile/extdelslice.pyx b/tests/compile/extdelslice.pyx
new file mode 100644 (file)
index 0000000..17e92ff
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+    
+    def __delslice__(self, Py_ssize_t i, Py_ssize_t j):
+        pass
diff --git a/tests/compile/extern.pyx b/tests/compile/extern.pyx
new file mode 100644 (file)
index 0000000..8ad35e9
--- /dev/null
@@ -0,0 +1,9 @@
+cdef extern int i
+cdef extern char *s[]
+cdef extern void spam(char c)
+
+cdef extern int eggs():
+    pass
+
+cdef int grail():
+    pass
diff --git a/tests/compile/extforward.pyx b/tests/compile/extforward.pyx
new file mode 100644 (file)
index 0000000..fd571a1
--- /dev/null
@@ -0,0 +1,8 @@
+cdef class Spam
+
+cdef class Grail:
+    cdef Spam spam
+
+cdef class Spam:
+    pass
+
diff --git a/tests/compile/extgetattr.pyx b/tests/compile/extgetattr.pyx
new file mode 100644 (file)
index 0000000..9ae9ac2
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+    
+    def __getattr__(self, x):
+        pass
diff --git a/tests/compile/exthash.pyx b/tests/compile/exthash.pyx
new file mode 100644 (file)
index 0000000..865edb7
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class Spam:
+
+    def __hash__(self):
+        pass
+
diff --git a/tests/compile/extimported.pyx b/tests/compile/extimported.pyx
new file mode 100644 (file)
index 0000000..2de7cee
--- /dev/null
@@ -0,0 +1,6 @@
+cdef extern class Spam.Eggs.Ham:
+    pass
+
+cdef Ham ham
+
+ham = None
\ No newline at end of file
diff --git a/tests/compile/extindex.pyx b/tests/compile/extindex.pyx
new file mode 100644 (file)
index 0000000..cc15854
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+
+    def __index__(self):
+        return 42
diff --git a/tests/compile/extinheritdel.pyx b/tests/compile/extinheritdel.pyx
new file mode 100644 (file)
index 0000000..f1db8e9
--- /dev/null
@@ -0,0 +1,16 @@
+cdef class Parrot:
+    pass
+
+cdef class Norwegian(Parrot):
+    
+    def __delitem__(self, i):
+        pass
+    
+    def __delslice__(self, i, j):
+        pass
+
+    def __delattr__(self, n):
+        pass
+
+    def __delete__(self, i):
+        pass
diff --git a/tests/compile/extinheritset.pyx b/tests/compile/extinheritset.pyx
new file mode 100644 (file)
index 0000000..a06b5cc
--- /dev/null
@@ -0,0 +1,16 @@
+cdef class Parrot:
+    pass
+
+cdef class Norwegian(Parrot):
+    
+    def __setitem__(self, i, x):
+        pass
+    
+    def __setslice__(self, i, j, x):
+        pass
+
+    def __setattr__(self, n, x):
+        pass
+
+    def __set__(self, i, v):
+        pass
diff --git a/tests/compile/extpropertydel.pyx b/tests/compile/extpropertydel.pyx
new file mode 100644 (file)
index 0000000..27f943c
--- /dev/null
@@ -0,0 +1,6 @@
+cdef class Spam:
+
+    property eggs:
+
+        def __del__(self):
+            pass
diff --git a/tests/compile/extpropertydoc.pyx b/tests/compile/extpropertydoc.pyx
new file mode 100644 (file)
index 0000000..dd043e8
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class Spam:
+
+    property eggs:
+
+        "Ova"
diff --git a/tests/compile/extpropertyget.pyx b/tests/compile/extpropertyget.pyx
new file mode 100644 (file)
index 0000000..c1a9388
--- /dev/null
@@ -0,0 +1,7 @@
+cdef class Spam:
+
+    property eggs:
+
+        def __get__(self):
+            pass
+
diff --git a/tests/compile/extpropertyset.pyx b/tests/compile/extpropertyset.pyx
new file mode 100644 (file)
index 0000000..8c6e851
--- /dev/null
@@ -0,0 +1,6 @@
+cdef class Spam:
+
+    property eggs:
+
+        def __set__(self, x):
+            pass
diff --git a/tests/compile/extsetattr.pyx b/tests/compile/extsetattr.pyx
new file mode 100644 (file)
index 0000000..4ab993a
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+    
+    def __setattr__(self, n, x):
+        pass
diff --git a/tests/compile/extsetitem.pyx b/tests/compile/extsetitem.pyx
new file mode 100644 (file)
index 0000000..20d0f99
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+    
+    def __setitem__(self, i, x):
+        pass
diff --git a/tests/compile/extsetslice.pyx b/tests/compile/extsetslice.pyx
new file mode 100644 (file)
index 0000000..a64e9e0
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class Spam:
+    
+    def __setslice__(self, Py_ssize_t i, Py_ssize_t j, x):
+        pass
diff --git a/tests/compile/for.pyx b/tests/compile/for.pyx
new file mode 100644 (file)
index 0000000..c5198d2
--- /dev/null
@@ -0,0 +1,26 @@
+def f(a, b, c):
+    cdef int i
+    for a in b:
+        i = 1
+        continue
+        i = 2
+        break
+        i = 3
+    
+    for i in b:
+        i = 1
+    
+    for a in "spam":
+        i = 1
+    
+    for a[b] in c:
+        i = 1
+    
+    for a,b in c:
+        i = 1
+    
+    for a in b,c:
+        i = 1
+
+    
+    
\ No newline at end of file
diff --git a/tests/compile/formfeed.pyx b/tests/compile/formfeed.pyx
new file mode 100644 (file)
index 0000000..a5a41b2
--- /dev/null
@@ -0,0 +1,7 @@
+cdef int x
+
+x = 42
+
+\f
+y = 88
+
diff --git a/tests/compile/fromimport.pyx b/tests/compile/fromimport.pyx
new file mode 100644 (file)
index 0000000..22936aa
--- /dev/null
@@ -0,0 +1,5 @@
+def f():
+    from spam import eggs
+    from spam.morespam import bacon, eggs, ham
+    from spam import eggs as ova
+    
\ No newline at end of file
diff --git a/tests/compile/funcptr.pyx b/tests/compile/funcptr.pyx
new file mode 100644 (file)
index 0000000..c6ca8c4
--- /dev/null
@@ -0,0 +1,6 @@
+cdef int grail():
+    cdef int (*spam)()
+    spam = &grail
+    spam = grail
+    spam()
+
diff --git a/tests/compile/getattr3ref.pyx b/tests/compile/getattr3ref.pyx
new file mode 100644 (file)
index 0000000..5fb4fdb
--- /dev/null
@@ -0,0 +1,2 @@
+cdef int f() except -1:
+    g = getattr3
diff --git a/tests/compile/globalonly.pyx b/tests/compile/globalonly.pyx
new file mode 100644 (file)
index 0000000..09444b0
--- /dev/null
@@ -0,0 +1,3 @@
+global __name__
+print __name__
+
diff --git a/tests/compile/globvardef.pyx b/tests/compile/globvardef.pyx
new file mode 100644 (file)
index 0000000..1e3debb
--- /dev/null
@@ -0,0 +1,5 @@
+cdef int a_global_int
+cdef a_global_pyobject
+
+a_global_int = 0
+a_global_pyobject = None
\ No newline at end of file
diff --git a/tests/compile/hinsen1.h b/tests/compile/hinsen1.h
new file mode 100644 (file)
index 0000000..40526fb
--- /dev/null
@@ -0,0 +1,3 @@
+typedef struct {
+       PyObject_HEAD
+} PySpamObject;
diff --git a/tests/compile/hinsen1.pyx b/tests/compile/hinsen1.pyx
new file mode 100644 (file)
index 0000000..f8ada94
--- /dev/null
@@ -0,0 +1,10 @@
+cdef extern from "hinsen1.h":
+
+    ctypedef class spam.Spam [object PySpamObject]:
+        pass
+
+
+cdef class SpamAndEggs(Spam):
+
+    cdef cook(self):
+        pass
diff --git a/tests/compile/hinsen2.pyx b/tests/compile/hinsen2.pyx
new file mode 100644 (file)
index 0000000..63540ac
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class vector:
+    def __div__(vector self, double factor):
+        result = vector()
+        return result
diff --git a/tests/compile/huss2.pyx b/tests/compile/huss2.pyx
new file mode 100644 (file)
index 0000000..c5d1b22
--- /dev/null
@@ -0,0 +1,15 @@
+cdef enum Color:
+    red
+    white
+    blue
+
+cdef void f():
+    cdef Color e
+    cdef int i
+    
+    i = red
+    i = red + 1
+    i = red | 1
+    e = white
+    i = e
+    i = e + 1
diff --git a/tests/compile/ia_cdefblock.pyx b/tests/compile/ia_cdefblock.pyx
new file mode 100644 (file)
index 0000000..97394c6
--- /dev/null
@@ -0,0 +1,33 @@
+cdef:
+
+    struct PrivFoo:
+        int i
+
+    int priv_i
+    
+    void priv_f():
+        global priv_i
+        priv_i = 42
+
+cdef public:
+
+    struct PubFoo:
+        int i
+    
+    int pub_v
+    
+    void pub_f():
+        pass
+    
+    class PubBlarg [object PubBlargObj, type PubBlargType]:
+        pass
+
+cdef api:
+
+    void api_f():
+        pass
+
+cdef public api:
+
+    void pub_api_f():
+        pass
diff --git a/tests/compile/import.pyx b/tests/compile/import.pyx
new file mode 100644 (file)
index 0000000..291f887
--- /dev/null
@@ -0,0 +1,6 @@
+def f():
+    import spam
+    import spam.eggs
+    import spam, eggs, ham
+    import spam as tasty
+    
\ No newline at end of file
diff --git a/tests/compile/ishimoto1.pyx b/tests/compile/ishimoto1.pyx
new file mode 100644 (file)
index 0000000..4cf478c
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class A:
+
+    def __getitem__(self, x):
+        pass
diff --git a/tests/compile/ishimoto4.pyx b/tests/compile/ishimoto4.pyx
new file mode 100644 (file)
index 0000000..cace041
--- /dev/null
@@ -0,0 +1,2 @@
+cdef void __stdcall f():
+    pass
diff --git a/tests/compile/jiba3.pyx b/tests/compile/jiba3.pyx
new file mode 100644 (file)
index 0000000..4f41ca4
--- /dev/null
@@ -0,0 +1,22 @@
+cdef class Position
+cdef class Point(Position)
+cdef class Vector(Point)
+cdef class CoordSyst
+
+cdef void test(float* f):
+  pass
+
+cdef class Position:
+  cdef readonly CoordSyst parent
+  
+cdef class Point(Position):
+  cdef void bug(self):
+    test(self.parent._matrix)
+
+cdef class Vector(Point):
+  cdef void bug(self):
+    test(self.parent._matrix)
+
+cdef class CoordSyst:
+  cdef float* _matrix
+
diff --git a/tests/compile/jiba4.pyx b/tests/compile/jiba4.pyx
new file mode 100644 (file)
index 0000000..46fcf77
--- /dev/null
@@ -0,0 +1,2 @@
+cdef class A:
+  cdef object x
diff --git a/tests/compile/johnson2.pyx b/tests/compile/johnson2.pyx
new file mode 100644 (file)
index 0000000..a767afb
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class C:
+
+    cdef object foo
+    cdef object __weakref__
diff --git a/tests/compile/khavkine1.pyx b/tests/compile/khavkine1.pyx
new file mode 100644 (file)
index 0000000..ccafb45
--- /dev/null
@@ -0,0 +1,9 @@
+cdef class T:
+    cdef int a[1]
+
+cdef object b
+
+cdef void f(void *obj):
+    (<T> obj).a[0] = 1
+
+b = None
diff --git a/tests/compile/kleckner1.pyx b/tests/compile/kleckner1.pyx
new file mode 100644 (file)
index 0000000..57cff9d
--- /dev/null
@@ -0,0 +1,5 @@
+def f(x,):
+    pass
+
+cdef void g(int x,):
+    pass
diff --git a/tests/compile/lepage_2.pyx b/tests/compile/lepage_2.pyx
new file mode 100644 (file)
index 0000000..79fda81
--- /dev/null
@@ -0,0 +1,2 @@
+ctypedef struct BB:
+    void (*f) (void* state)
diff --git a/tests/compile/longunsigned.pyx b/tests/compile/longunsigned.pyx
new file mode 100644 (file)
index 0000000..17e9ee2
--- /dev/null
@@ -0,0 +1,2 @@
+cdef extern unsigned long x
+cdef extern long unsigned y
diff --git a/tests/compile/nogil.pyx b/tests/compile/nogil.pyx
new file mode 100644 (file)
index 0000000..cc9d4c8
--- /dev/null
@@ -0,0 +1,5 @@
+cdef extern object g(object x) nogil
+
+cdef void f(int x) nogil:
+    cdef int y
+    y = 42
diff --git a/tests/compile/nonctypedefclass.pyx b/tests/compile/nonctypedefclass.pyx
new file mode 100644 (file)
index 0000000..abbbe4d
--- /dev/null
@@ -0,0 +1,6 @@
+cdef class spam:
+    pass
+
+cdef spam s
+
+s = None
diff --git a/tests/compile/nullptr.pyx b/tests/compile/nullptr.pyx
new file mode 100644 (file)
index 0000000..fe4b96b
--- /dev/null
@@ -0,0 +1,8 @@
+cdef char *p1
+cdef int *p2
+cdef int x
+
+p1 = NULL
+p2 = NULL
+x = p1 == NULL
+x = NULL == p2
diff --git a/tests/compile/omittedargnames.pyx b/tests/compile/omittedargnames.pyx
new file mode 100644 (file)
index 0000000..85fe92a
--- /dev/null
@@ -0,0 +1,2 @@
+cdef extern void spam(int, char *)
+
diff --git a/tests/compile/pinard4.pyx b/tests/compile/pinard4.pyx
new file mode 100644 (file)
index 0000000..69e9a56
--- /dev/null
@@ -0,0 +1 @@
+fiches_CP[:] = []
diff --git a/tests/compile/pyclass.pyx b/tests/compile/pyclass.pyx
new file mode 100644 (file)
index 0000000..c7974d2
--- /dev/null
@@ -0,0 +1,4 @@
+class Spam:
+
+    def eggs(self):
+        pass
diff --git a/tests/compile/signedtypes.pyx b/tests/compile/signedtypes.pyx
new file mode 100644 (file)
index 0000000..6ca9996
--- /dev/null
@@ -0,0 +1,16 @@
+cdef struct S:
+    char c
+    unsigned char uc
+    signed char sc
+    short s
+    unsigned short us
+    signed short ss
+    int i
+    unsigned int ui
+    signed int si
+    long l
+    unsigned long ul
+    signed long sl
+    long long ll
+    unsigned long long ull
+    signed long long sll
diff --git a/tests/compile/specmethargdefault.pyx b/tests/compile/specmethargdefault.pyx
new file mode 100644 (file)
index 0000000..fa0c5cf
--- /dev/null
@@ -0,0 +1,8 @@
+cdef class Grail:
+
+    def __cinit__(self, spam = None):
+        pass
+
+    def __init__(self, parrot = 42):
+        pass
+
diff --git a/tests/compile/specmethdocstring.pyx b/tests/compile/specmethdocstring.pyx
new file mode 100644 (file)
index 0000000..7de1a5d
--- /dev/null
@@ -0,0 +1,8 @@
+cdef class C:
+    def __init__(self):
+        "This is an unusable docstring."
+    property foo:
+        def __get__(self):
+            "So is this."
+        def __set__(self, x):
+            "And here is another one."
diff --git a/tests/compile/specmethextarg.pyx b/tests/compile/specmethextarg.pyx
new file mode 100644 (file)
index 0000000..ab1f7e9
--- /dev/null
@@ -0,0 +1,6 @@
+cdef class Spam:
+    cdef int eggs
+
+    def __iadd__(self, Spam other):
+        self.eggs = self.eggs +  other.eggs
+
diff --git a/tests/compile/tryexcept.pyx b/tests/compile/tryexcept.pyx
new file mode 100644 (file)
index 0000000..6847d2b
--- /dev/null
@@ -0,0 +1,45 @@
+def f(a, b, c, x):
+    cdef int i
+    a = b + c
+    
+    try:
+        i = 1
+        raise x
+        i = 2
+    except a:
+        i = 3
+    
+    try:
+        i = 1
+    except a:
+        i = 2
+    except b:
+        i = 3
+    
+    try:
+        i = 1
+    except a, b:
+        i = 2
+    
+    try:
+        i = 1
+    except a:
+        i = 2
+    except:
+        i = 3
+    
+    try:
+        i = 1
+    except (a, b), c[42]:
+        i = 2
+    
+    for a in b:
+        try:
+            c = x * 42
+        except:
+            i = 17
+
+    try:
+        i = 1
+    except:
+        raise
diff --git a/tests/compile/tryfinally.pyx b/tests/compile/tryfinally.pyx
new file mode 100644 (file)
index 0000000..dcbd0b8
--- /dev/null
@@ -0,0 +1,19 @@
+def f(a, b, c, x):
+    cdef int i
+    a = b + c
+    
+    try:
+        return
+        raise a
+    finally:
+        c = a - b
+    
+    for a in b:
+        try:
+            continue
+            break
+            c = a * b
+        finally:
+            i = 42
+    
+    
\ No newline at end of file
diff --git a/tests/compile/typecast.pyx b/tests/compile/typecast.pyx
new file mode 100644 (file)
index 0000000..f3945af
--- /dev/null
@@ -0,0 +1,7 @@
+cdef void f(obj):
+    cdef int i
+    cdef char *p
+    p = <char *>i
+    obj = <object>p
+    p = <char *>obj
+    
\ No newline at end of file
diff --git a/tests/compile/varargdecl.pyx b/tests/compile/varargdecl.pyx
new file mode 100644 (file)
index 0000000..2f62726
--- /dev/null
@@ -0,0 +1,2 @@
+cdef grail(char *blarg, ...):
+    pass
diff --git a/tests/compile/while.pyx b/tests/compile/while.pyx
new file mode 100644 (file)
index 0000000..31e36bc
--- /dev/null
@@ -0,0 +1,26 @@
+def f(a, b):
+    cdef int i
+    
+    while a:
+        x = 1
+
+    while a+b:
+        x = 1
+    
+    while i:
+        x = 1
+    else:
+        x = 2
+    
+    while i:
+        x = 1
+        break
+        x = 2
+    else:
+        x = 3
+    
+    while i:
+        x = 1
+        continue
+        x = 2
+    
\ No newline at end of file
diff --git a/tests/compile/withgil.pyx b/tests/compile/withgil.pyx
new file mode 100644 (file)
index 0000000..35f7512
--- /dev/null
@@ -0,0 +1,5 @@
+cdef void f() with gil:
+    x = 42
+
+cdef object g(object x) with gil:
+    pass
diff --git a/tests/compile/withnogil.pyx b/tests/compile/withnogil.pyx
new file mode 100644 (file)
index 0000000..0ccfabd
--- /dev/null
@@ -0,0 +1,13 @@
+cdef object f(object x):
+    cdef int y
+    #z = 42
+    with nogil:
+        pass#y = 17
+    #z = 88
+
+cdef object g():
+    with nogil:
+        h()
+
+cdef int h() except -1:
+    pass
diff --git a/tests/run/addop.pyx b/tests/run/addop.pyx
new file mode 100644 (file)
index 0000000..6f44d03
--- /dev/null
@@ -0,0 +1,11 @@
+def f():
+    cdef int int1, int2, int3
+    cdef char *ptr1, *ptr2, *ptr3
+    obj1 = 1
+    obj2 = 2
+    obj3 = 3
+    int1 = int2 + int3
+    ptr1 = ptr2 + int3
+    ptr1 = int2 + ptr3
+    obj1 = obj2 + int3
+    
\ No newline at end of file
diff --git a/tests/run/addressof.pyx b/tests/run/addressof.pyx
new file mode 100644 (file)
index 0000000..a7dd165
--- /dev/null
@@ -0,0 +1,4 @@
+def f():
+    cdef int i
+    cdef int *p
+    p = &i
diff --git a/tests/run/altet2.pyx b/tests/run/altet2.pyx
new file mode 100644 (file)
index 0000000..6110e2d
--- /dev/null
@@ -0,0 +1,10 @@
+__doc__ = """
+  >>> iter(C())
+  Traceback (most recent call last):
+  TypeError: iter() returned non-iterator of type 'NoneType'
+"""
+
+cdef class C:
+
+    def __iter__(self):
+        "This is a doc string."
diff --git a/tests/run/ass2global.pyx b/tests/run/ass2global.pyx
new file mode 100644 (file)
index 0000000..cc4fa3a
--- /dev/null
@@ -0,0 +1,4 @@
+def f(a):
+    global f
+    f = a
+    f = 42
diff --git a/tests/run/ass2local.pyx b/tests/run/ass2local.pyx
new file mode 100644 (file)
index 0000000..20524b1
--- /dev/null
@@ -0,0 +1,2 @@
+def f():
+    a = 42
diff --git a/tests/run/assert.pyx b/tests/run/assert.pyx
new file mode 100644 (file)
index 0000000..b9e435c
--- /dev/null
@@ -0,0 +1,8 @@
+def f(a, b):
+    cdef int i
+    assert a
+    assert a+b
+    assert i
+
+def g(a, b):
+    assert a, b
diff --git a/tests/run/attr.pyx b/tests/run/attr.pyx
new file mode 100644 (file)
index 0000000..2927acb
--- /dev/null
@@ -0,0 +1,6 @@
+def f(a, b):
+    a = b.spam
+    a.spam = b
+    a = b.spam.eggs
+    a.spam.eggs = b
+    
\ No newline at end of file
diff --git a/tests/run/baas3.pyx b/tests/run/baas3.pyx
new file mode 100644 (file)
index 0000000..a292ef7
--- /dev/null
@@ -0,0 +1,7 @@
+cdef class MyClass:
+    pass
+
+def foo(MyClass c):
+    cdef MyClass res
+    res = c
+    return res
diff --git a/tests/run/backquote.pyx b/tests/run/backquote.pyx
new file mode 100644 (file)
index 0000000..bd77227
--- /dev/null
@@ -0,0 +1,4 @@
+def f(obj1, obj2):
+    obj1 = `obj2`
+    obj1 = `42`
+    
\ No newline at end of file
diff --git a/tests/run/behnel1.pyx b/tests/run/behnel1.pyx
new file mode 100644 (file)
index 0000000..4382350
--- /dev/null
@@ -0,0 +1,9 @@
+cdef class Spam:
+    cdef eggs(self):
+        pass
+
+cdef Spam spam():
+    pass
+
+def viking():
+    return spam().eggs()
diff --git a/tests/run/behnel2.pyx b/tests/run/behnel2.pyx
new file mode 100644 (file)
index 0000000..b7695b6
--- /dev/null
@@ -0,0 +1,11 @@
+__doc__ = """
+    >>> y
+    1
+    >>> y and {}
+    {}
+    >>> x
+    {}
+"""
+
+y = 1
+x = y and {}
diff --git a/tests/run/behnel3.pyx b/tests/run/behnel3.pyx
new file mode 100644 (file)
index 0000000..6ec8095
--- /dev/null
@@ -0,0 +1,10 @@
+__doc__ = """
+    >>> y
+    >>> y or {}
+    {}
+    >>> x
+    {}
+"""
+
+y = None
+x = y or {}
diff --git a/tests/run/bishop1.pyx b/tests/run/bishop1.pyx
new file mode 100644 (file)
index 0000000..7b9b620
--- /dev/null
@@ -0,0 +1,8 @@
+cdef class fmatrix:
+  cdef int foo
+
+  def __setitem__(self, int key, int value):
+    if key:
+      self.foo = value
+      return
+    self.foo = not value
diff --git a/tests/run/bishop2.pyx b/tests/run/bishop2.pyx
new file mode 100644 (file)
index 0000000..0853117
--- /dev/null
@@ -0,0 +1,4 @@
+cdef class foo:
+
+  def __contains__(self, key):
+    return 1
diff --git a/tests/run/boolop.pyx b/tests/run/boolop.pyx
new file mode 100644 (file)
index 0000000..dfafab4
--- /dev/null
@@ -0,0 +1,13 @@
+cdef void foo(obj1, obj2, obj3, obj4, obj5):
+    cdef int bool1, bool2, bool3, bool4
+    cdef char *ptr
+    cdef float f
+    bool3 = bool1 and bool2
+    bool3 = bool1 or bool2
+    bool3 = obj1 and obj2
+    bool3 = bool1 and ptr
+    bool3 = bool1 and f
+    bool4 = bool1 and bool2 and bool3
+    bool4 = bool1 or bool2 and bool3
+    obj4 = obj1 and obj2 and obj3
+    obj5 = (obj1 + obj2 + obj3) and obj4
diff --git a/tests/run/cfuncdef.pyx b/tests/run/cfuncdef.pyx
new file mode 100644 (file)
index 0000000..f277974
--- /dev/null
@@ -0,0 +1,12 @@
+cdef void ftang():
+    cdef int x
+    x = 0
+
+cdef int foo(int i, char c):
+    cdef float f, g
+    f = 0
+    g = 0
+
+cdef spam(int i, obj, object object):
+    cdef char c
+    c = 0
diff --git a/tests/run/cintop.pyx b/tests/run/cintop.pyx
new file mode 100644 (file)
index 0000000..6a60057
--- /dev/null
@@ -0,0 +1,13 @@
+def f():
+    cdef int int1, int2, int3
+    cdef char char1
+    cdef long long1, long2
+    int1 = int2 | int3
+    int1 = int2 ^ int3
+    int1 = int2 & int3
+    int1 = int2 << int3
+    int1 = int2 >> int3
+    int1 = int2 << int3 | int2 >> int3
+    long1 = char1 | long2
+    
+    
\ No newline at end of file
diff --git a/tests/run/classpass.pyx b/tests/run/classpass.pyx
new file mode 100644 (file)
index 0000000..f644f35
--- /dev/null
@@ -0,0 +1,2 @@
+class Spam: pass
+
diff --git a/tests/run/concatcstrings.pyx b/tests/run/concatcstrings.pyx
new file mode 100644 (file)
index 0000000..ce1b92c
--- /dev/null
@@ -0,0 +1,2 @@
+spam = "C string 1" + "C string 2"
+
diff --git a/tests/run/cstringmul.pyx b/tests/run/cstringmul.pyx
new file mode 100644 (file)
index 0000000..bef435a
--- /dev/null
@@ -0,0 +1,3 @@
+spam = "eggs" * 42
+grail = 17 * "tomato"
+
diff --git a/tests/run/cstruct.pyx b/tests/run/cstruct.pyx
new file mode 100644 (file)
index 0000000..1529e1c
--- /dev/null
@@ -0,0 +1,19 @@
+cdef struct Grail
+
+cdef struct Spam:
+    int i
+    char c
+    float *p[42]
+    Grail *g
+
+cdef struct Grail:
+    Spam *s
+
+cdef Spam spam, ham
+
+cdef void eggs(Spam s):
+    cdef int j
+    j = s.i
+    s.i = j
+
+spam = ham
diff --git a/tests/run/cunion.pyx b/tests/run/cunion.pyx
new file mode 100644 (file)
index 0000000..72ad766
--- /dev/null
@@ -0,0 +1,13 @@
+cdef union Spam:
+    int i
+    char c
+    float *p[42]
+
+cdef Spam spam, ham
+
+cdef void eggs(Spam s):
+    cdef int j
+    j = s.i
+    s.i = j
+
+spam = ham
diff --git a/tests/run/cvardef.pyx b/tests/run/cvardef.pyx
new file mode 100644 (file)
index 0000000..57d4be3
--- /dev/null
@@ -0,0 +1,45 @@
+def f():
+    cdef char a_char
+    cdef short a_short
+    cdef int i1, i2
+    cdef long a_long
+    cdef float a_float
+    cdef double a_double
+    cdef unsigned char an_unsigned_char
+    cdef unsigned short an_unsigned_short
+    cdef unsigned int an_unsigned_int
+    cdef unsigned long an_unsigned_long
+    cdef char *a_char_ptr, *another_char_ptr
+    cdef char **a_char_ptr_ptr
+    cdef char ***a_char_ptr_ptr_ptr
+    cdef char a_sized_char_array[10]
+    cdef char a_2d_char_array[10][20]
+    cdef char *a_2d_char_ptr_array[10][20]
+    cdef char **a_2d_char_ptr_ptr_array[10][20]
+    cdef int (*a_0arg_function)()
+    cdef int (*a_1arg_function)(int i)
+    cdef int (*a_2arg_function)(int i, int j)
+    cdef void (*a_void_function)()
+    a_char = 0
+    a_short = 0
+    i1 = 0
+    i2 = 0
+    a_long = 0
+    a_float = 0
+    a_double = 0
+    an_unsigned_char = 0
+    an_unsigned_short = 0
+    an_unsigned_int = 0
+    an_unsigned_long = 0
+    a_char_ptr = NULL
+    another_char_ptr = NULL
+    a_char_ptr_ptr = NULL
+    a_char_ptr_ptr_ptr = NULL
+    a_sized_char_array[0] = 0
+    a_2d_char_array[0][0] = 0
+    a_2d_char_ptr_array[0][0] = NULL
+    a_2d_char_ptr_ptr_array[0][0] = NULL
+    a_0arg_function = NULL
+    a_1arg_function = NULL
+    a_2arg_function = NULL
+    a_void_function = NULL
diff --git a/tests/run/dict.pyx b/tests/run/dict.pyx
new file mode 100644 (file)
index 0000000..2ae22a3
--- /dev/null
@@ -0,0 +1,7 @@
+def f(adict, key1, value1, key2, value2):
+    adict = {}
+    adict = {key1:value1}
+    adict = {key1:value1, key2:value2}
+    adict = {key1:value1, key2:value2,}
+    adict = {"parrot":"resting", "answer":42}
+    
\ No newline at end of file
diff --git a/tests/run/dietachmayer1.pyx b/tests/run/dietachmayer1.pyx
new file mode 100644 (file)
index 0000000..d86f873
--- /dev/null
@@ -0,0 +1,4 @@
+def test():
+    cdef float v[10][10]
+    v[1][2] = 1.0
+    print v[1][2]
diff --git a/tests/run/docstrings.pyx b/tests/run/docstrings.pyx
new file mode 100644 (file)
index 0000000..a710203
--- /dev/null
@@ -0,0 +1,14 @@
+"Welcome to the parrot module. It is currently resting."
+
+def zap(polly, volts):
+    "Wake up polly."
+
+class Parrot:
+    "Standard Norwegian Blue."
+    
+    def admire_plumage(self):
+        "Lovely, ain't it?"
+
+cdef class SuperParrot:
+    "Special high-performance model."
+
diff --git a/tests/run/exarkun.pyx b/tests/run/exarkun.pyx
new file mode 100644 (file)
index 0000000..4ca7ad1
--- /dev/null
@@ -0,0 +1,10 @@
+cdef class Point:
+    cdef double x, y, z
+    def __init__(self, double x, double y, double z):
+        self.x = x
+        self.y = y
+        self.z = z
+
+    # XXX
+    def __add__(self, other):
+        return Point(self.x + other.x, self.y + other.y, self.z + other.z)
diff --git a/tests/run/extclasspass.pyx b/tests/run/extclasspass.pyx
new file mode 100644 (file)
index 0000000..b8b19ee
--- /dev/null
@@ -0,0 +1,2 @@
+cdef class Eggs: pass
+
diff --git a/tests/run/extinherit.pyx b/tests/run/extinherit.pyx
new file mode 100644 (file)
index 0000000..ffd1245
--- /dev/null
@@ -0,0 +1,15 @@
+cdef class Parrot:
+    cdef object name
+    cdef int alive
+
+cdef class Norwegian(Parrot):
+    cdef object plumage_colour
+
+cdef void rest(Norwegian polly):
+    cdef Parrot fred
+    cdef object spam
+    fred = polly
+    polly = fred
+    polly = spam
+    spam = polly
+    polly.alive = 0
diff --git a/tests/run/extinstantiate.pyx b/tests/run/extinstantiate.pyx
new file mode 100644 (file)
index 0000000..d64ad0a
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class Spam:
+    pass
+
+def f():
+    s = Spam()
diff --git a/tests/run/extlen.pyx b/tests/run/extlen.pyx
new file mode 100644 (file)
index 0000000..e03a56d
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class Spam:
+
+    def __len__(self):
+        return 0
+
diff --git a/tests/run/extstarargs.pyx b/tests/run/extstarargs.pyx
new file mode 100644 (file)
index 0000000..5757b23
--- /dev/null
@@ -0,0 +1,16 @@
+cdef class Silly:
+
+    def __init__(self, *a):
+        pass
+
+    def spam(self, x, y, z):
+        pass
+    
+    def grail(self, x, y, z, *a):
+        pass
+    
+    def swallow(self, x, y, z, **k):
+        pass
+    
+    def creosote(self, x, y, z, *a, **k):
+        pass
diff --git a/tests/run/exttype.pyx b/tests/run/exttype.pyx
new file mode 100644 (file)
index 0000000..408a345
--- /dev/null
@@ -0,0 +1,45 @@
+__doc__ = """
+    >>> s = Spam(12)
+    >>> s.eat()
+    12 42
+    >>> f(s)
+    Traceback (most recent call last):
+    AttributeError: 'exttype.Spam' object has no attribute 'foo'
+    >>> s.eat()
+    12 42
+
+    >>> class Spam2(Spam):
+    ...     foo = 1
+    >>> s = Spam2(12)
+    >>> s.eat()
+    12 42
+    >>> f(s)
+    >>> s.eat()
+    12 42
+"""
+
+cdef gobble(a, b):
+    print a, b
+
+cdef class Spam:
+
+    cdef eggs
+    cdef int ham
+
+    def __cinit__(self, eggs):
+        self.eggs = eggs
+        self.ham = 42
+    
+    def __dealloc__(self):
+        self.ham = 0
+    
+    def eat(self):
+        gobble(self.eggs, self.ham)
+
+def f(Spam spam):
+    x = spam.eggs
+    y = spam.ham
+    z = spam.foo
+    spam.eggs = x
+    spam.ham = y
+    spam.foo = z
diff --git a/tests/run/filenames.pxi b/tests/run/filenames.pxi
new file mode 100644 (file)
index 0000000..c45d71c
--- /dev/null
@@ -0,0 +1 @@
+spam = "ftang"
diff --git a/tests/run/filenames.pyx b/tests/run/filenames.pyx
new file mode 100644 (file)
index 0000000..ae7f419
--- /dev/null
@@ -0,0 +1,4 @@
+include "filenames.pxi"
+
+foo = 42
+
diff --git a/tests/run/if.pyx b/tests/run/if.pyx
new file mode 100644 (file)
index 0000000..e3176a3
--- /dev/null
@@ -0,0 +1,19 @@
+def f(a, b):
+    if a:
+        x = 1
+        
+    if a+b:
+        x = 1
+        
+    if a:
+        x = 1
+    elif b:
+        x = 2
+    
+    if a:
+        x = 1
+    elif b:
+        x = 2
+    else:
+        x = 3
+        
\ No newline at end of file
diff --git a/tests/run/ishimoto2.pyx b/tests/run/ishimoto2.pyx
new file mode 100644 (file)
index 0000000..3ab9402
--- /dev/null
@@ -0,0 +1,3 @@
+class C:
+    def xxx(self, p="a b"):
+        pass
diff --git a/tests/run/ishimoto3.pyx b/tests/run/ishimoto3.pyx
new file mode 100644 (file)
index 0000000..1baf0b8
--- /dev/null
@@ -0,0 +1,8 @@
+cdef class C1:
+    pass
+
+cdef class C2:
+    cdef C1 c1
+
+    def __init__(self, arg):
+        self.c1 = arg
diff --git a/tests/run/jarausch1.pyx b/tests/run/jarausch1.pyx
new file mode 100644 (file)
index 0000000..855fb51
--- /dev/null
@@ -0,0 +1,6 @@
+__doc__ = """
+   >>> py_x = r'\\\\'
+   >>> assert x == py_x
+"""
+
+x = r'\\'
diff --git a/tests/run/kostyrka.pyx b/tests/run/kostyrka.pyx
new file mode 100644 (file)
index 0000000..baef2ff
--- /dev/null
@@ -0,0 +1,3 @@
+cdef class TEST:
+    def __contains__(self, x):
+        return 42
diff --git a/tests/run/kostyrka2.pyx b/tests/run/kostyrka2.pyx
new file mode 100644 (file)
index 0000000..0dfe2e0
--- /dev/null
@@ -0,0 +1,2 @@
+class X:
+        slots = ["", ]
diff --git a/tests/run/kwonlyargs.pyx b/tests/run/kwonlyargs.pyx
new file mode 100644 (file)
index 0000000..a1be9cd
--- /dev/null
@@ -0,0 +1,17 @@
+def c(a, b, c):
+    z = 33
+
+def d(a, b, *, c = 88):
+    z = 44
+
+def e(a, b, c = 88, **kwds):
+    z = 55
+
+def f(a, b, *, c, d = 42):
+    z = 66
+
+def g(a, b, *, c, d = 42, e = 17, f, **kwds):
+    z = 77
+
+def h(a, b, *args, c, d = 42, e = 17, f, **kwds):
+    z = 88
diff --git a/tests/run/lepage_1.pyx b/tests/run/lepage_1.pyx
new file mode 100644 (file)
index 0000000..551bc7f
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class A:
+    cdef double x[3]
+
+    def __getitem__(self,i):
+        return self.x[i]
diff --git a/tests/run/list.pyx b/tests/run/list.pyx
new file mode 100644 (file)
index 0000000..550494c
--- /dev/null
@@ -0,0 +1,7 @@
+def f(obj1, obj2, obj3, obj4, obj5):
+    obj1 = []
+    obj1 = [obj2]
+    obj1 = [obj2, obj3]
+    obj1 = [obj2, obj3, obj4]
+    obj1 = [17, 42, 88]
+    
\ No newline at end of file
diff --git a/tests/run/literals.pyx b/tests/run/literals.pyx
new file mode 100644 (file)
index 0000000..158009a
--- /dev/null
@@ -0,0 +1,44 @@
+def foo():
+    a = 42
+    a1 = 0123
+    a2 = 0xabc
+    a3 = 0xDEF
+    a4 = 1234567890L
+    b = 42.88e17
+    b0a = 1.
+    b0b = .1
+    b0c = 1.1
+    b0d = 1.e1
+    b0e = .1e1
+    b0f = 1.1e1
+    b0g = 1.1e-1
+    b0h = 1e1
+    b1 = 3j
+    b2 = 3.1415J
+    b3 = c'X'
+    c = "spanish inquisition"
+    d = "this" "parrot" "is" "resting"
+    e = 'single quoted string'
+    f = '"this is quoted"'
+    g = '''Triple single quoted string.'''
+    h = """Triple double quoted string."""
+    g1 = '''Two line triple
+single quoted string.'''
+    h1 = """Two line triple
+double quoted string."""
+    i = 'This string\
+ has an ignored newline.'
+    j = 'One-char escapes: \'\"\\\a\b\f\n\r\t\v'
+    k = 'Oct and hex escapes: \1 \12 \123 \x45 \xaf \xAF'
+    l = r'''This is\
+a \three \line
+raw string with some backslashes.'''
+    m = 'Three backslashed ordinaries: \c\g\+'
+    n = '''Triple single quoted string 
+with ' and " quotes'''
+    o = """Triple double quoted string 
+with ' and " quotes"""
+    p = "name_like_string"
+    q = "NameLikeString2"
+    r = "99_percent_un_namelike"
+    s = "Not an \escape"
diff --git a/tests/run/modbody.pyx b/tests/run/modbody.pyx
new file mode 100644 (file)
index 0000000..0cf3e14
--- /dev/null
@@ -0,0 +1,9 @@
+def f():
+    pass
+    
+g = 42
+x = "spam"
+y = "eggs"
+if g:
+    z = x + y
+
diff --git a/tests/run/modop.pyx b/tests/run/modop.pyx
new file mode 100644 (file)
index 0000000..9298d31
--- /dev/null
@@ -0,0 +1,10 @@
+def f():
+    cdef int int1, int2, int3
+    cdef char *str2, *str3
+    obj1 = 1
+    obj2 = 2
+    obj3 = 3
+    int1 = int2 % int3
+    obj1 = str2 % str3
+    obj1 = obj2 % obj3
+    
\ No newline at end of file
diff --git a/tests/run/multass.pyx b/tests/run/multass.pyx
new file mode 100644 (file)
index 0000000..e582065
--- /dev/null
@@ -0,0 +1,8 @@
+cdef void f():
+    cdef object obj1a, obj2a, obj3a, obj1b, obj2b, obj3b
+    cdef int int1, int2
+    cdef char *ptr1, *ptr2
+    obj1a, obj2a = obj1b, obj2b
+    obj1a, [obj2a, obj3a] = [obj1b, (obj2b, obj3b)]
+    int1, ptr1, obj1a = int2, ptr2, obj1b
+    obj1a, obj2a, obj3a = obj1b + 1, obj2b + 2, obj3b + 3
diff --git a/tests/run/naanou_1.pyx b/tests/run/naanou_1.pyx
new file mode 100644 (file)
index 0000000..d79ad65
--- /dev/null
@@ -0,0 +1,2 @@
+def f(a, *p, **n):
+    pass
diff --git a/tests/run/new_style_exceptions.pyx b/tests/run/new_style_exceptions.pyx
new file mode 100644 (file)
index 0000000..8ae7240
--- /dev/null
@@ -0,0 +1,9 @@
+import sys
+
+def test(obj):
+    print "Raising:", repr(obj)
+    try:
+        raise obj
+    except:
+        info = sys.exc_info()
+        print "Caught: %r %r" % (info[0], info[1])
diff --git a/tests/run/pass.pyx b/tests/run/pass.pyx
new file mode 100644 (file)
index 0000000..4f28bc7
--- /dev/null
@@ -0,0 +1,2 @@
+def f():
+    pass
diff --git a/tests/run/pinard5.pyx b/tests/run/pinard5.pyx
new file mode 100644 (file)
index 0000000..32c6527
--- /dev/null
@@ -0,0 +1,10 @@
+cdef class Tri:
+    pass
+    
+cdef class Curseur:
+    cdef Tri tri
+    def detail(self):
+        produire_fiches(self.tri)
+
+cdef produire_fiches(Tri tri):
+    pass
diff --git a/tests/run/pinard6.pyx b/tests/run/pinard6.pyx
new file mode 100644 (file)
index 0000000..98d0305
--- /dev/null
@@ -0,0 +1,2 @@
+x = 1,
+x = 1, 2,
diff --git a/tests/run/pinard7.pyx b/tests/run/pinard7.pyx
new file mode 100644 (file)
index 0000000..4a61196
--- /dev/null
@@ -0,0 +1,9 @@
+cdef enum Mode:
+    a = 1
+    b = 2
+
+cdef class Curseur:
+    cdef Mode mode
+
+    def method(self):
+        assert False, self.mode
diff --git a/tests/run/pinard8.pyx b/tests/run/pinard8.pyx
new file mode 100644 (file)
index 0000000..aae2b50
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class Fiche:
+
+    def __setitem__(self, element, valeur):
+        if valeur is None:
+            return
diff --git a/tests/run/print.pyx b/tests/run/print.pyx
new file mode 100644 (file)
index 0000000..650f05c
--- /dev/null
@@ -0,0 +1,7 @@
+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/pycmp.pyx b/tests/run/pycmp.pyx
new file mode 100644 (file)
index 0000000..ef0ece9
--- /dev/null
@@ -0,0 +1,29 @@
+__doc__ = """
+    >>> f()
+    >>> g()
+"""
+
+def f():
+    cdef int bool, int1, int2
+    obj1 = 1
+    obj2 = 2
+    bool = obj1 == obj2
+    assert not bool
+    bool = obj1 <> int2
+    assert bool
+    bool = int1 == obj2
+    assert not bool
+    bool = obj1 is obj2
+    assert not bool
+    bool = obj1 is not obj2
+    assert bool
+
+def g():
+    cdef int bool
+    obj1 = 1
+    obj2 = []
+    bool = obj1 in obj2
+    assert not bool
+    bool = obj1 not in obj2
+    assert bool
+    
diff --git a/tests/run/pyextattrref.pyx b/tests/run/pyextattrref.pyx
new file mode 100644 (file)
index 0000000..cee1118
--- /dev/null
@@ -0,0 +1,8 @@
+cdef class Eggs:
+    cdef object ham
+
+cdef class Spam:
+    cdef Eggs eggs
+
+cdef void tomato(Spam s):
+    food = s.eggs.ham
diff --git a/tests/run/pyintop.pyx b/tests/run/pyintop.pyx
new file mode 100644 (file)
index 0000000..f6f3eea
--- /dev/null
@@ -0,0 +1,11 @@
+def f():
+    obj1 = 1
+    obj2 = 2
+    obj3 = 3
+    obj1 = obj2 | obj3
+    obj1 = obj2 ^ obj3
+    obj1 = obj2 & obj3
+    obj1 = obj2 << obj3
+    obj1 = obj2 >> obj3
+    obj1 = obj2 << obj3 | obj2 >> obj3
+    
\ No newline at end of file
diff --git a/tests/run/pynumop.pyx b/tests/run/pynumop.pyx
new file mode 100644 (file)
index 0000000..c4f7e09
--- /dev/null
@@ -0,0 +1,20 @@
+__doc__ = """
+    >>> f()
+    6
+    >>> g()
+    0
+"""
+
+def f():
+    obj1 = 1
+    obj2 = 2
+    obj3 = 3
+    obj1 = obj2 * obj3
+    return obj1
+
+def g():
+    obj1 = 1
+    obj2 = 2
+    obj3 = 3
+    obj1 = obj2 / obj3
+    return obj1
diff --git a/tests/run/r_addint.pyx b/tests/run/r_addint.pyx
new file mode 100644 (file)
index 0000000..95e73e8
--- /dev/null
@@ -0,0 +1,14 @@
+__doc__ = """
+    >>> def test(a, b):
+    ...     print a, b, add(a, b)
+
+    >>> test(1, 2)
+    1 2 3
+    >>> test(17.3, 88.6)
+    17.3 88.6 105.9
+    >>> test("eggs", "spam")
+    eggs spam eggsspam
+"""
+
+def add(x, y):
+    return x + y
diff --git a/tests/run/r_argdefault.pyx b/tests/run/r_argdefault.pyx
new file mode 100644 (file)
index 0000000..0532f8a
--- /dev/null
@@ -0,0 +1,17 @@
+__doc__ = """
+  >>> swallow(name = "Brian")
+  This swallow is called Brian
+  >>> swallow(airspeed = 42)
+  This swallow is flying at 42 furlongs per fortnight
+  >>> swallow(coconuts = 3)
+  This swallow is carrying 3 coconuts
+"""
+
+def swallow(name = None, airspeed = None, coconuts = None):
+    if name is not None:
+        print "This swallow is called", name
+    if airspeed is not None:
+        print "This swallow is flying at", airspeed, "furlongs per fortnight"
+    if coconuts is not None:
+        print "This swallow is carrying", coconuts, "coconuts"
+
diff --git a/tests/run/r_barbieri1.pyx b/tests/run/r_barbieri1.pyx
new file mode 100644 (file)
index 0000000..e505bf1
--- /dev/null
@@ -0,0 +1,15 @@
+__doc__ = """
+  >>> try:
+  ...     B()
+  ... except Exception, e:
+  ...     print "%s: %s" % (e.__class__.__name__, e)
+  Exception: crash-me
+"""
+
+cdef class A:
+    def __cinit__(self):
+        raise Exception("crash-me")
+
+cdef class B(A):
+    def __cinit__(self):
+        print "hello world"
diff --git a/tests/run/r_bishop3.pyx b/tests/run/r_bishop3.pyx
new file mode 100644 (file)
index 0000000..1b4d62b
--- /dev/null
@@ -0,0 +1,25 @@
+__doc__ = """
+foo = Foo()
+fee = Fee()
+faa = Faa()
+fee.bof()
+faa.bof()
+"""
+
+cdef class Foo:
+  cdef int val
+
+  def __init__(self):
+    self.val = 0
+
+
+cdef class Fee(Foo):
+
+  def bof(self):
+    print 'Fee bof', self.val
+
+
+cdef class Faa(Fee):
+
+  def bof(self):
+    print 'Foo bof', self.val
diff --git a/tests/run/r_bowden1.pyx b/tests/run/r_bowden1.pyx
new file mode 100644 (file)
index 0000000..575edc2
--- /dev/null
@@ -0,0 +1,12 @@
+__doc__ = """
+print f(100)
+print g(3000000000)
+"""
+
+def f(x):
+    cdef unsigned long long ull
+    ull = x
+    return ull + 1
+
+def g(unsigned long x):
+    return x + 1
diff --git a/tests/run/r_delgado_1.pyx b/tests/run/r_delgado_1.pyx
new file mode 100644 (file)
index 0000000..bef3a03
--- /dev/null
@@ -0,0 +1,15 @@
+__doc__ = """
+try:
+    eggs().eat()
+except RuntimeError, e:
+    print "%s: %s" % (e.__class__.__name__, e)
+"""
+
+cdef class eggs:
+
+  def __dealloc__(self):
+    pass
+
+  def eat(self):
+    raise RuntimeError("I don't like that")
+
diff --git a/tests/run/r_docstrings.pyx b/tests/run/r_docstrings.pyx
new file mode 100644 (file)
index 0000000..2299996
--- /dev/null
@@ -0,0 +1,18 @@
+__doc__ = """
+    >>> print f.__doc__
+    This is a function docstring.
+    >>> print C.__doc__
+    This is a class docstring.
+    >>> print T.__doc__
+    This is an extension type docstring.
+"""
+
+def f():
+    "This is a function docstring."
+
+class C:
+    "This is a class docstring."
+
+cdef class T:
+    "This is an extension type docstring."
+
diff --git a/tests/run/r_extcomplex2.pyx b/tests/run/r_extcomplex2.pyx
new file mode 100644 (file)
index 0000000..0131700
--- /dev/null
@@ -0,0 +1,24 @@
+__doc__ = """
+    >>> c = eggs()
+    >>> print "eggs returned:", c
+    eggs returned: (17+42j)
+    >>> spam(c)
+    Real: 17.0
+    Imag: 42.0
+"""
+
+cdef extern from "complexobject.h":
+    
+    struct Py_complex:
+        double real
+        double imag
+    
+    ctypedef class __builtin__.complex [object PyComplexObject]:
+        cdef Py_complex cval
+    
+def spam(complex c):
+    print "Real:", c.cval.real
+    print "Imag:", c.cval.imag
+
+def eggs():
+    return complex(17, 42)
diff --git a/tests/run/r_extstarargs.pyx b/tests/run/r_extstarargs.pyx
new file mode 100644 (file)
index 0000000..34740ae
--- /dev/null
@@ -0,0 +1,39 @@
+__doc__ = """
+  >>> s = Swallow("Brian", 42)
+  Name: Brian
+  Airspeed: 42
+  Extra args: ()
+  Extra keywords: {}
+
+  >>> s = Swallow("Brian", 42, "African")
+  Name: Brian
+  Airspeed: 42
+  Extra args: ('African',)
+  Extra keywords: {}
+
+  >>> s = Swallow("Brian", airspeed = 42)
+  Name: Brian
+  Airspeed: 42
+  Extra args: ()
+  Extra keywords: {}
+
+  >>> s = Swallow("Brian", airspeed = 42, species = "African", coconuts = 3)
+  Name: Brian
+  Airspeed: 42
+  Extra args: ()
+  Extra keywords: {'coconuts': 3, 'species': 'African'}
+
+  >>> s = Swallow("Brian", 42, "African", coconuts = 3)
+  Name: Brian
+  Airspeed: 42
+  Extra args: ('African',)
+  Extra keywords: {'coconuts': 3}
+"""
+
+cdef class Swallow:
+
+    def __init__(self, name, airspeed, *args, **kwds):
+        print "Name:", name
+        print "Airspeed:", airspeed
+        print "Extra args:", args
+        print "Extra keywords:", kwds
diff --git a/tests/run/r_forloop.pyx b/tests/run/r_forloop.pyx
new file mode 100644 (file)
index 0000000..189900f
--- /dev/null
@@ -0,0 +1,13 @@
+__doc__ = """
+  >>> go()
+  Spam!
+  Spam!
+  Spam!
+  Spam!
+  Spam!
+"""
+
+def go():
+    for i in range(5):
+        print "Spam!"
+
diff --git a/tests/run/r_hordijk1.pyx b/tests/run/r_hordijk1.pyx
new file mode 100644 (file)
index 0000000..3d583f8
--- /dev/null
@@ -0,0 +1,17 @@
+__doc__ = """
+  >>> try:
+  ...     s = Spam()
+  ... except StandardError, e:
+  ...     print "Exception:", e
+  ... else:
+  ...     print "Did not raise the expected exception"
+  Exception: This is not a spanish inquisition
+"""
+
+cdef extern from "Python.h":
+    ctypedef class types.ListType [object PyListObject]:
+        pass
+
+cdef class Spam(ListType):
+    def __init__(self):
+        raise StandardError("This is not a spanish inquisition")
diff --git a/tests/run/r_huss3.pyx b/tests/run/r_huss3.pyx
new file mode 100644 (file)
index 0000000..cc8ab2f
--- /dev/null
@@ -0,0 +1,19 @@
+__doc__ = """
+try:
+    foo()
+except Exception, e:
+    print "%s: %s" % (e.__class__.__name__, e)
+"""
+
+def bar():
+    try:
+        raise TypeError
+    except TypeError:
+        pass
+
+def foo():
+    try:
+        raise ValueError
+    except ValueError, e:
+        bar()
+        raise
diff --git a/tests/run/r_jeff_epler_1.pyx b/tests/run/r_jeff_epler_1.pyx
new file mode 100644 (file)
index 0000000..39975c9
--- /dev/null
@@ -0,0 +1,9 @@
+__doc__ = """
+print r_jeff_epler_1.blowup([2, 3, 5])
+"""
+
+def blowup(p):
+    cdef int n, i
+    n = 10
+    i = 1
+    return n % p[i]
diff --git a/tests/run/r_jiba1.pxd b/tests/run/r_jiba1.pxd
new file mode 100644 (file)
index 0000000..7e667a4
--- /dev/null
@@ -0,0 +1,5 @@
+cdef class Parrot:
+       cdef void describe(self)
+
+cdef class Norwegian(Parrot):
+       pass
diff --git a/tests/run/r_jiba1.pyx b/tests/run/r_jiba1.pyx
new file mode 100644 (file)
index 0000000..2034b38
--- /dev/null
@@ -0,0 +1,18 @@
+cdef class Parrot:
+
+    cdef void describe(self):
+        print "This parrot is resting."
+
+    def describe_python(self):
+        self.describe()
+
+cdef class Norwegian(Parrot):
+
+    cdef void describe(self):
+        print "Lovely plumage!"
+
+cdef Parrot p1, p2
+p1 = Parrot()
+p2 = Norwegian()
+p1.describe()
+p2.describe()
diff --git a/tests/run/r_lepage_3.pyx b/tests/run/r_lepage_3.pyx
new file mode 100644 (file)
index 0000000..5f59490
--- /dev/null
@@ -0,0 +1,9 @@
+__doc__ = """
+g = r_lepage_3.Grail()
+g("spam", 42, ["tomato", "sandwich"])
+"""
+
+cdef class Grail:
+
+    def __call__(self, x, y, z):
+        print "Grail called with:", x, y, z
diff --git a/tests/run/r_mang1.pyx b/tests/run/r_mang1.pyx
new file mode 100644 (file)
index 0000000..fcf140a
--- /dev/null
@@ -0,0 +1,2 @@
+import re
+t = re.search('(\d+)', '-2.80 98\n').groups()
diff --git a/tests/run/r_mcintyre1.pyx b/tests/run/r_mcintyre1.pyx
new file mode 100644 (file)
index 0000000..b0d19ce
--- /dev/null
@@ -0,0 +1,4 @@
+class Bicycle:
+
+    def fall_off(self, how_hard = "extremely"):
+        print "Falling off", how_hard, "hard"
diff --git a/tests/run/r_mitch_chapman_2.pyx b/tests/run/r_mitch_chapman_2.pyx
new file mode 100644 (file)
index 0000000..afbed93
--- /dev/null
@@ -0,0 +1,6 @@
+def boolExpressionsFail():
+    dict = {1: 1}
+    if not dict.has_key("2b"):
+        return "Not 2b"
+    else:
+        return "2b?"
diff --git a/tests/run/r_primes.pyx b/tests/run/r_primes.pyx
new file mode 100644 (file)
index 0000000..b74a44a
--- /dev/null
@@ -0,0 +1,23 @@
+__doc__ = """
+    >>> print primes(20)
+    [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
+"""
+
+def primes(int kmax):
+    cdef int n, k, i
+    cdef int p[1000]
+    result = []
+    if kmax > 1000:
+        kmax = 1000
+    k = 0
+    n = 2
+    while k < kmax:
+        i = 0
+        while i < k and n % p[i] <> 0:
+            i = i + 1
+        if i == k:
+            p[k] = n
+            k = k + 1
+            result.append(n)
+        n = n + 1
+    return result
diff --git a/tests/run/r_print.pyx b/tests/run/r_print.pyx
new file mode 100644 (file)
index 0000000..0742fbc
--- /dev/null
@@ -0,0 +1,8 @@
+__doc__ = """
+  >>> frighten()
+  NOBODY expects the Spanish Inquisition!
+"""
+
+def frighten():
+    print "NOBODY", "expects", "the Spanish Inquisition!"
+
diff --git a/tests/run/r_pyclass.pyx b/tests/run/r_pyclass.pyx
new file mode 100644 (file)
index 0000000..ecad7b2
--- /dev/null
@@ -0,0 +1,16 @@
+__doc__ = """
+    >>> order()
+    42 tons of spam!
+"""
+
+class Spam:
+
+    def __init__(self, w):
+        self.weight = w
+
+    def serve(self):
+        print self.weight, "tons of spam!"
+
+def order():
+    s = Spam(42)
+    s.serve()
diff --git a/tests/run/r_pyclassdefault.pyx b/tests/run/r_pyclassdefault.pyx
new file mode 100644 (file)
index 0000000..b8528dc
--- /dev/null
@@ -0,0 +1,19 @@
+__doc__ = """
+  >>> c = CoconutCarrier()
+  >>> c.swallow(name = "Brian")
+  This swallow is called Brian
+  >>> c.swallow(airspeed = 42)
+  This swallow is flying at 42 furlongs per fortnight
+  >>> c.swallow(coconuts = 3)
+  This swallow is carrying 3 coconuts
+"""
+
+class CoconutCarrier:
+
+    def swallow(self, name = None, airspeed = None, coconuts = None):
+        if name is not None:
+            print "This swallow is called", name
+        if airspeed is not None:
+            print "This swallow is flying at", airspeed, "furlongs per fortnight"
+        if coconuts is not None:
+            print "This swallow is carrying", coconuts, "coconuts"
diff --git a/tests/run/r_pythonapi.pyx b/tests/run/r_pythonapi.pyx
new file mode 100644 (file)
index 0000000..346e576
--- /dev/null
@@ -0,0 +1,16 @@
+__doc__ = """
+    >>> x = spam()
+    >>> print repr(x)
+    'Ftang\\x00Ftang!'
+"""
+
+cdef extern from "string.h":
+    void memcpy(char *d, char *s, int n)
+
+cdef extern from "Python.h":
+    object PyString_FromStringAndSize(char *s, int len)
+    
+def spam():
+    cdef char buf[12]
+    memcpy(buf, "Ftang\0Ftang!", sizeof(buf))
+    return PyString_FromStringAndSize(buf, sizeof(buf))
diff --git a/tests/run/r_spamtype.pyx b/tests/run/r_spamtype.pyx
new file mode 100644 (file)
index 0000000..ecb4987
--- /dev/null
@@ -0,0 +1,26 @@
+__doc__ = """
+    >>> s = Spam()
+    >>> print s.get_tons()
+    17
+    >>> s.set_tons(42)
+    >>> print s.get_tons()
+    42
+    >>> s = None
+    42 tons of spam is history.
+"""
+
+cdef class Spam:
+
+    cdef int tons
+    
+    def __cinit__(self):
+        self.tons = 17
+    
+    def __dealloc__(self):
+        print self.tons, "tons of spam is history."
+    
+    def get_tons(self):
+        return self.tons
+    
+    def set_tons(self, x):
+        self.tons = x
diff --git a/tests/run/r_starargcall.pyx b/tests/run/r_starargcall.pyx
new file mode 100644 (file)
index 0000000..3a0a263
--- /dev/null
@@ -0,0 +1,13 @@
+__doc__ = """
+    >>> eggs()
+    Args: 1 2 3
+    Args: buckle my shoe
+"""
+
+def spam(a, b, c):
+    print "Args:", a, b, c
+
+def eggs():
+    spam(*(1,2,3))
+    spam(*["buckle","my","shoe"])
+
diff --git a/tests/run/r_starargs.pyx b/tests/run/r_starargs.pyx
new file mode 100644 (file)
index 0000000..18c4493
--- /dev/null
@@ -0,0 +1,38 @@
+__doc__ = """
+    >>> swallow("Brian", 42)
+    Name: Brian
+    Airspeed: 42
+    Extra args: ()
+    Extra keywords: {}
+
+    >>> swallow("Brian", 42, "African")
+    Name: Brian
+    Airspeed: 42
+    Extra args: ('African',)
+    Extra keywords: {}
+
+    >>> swallow("Brian", airspeed = 42)
+    Name: Brian
+    Airspeed: 42
+    Extra args: ()
+    Extra keywords: {}
+
+    >>> swallow("Brian", airspeed = 42, species = "African", coconuts = 3)
+    Name: Brian
+    Airspeed: 42
+    Extra args: ()
+    Extra keywords: {'coconuts': 3, 'species': 'African'}
+
+    >>> swallow("Brian", 42, "African", coconuts = 3)
+    Name: Brian
+    Airspeed: 42
+    Extra args: ('African',)
+    Extra keywords: {'coconuts': 3}
+"""
+
+def swallow(name, airspeed, *args, **kwds):
+    print "Name:", name
+    print "Airspeed:", airspeed
+    print "Extra args:", args
+    print "Extra keywords:", kwds
+
diff --git a/tests/run/r_starargsonly.pyx b/tests/run/r_starargsonly.pyx
new file mode 100644 (file)
index 0000000..c440d2e
--- /dev/null
@@ -0,0 +1,12 @@
+__doc__ = """
+    >>> spam()
+    Args: ()
+    >>> spam(42)
+    Args: (42,)
+    >>> spam("one", 2, "buckle my shoe")
+    Args: ('one', 2, 'buckle my shoe')
+"""
+
+def spam(*args):
+    print "Args:", args
+
diff --git a/tests/run/r_toofewargs.pyx b/tests/run/r_toofewargs.pyx
new file mode 100644 (file)
index 0000000..331b399
--- /dev/null
@@ -0,0 +1,10 @@
+__doc__ = """
+    >>> s = Spam()
+    Traceback (most recent call last):
+    TypeError: function takes exactly 3 arguments (0 given)
+"""
+
+cdef class Spam:
+
+    def __init__(self, a, b, int c):
+        pass
diff --git a/tests/run/r_vree_1.pyx b/tests/run/r_vree_1.pyx
new file mode 100644 (file)
index 0000000..257d67c
--- /dev/null
@@ -0,0 +1,4 @@
+def test(k):
+    cdef unsigned long m
+    m = k
+    return m
diff --git a/tests/run/ref2local.pyx b/tests/run/ref2local.pyx
new file mode 100644 (file)
index 0000000..cfcc66b
--- /dev/null
@@ -0,0 +1,3 @@
+def f():
+    a = 42
+    b = a
diff --git a/tests/run/return.pyx b/tests/run/return.pyx
new file mode 100644 (file)
index 0000000..b07ad14
--- /dev/null
@@ -0,0 +1,12 @@
+def f(a):
+    return
+    return a
+    return 42
+
+cdef void g():
+    return
+
+cdef int h(a):
+    cdef int i
+    return i
+    
\ No newline at end of file
diff --git a/tests/run/rodriguez_1.pyx b/tests/run/rodriguez_1.pyx
new file mode 100644 (file)
index 0000000..f8cd04d
--- /dev/null
@@ -0,0 +1,10 @@
+class B:
+    def __init__(self):
+        self.t = {
+            1 : (
+                (1, 2, 3)
+                ,
+                )
+
+            , 2 : ( 1, 2, 3)
+            }
diff --git a/tests/run/simpcall.pyx b/tests/run/simpcall.pyx
new file mode 100644 (file)
index 0000000..db8ed96
--- /dev/null
@@ -0,0 +1,18 @@
+def f(x, y):
+    x = y
+
+cdef void g(int i, float f, char *p):
+    f = i
+
+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)
+    h(42, "eggs")
+    
\ No newline at end of file
diff --git a/tests/run/sizeof.pyx b/tests/run/sizeof.pyx
new file mode 100644 (file)
index 0000000..cbc54d7
--- /dev/null
@@ -0,0 +1,10 @@
+cdef struct Spam:
+    char *grail
+
+cdef void f():
+    cdef int i, j, k
+    cdef char *p
+    i = sizeof(p)
+    i = sizeof(j + k)
+    i = sizeof(int)
+    i = sizeof(Spam)
diff --git a/tests/run/slice2.pyx b/tests/run/slice2.pyx
new file mode 100644 (file)
index 0000000..437dcae
--- /dev/null
@@ -0,0 +1,5 @@
+def f(obj1, obj2, obj3, obj4):
+    obj1 = obj2[:]
+    obj1 = obj2[obj3:]
+    obj1 = obj2[:obj4]
+    obj1 = obj2[obj3:obj4]
diff --git a/tests/run/slice3.pyx b/tests/run/slice3.pyx
new file mode 100644 (file)
index 0000000..07321b8
--- /dev/null
@@ -0,0 +1,14 @@
+def f(obj1, obj2, obj3, obj4, obj5):
+    cdef int int3, int4, int5
+    obj1 = obj2[...]
+    obj1 = obj2[::]
+    obj1 = obj2[obj3::]
+    obj1 = obj2[:obj4:]
+    obj1 = obj2[::obj5]
+    obj1 = obj2[obj3:obj4:]
+    obj1 = obj2[obj3::obj5]
+    obj1 = obj2[:obj4:obj5]
+    obj1 = obj2[obj3:obj4:obj5]
+    obj1 = obj2[int3:int4:int5]
+    obj1[int3:int4:int5] = obj2
+    
\ No newline at end of file
diff --git a/tests/run/starargs.pyx b/tests/run/starargs.pyx
new file mode 100644 (file)
index 0000000..67cd01c
--- /dev/null
@@ -0,0 +1,12 @@
+def spam(x, y, z):
+    pass
+
+def grail(x, y, z, *a):
+    pass
+
+def swallow(x, y, z, **k):
+    pass
+
+def creosote(x, y, z, *a, **k):
+    pass
+
diff --git a/tests/run/strconstinclass.pyx b/tests/run/strconstinclass.pyx
new file mode 100644 (file)
index 0000000..67e662e
--- /dev/null
@@ -0,0 +1,3 @@
+class C:
+    x = "foo"
+
diff --git a/tests/run/subop.pyx b/tests/run/subop.pyx
new file mode 100644 (file)
index 0000000..717edbb
--- /dev/null
@@ -0,0 +1,11 @@
+def f():
+    cdef int int1, int2, int3
+    cdef char *ptr1, *ptr2, *ptr3
+    obj1 = 1
+    obj2 = 2
+    obj3 = 3
+    int1 = int2 - int3
+    ptr1 = ptr2 - int3
+    int1 = ptr2 - ptr3
+    obj1 = obj2 - int3
+    
\ No newline at end of file
diff --git a/tests/run/tuple.pyx b/tests/run/tuple.pyx
new file mode 100644 (file)
index 0000000..6ff2388
--- /dev/null
@@ -0,0 +1,7 @@
+def f(obj1, obj2, obj3, obj4, obj5):
+    obj1 = ()
+    obj1 = (obj2,)
+    obj1 = obj2, obj3
+    obj1 = (obj2, obj3, obj4)
+    obj1 = (obj2, obj3, obj4,)
+    obj1 = 17, 42, 88
diff --git a/tests/run/unop.pyx b/tests/run/unop.pyx
new file mode 100644 (file)
index 0000000..2311415
--- /dev/null
@@ -0,0 +1,14 @@
+def f(obj1, obj2, obj3):
+    cdef int bool1, bool2
+    cdef int int1, int2
+    cdef char *str1
+    bool1 = not bool2
+    obj1 = not obj2
+    bool1 = not str1
+    int1 = +int2
+    obj1 = +obj2
+    int1 = -int2
+    obj1 = -obj2
+    int1 = ~int2
+    obj1 = ~obj2
+    
\ No newline at end of file
diff --git a/tests/run/unpack.pyx b/tests/run/unpack.pyx
new file mode 100644 (file)
index 0000000..3a7c3b8
--- /dev/null
@@ -0,0 +1,7 @@
+def f(obj1, obj2, obj3, obj4, obj5):
+    obj1, = obj2
+    obj1, = obj2 + obj3
+    obj1, obj2, obj3 = obj3
+    obj1, (obj2, obj3) = obj4
+    [obj1, obj2] = obj3
+    
\ No newline at end of file
diff --git a/tests/run/varargcall.pyx b/tests/run/varargcall.pyx
new file mode 100644 (file)
index 0000000..13d7201
--- /dev/null
@@ -0,0 +1,6 @@
+cdef grail(char *blarg, ...):
+    pass
+
+cdef swallow():
+    grail("spam")
+    grail("spam", 42)
diff --git a/tests/run/wundram1.pyx b/tests/run/wundram1.pyx
new file mode 100644 (file)
index 0000000..7360cb6
--- /dev/null
@@ -0,0 +1,2 @@
+cdef unsigned int ui
+x = ui