[pypy-svn] r45719 - in pypy/branch/pypy-more-rtti-inprogress/rpython/tool: . test

arigo at codespeak.net arigo at codespeak.net
Thu Aug 16 15:45:17 CEST 2007


Author: arigo
Date: Thu Aug 16 15:45:15 2007
New Revision: 45719

Modified:
   pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py
   pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py
Log:
* prefer rffi.SIGNEDCHAR over the ambigous rffi.CHAR
* minor cleanups in the test


Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py	Thu Aug 16 15:45:15 2007
@@ -375,7 +375,7 @@
     LAST[0] += 1
     return udir.join('platcheck_%d.c' % i)
 
-integer_class = [rffi.CHAR, rffi.UCHAR,
+integer_class = [rffi.SIGNEDCHAR, rffi.UCHAR, rffi.CHAR,
                  rffi.SHORT, rffi.USHORT,
                  rffi.INT, rffi.UINT,
                  rffi.LONG, rffi.ULONG,

Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py	Thu Aug 16 15:45:15 2007
@@ -4,12 +4,12 @@
 from pypy.rpython.lltypesystem import rffi
 from pypy.tool.udir import udir
 
-def setup_module(mod):
+def import_ctypes():
     try:
         import ctypes
-        mod.ctypes = ctypes
     except ImportError:
-        py.test.skip("Cannot test rffi_platform without ctypes")
+        py.test.skip("this test requires ctypes")
+    return ctypes
 
 def test_dirent():
     dirent = rffi_platform.getstruct("struct dirent",
@@ -25,7 +25,10 @@
                                        [("d_reclen", rffi.USHORT)])
     
     assert isinstance(dirent, lltype.Struct)
+    # check that we have the desired field
+    assert dirent.c_d_reclen is rffi.USHORT
 
+    ctypes = import_ctypes()
     class CTypesDirent(ctypes.Structure):
         _fields_ = [('d_ino', ctypes.c_long),
                     ('d_off', ctypes.c_int),
@@ -33,8 +36,6 @@
                     ('d_name', ctypes.c_char * 32)]
 
     assert dirent._hints['size'] == ctypes.sizeof(CTypesDirent)
-    # check if we have a desired field
-    assert dirent._flds['c_d_reclen'] is rffi.USHORT
 
 def test_fit_type():
     S = rffi_platform.getstruct("struct S",
@@ -67,18 +68,17 @@
     # XXX we need to have a float here as well as soon as we'll
     #     have support
     assert isinstance(S, lltype.Struct)
-    fields = dict(S._flds)
-    assert fields["c_c"] == rffi.CHAR
-    assert fields["c_uc"] == rffi.UCHAR
-    assert fields["c_s"] == rffi.SHORT
-    assert fields["c_us"] == rffi.USHORT
-    assert fields["c_i"] == rffi.INT
-    assert fields["c_ui"] == rffi.UINT
-    assert fields["c_l"] == rffi.LONG
-    assert fields["c_ul"] == rffi.ULONG
-    assert fields["c_ll"] == rffi.LONGLONG
-    assert fields["c_ull"] == rffi.ULONGLONG
-    assert fields["c_d"] == rffi.DOUBLE
+    assert S.c_c == rffi.SIGNEDCHAR
+    assert S.c_uc == rffi.UCHAR
+    assert S.c_s == rffi.SHORT
+    assert S.c_us == rffi.USHORT
+    assert S.c_i == rffi.INT
+    assert S.c_ui == rffi.UINT
+    assert S.c_l == rffi.LONG
+    assert S.c_ul == rffi.ULONG
+    assert S.c_ll == rffi.LONGLONG
+    assert S.c_ull == rffi.ULONGLONG
+    assert S.c_d == rffi.DOUBLE
 
 def test_simple_type():
     ctype = rffi_platform.getsimpletype('test_t',
@@ -168,10 +168,9 @@
     res = rffi_platform.configure(CConfig)
     c_x = res["x"]
     c_y = res["y"]
-    c_y_fields = dict(c_y._flds)
-    assert isinstance(c_x , lltype.Struct)
+    assert isinstance(c_x, lltype.Struct)
     assert isinstance(c_y, lltype.Struct)
-    assert c_y_fields["c_x"] is c_x
+    assert c_y.c_x is c_x
 
 def test_array():
     py.test.skip("Next to go")



More information about the Pypy-commit mailing list