Author: Ronan Lamy <[email protected]>
Branch: rffi-parser-2
Changeset: r89220:ec3d3a2fd7d3
Date: 2016-12-23 19:36 +0100
http://bitbucket.org/pypy/pypy/changeset/ec3d3a2fd7d3/
Log: Add 2 (failing) tests
diff --git a/pypy/module/cpyext/test/test_cparser.py
b/pypy/module/cpyext/test/test_cparser.py
--- a/pypy/module/cpyext/test/test_cparser.py
+++ b/pypy/module/cpyext/test/test_cparser.py
@@ -80,3 +80,57 @@
assert 'Type' not in hdr2.definitions
Object = hdr2.definitions['Object'].OF
assert Object.c_type.TO is Type
+
+def test_incomplete(tmpdir):
+ cdef = """
+ typedef ssize_t Py_ssize_t;
+
+ typedef struct {
+ Py_ssize_t ob_refcnt;
+ Py_ssize_t ob_pypy_link;
+ struct _typeobject *ob_type;
+ } Object;
+
+ typedef struct {
+ void *buf;
+ Object *obj;
+ } Buffer;
+
+ """
+ (tmpdir / 'foo.h').write(cdef)
+ eci = ExternalCompilationInfo(
+ include_dirs=[str(tmpdir)],
+ includes=['sys/types.h', 'foo.h'])
+ foo_h = parse_source(cdef, eci=eci)
+ foo_h.configure_types()
+ Object = foo_h.definitions['Object'].OF
+ assert isinstance(Object, lltype.ForwardReference) or hash(Object)
+
+def test_recursive(tmpdir):
+ cdef = """
+ typedef ssize_t Py_ssize_t;
+
+ typedef struct {
+ Py_ssize_t ob_refcnt;
+ Py_ssize_t ob_pypy_link;
+ struct _typeobject *ob_type;
+ } Object;
+
+ typedef struct {
+ void *buf;
+ Object *obj;
+ } Buffer;
+
+ typedef struct _typeobject {
+ Object *obj;
+ } Type;
+ """
+ (tmpdir / 'foo.h').write(cdef)
+ eci = ExternalCompilationInfo(
+ include_dirs=[str(tmpdir)],
+ includes=['sys/types.h', 'foo.h'])
+ foo_h = parse_source(cdef, eci=eci)
+ foo_h.configure_types()
+ Object = foo_h.definitions['Object'].OF
+ assert isinstance(Object, lltype.Struct)
+ hash(Object)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit