extended test case for ticket 252
authorStefan Behnel <scoder@users.berlios.de>
Wed, 28 Oct 2009 13:29:21 +0000 (14:29 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 28 Oct 2009 13:29:21 +0000 (14:29 +0100)
--HG--
rename : tests/compile/bad_c_struct_T252.pyx => tests/run/bad_c_struct_T252.pyx

tests/compile/bad_c_struct_T252.pyx [deleted file]
tests/run/bad_c_struct_T252.pyx [new file with mode: 0644]

diff --git a/tests/compile/bad_c_struct_T252.pyx b/tests/compile/bad_c_struct_T252.pyx
deleted file mode 100644 (file)
index 0f5b959..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-cdef f(void=None):
-    pass
-
-cdef struct foo:
-    int void
-
-cdef class Foo:
-    cdef int void
diff --git a/tests/run/bad_c_struct_T252.pyx b/tests/run/bad_c_struct_T252.pyx
new file mode 100644 (file)
index 0000000..7c26b55
--- /dev/null
@@ -0,0 +1,56 @@
+
+cdef cf(default=None):
+    return default
+
+cpdef cpf(default=None):
+    """
+    >>> cpf()
+    None
+    >>> cpf(1)
+    1
+    >>> cpf(default=2)
+    2
+    """
+    default = cf(default)
+    return default
+
+def pf(default=None):
+    """
+    >>> pf()
+    None
+    >>> pf(1)
+    1
+    >>> pf(default=2)
+    2
+    """
+    return default
+
+
+cdef struct foo:
+    int void
+    int default
+
+def test_struct():
+    """
+    >>> test_struct()
+    (1, 2)
+    """
+    cdef foo foo_struct
+    foo_struct.void = 1
+    foo_struct.default = 2
+    return foo_struct.void, foo_struct.default
+
+
+cdef class Foo:
+    cdef int void
+    cdef int default
+
+def test_class():
+    """
+    >>> test_class()
+    (1, 2)
+    """
+    cdef Foo foo_instance = Foo()
+    foo_instance.void = 1
+    foo_instance.default = 2
+    return foo_instance.void, foo_instance.default