Antonio Cuni avatar Antonio Cuni committed 7db2e26

add a test to check that we can take pointers to incomplete structures

Comments (0)

Files changed (1)

pypy/module/_ffi/test/test_struct.py

         assert repr(descr.ffitype) == '<ffi type struct foo>'
         assert descr.ffitype.sizeof() == longsize*2
         raises(ValueError, "descr.define_fields(fields)")
+
+    def test_pointer_to_incomplete_struct(self):
+        from _ffi import _StructDescr, Field, types
+        longsize = types.slong.sizeof()
+        fields = [
+            Field('x', types.slong),
+            Field('y', types.slong),
+            ]
+        descr = _StructDescr('foo')
+        foo_ffitype = descr.ffitype
+        foo_p = types.Pointer(descr.ffitype)
+        assert foo_p.deref_pointer() is foo_ffitype
+        descr.define_fields(fields)
+        assert descr.ffitype is foo_ffitype
+        assert foo_p.deref_pointer() is foo_ffitype
+        assert types.Pointer(descr.ffitype) is foo_p
         
 
     def test_compute_shape(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.