Author: Armin Rigo <ar...@tunes.org>
Branch: cmacros
Changeset: r2301:39f0d496d0eb
Date: 2015-10-04 19:21 +0200
http://bitbucket.org/cffi/cffi/changeset/39f0d496d0eb/

Log:    more tests

diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -511,13 +511,13 @@
         #else
         typedef long foo_t;
         #endif
-        foo_t foo(char);
+        foo_t *foo(char);
     """)
     case = ffi._parser._declarations['function foo']
     assert isinstance(case, ConditionalCase)
     assert case.condition == 'defined(ABC)'
-    assert str(case.iftrue) == '<func (<char>), <int>, False>'
-    assert str(case.iffalse) == '<func (<char>), <long>, False>'
+    assert str(case.iftrue) == '<func (<char>), <pointer to <int>>, False>'
+    assert str(case.iffalse) == '<func (<char>), <pointer to <long>>, False>'
 
 def test_conditional_typedef_not_used_by_func():
     ffi = FFI(backend=FakeBackend())
@@ -532,6 +532,27 @@
     case = ffi._parser._declarations['function foo']
     assert str(case) == '<func (<char>), <char>, False>'
 
+def test_conditional_typedef_partially_defined_1():
+    ffi = FFI(backend=FakeBackend())
+    ffi.cdef("""
+        #ifdef ABC
+        typedef int foo_t;
+        #endif
+        char foo(char);
+    """)
+    case = ffi._parser._declarations['function foo']
+    assert str(case) == '<func (<char>), <char>, False>'
+
+def test_conditional_typedef_partially_defined_2():
+    ffi = FFI(backend=FakeBackend())
+    ffi.cdef("""
+        #ifdef ABC
+        typedef int foo_t;
+        #endif
+        char foo(foo_t *);
+    """)
+    should_crash
+
 def test_conditional_nested():
     ffi = FFI(backend=FakeBackend())
     ffi.cdef("""
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to