[pypy-commit] cffi cffi-1.0: Move and fix the test
arigo
noreply at buildbot.pypy.org
Sun Apr 26 11:37:07 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1842:3919dd27269f
Date: 2015-04-26 11:37 +0200
http://bitbucket.org/cffi/cffi/changeset/3919dd27269f/
Log: Move and fix the test
diff --git a/_cffi1/test_new_ffi_1.py b/_cffi1/test_new_ffi_1.py
--- a/_cffi1/test_new_ffi_1.py
+++ b/_cffi1/test_new_ffi_1.py
@@ -1278,26 +1278,6 @@
sz = ffi.sizeof("long")
assert cb((1 << (sz*8-1)) - 1, -10) == 42
- def test_unique_types(self):
- xxxx
- ffi1 = FFI(backend=self.Backend())
- ffi2 = FFI(backend=self.Backend())
- assert ffi1.typeof("char") is ffi2.typeof("char ")
- assert ffi1.typeof("long") is ffi2.typeof("signed long int")
- assert ffi1.typeof("double *") is ffi2.typeof("double*")
- assert ffi1.typeof("int ***") is ffi2.typeof(" int * * *")
- assert ffi1.typeof("int[]") is ffi2.typeof("signed int[]")
- assert ffi1.typeof("signed int*[17]") is ffi2.typeof("int *[17]")
- assert ffi1.typeof("void") is ffi2.typeof("void")
- assert ffi1.typeof("int(*)(int,int)") is ffi2.typeof("int(*)(int,int)")
- #
- # these depend on user-defined data, so should not be shared
- assert ffi1.typeof("struct foo") is not ffi2.typeof("struct foo")
- assert ffi1.typeof("union foo *") is not ffi2.typeof("union foo*")
- assert ffi1.typeof("enum foo") is not ffi2.typeof("enum foo")
- # sanity check: twice 'ffi1'
- assert ffi1.typeof("struct foo*") is ffi1.typeof("struct foo *")
-
def test_anonymous_enum(self):
# typedef enum { Value0 = 0 } e_t, *pe_t;
assert ffi.getctype("e_t*") == 'e_t *'
diff --git a/_cffi1/test_recompiler.py b/_cffi1/test_recompiler.py
--- a/_cffi1/test_recompiler.py
+++ b/_cffi1/test_recompiler.py
@@ -374,3 +374,29 @@
"typedef enum { AA=%d } e1;" % sys.maxint)
assert lib.AA == sys.maxint
assert ffi.sizeof("e1") == ffi.sizeof("long")
+
+def test_unique_types():
+ CDEF = "struct foo_s; union foo_u; enum foo_e { AA };"
+ ffi1 = FFI(); ffi1.cdef(CDEF); verify(ffi1, "test_unique_types_1", CDEF)
+ ffi2 = FFI(); ffi2.cdef(CDEF); verify(ffi2, "test_unique_types_2", CDEF)
+ #
+ assert ffi1.typeof("char") is ffi2.typeof("char ")
+ assert ffi1.typeof("long") is ffi2.typeof("signed long int")
+ assert ffi1.typeof("double *") is ffi2.typeof("double*")
+ assert ffi1.typeof("int ***") is ffi2.typeof(" int * * *")
+ assert ffi1.typeof("int[]") is ffi2.typeof("signed int[]")
+ assert ffi1.typeof("signed int*[17]") is ffi2.typeof("int *[17]")
+ assert ffi1.typeof("void") is ffi2.typeof("void")
+ assert ffi1.typeof("int(*)(int,int)") is ffi2.typeof("int(*)(int,int)")
+ #
+ # these depend on user-defined data, so should not be shared
+ for name in ["struct foo_s",
+ "union foo_u *",
+ "enum foo_e",
+ "struct foo_s *(*)()",
+ "void(*)(struct foo_s *)",
+ "struct foo_s *(*[5])[8]",
+ ]:
+ assert ffi1.typeof(name) is not ffi2.typeof(name)
+ # sanity check: twice 'ffi1'
+ assert ffi1.typeof("struct foo_s*") is ffi1.typeof("struct foo_s *")
More information about the pypy-commit
mailing list