[pypy-svn] r25507 - in pypy/dist/pypy/rpython/rctypes: . test

arigo at codespeak.net arigo at codespeak.net
Fri Apr 7 16:54:15 CEST 2006


Author: arigo
Date: Fri Apr  7 16:54:12 2006
New Revision: 25507

Modified:
   pypy/dist/pypy/rpython/rctypes/ctypes_platform.py
   pypy/dist/pypy/rpython/rctypes/test/test_ctypes_platform.py
Log:
(arre, arigo)

Helper getdefined().



Modified: pypy/dist/pypy/rpython/rctypes/ctypes_platform.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/ctypes_platform.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/ctypes_platform.py	Fri Apr  7 16:54:12 2006
@@ -222,6 +222,11 @@
     return info['value']
 
 
+def getdefined(name, c_header_source):
+    return getconstantinteger('\n#ifdef %s\n1\n#else\n0\n#endif\n' % (name),
+                              c_header_source)
+
+
 if __name__ == '__main__':
     doc = """Example:
     

Modified: pypy/dist/pypy/rpython/rctypes/test/test_ctypes_platform.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_ctypes_platform.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_ctypes_platform.py	Fri Apr  7 16:54:12 2006
@@ -3,10 +3,6 @@
 import ctypes
 
 
-if sys.platform != 'linux2':
-    py.test.skip("the test must be adapted to your platform")
-
-
 def test_dirent():
     dirent = ctypes_platform.getstruct("struct dirent",
                                        """
@@ -99,3 +95,10 @@
     value = ctypes_platform.getconstantinteger('BLAH',
                                                '#define BLAH (3333333333ULL)')
     assert value == 3333333333
+
+def test_defined():
+    res = ctypes_platform.getdefined('ALFKJLKJFLKJFKLEJDLKEWMECEE', '')
+    assert not res
+    res = ctypes_platform.getdefined('ALFKJLKJFLKJFKLEJDLKEWMECEE',
+                                     '#define ALFKJLKJFLKJFKLEJDLKEWMECEE')
+    assert res



More information about the Pypy-commit mailing list