[pypy-svn] r18805 - pypy/dist/pypy/translator/c/test

afa at codespeak.net afa at codespeak.net
Thu Oct 20 19:38:39 CEST 2005


Author: afa
Date: Thu Oct 20 19:38:37 2005
New Revision: 18805

Modified:
   pypy/dist/pypy/translator/c/test/test_extfunc.py
Log:
Simplify a socket test, and explain why it should not try all combinations:
the C external functions do not have to handle type conversion.


Modified: pypy/dist/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_extfunc.py	Thu Oct 20 19:38:37 2005
@@ -527,25 +527,6 @@
 def test_socket():
     import _socket
     import pypy.module._socket.rpython.exttable   # for declare()/declaretype()
-    def fn():
-        return _socket.ntohs(123)
-    f = compile(fn, [])
-    assert f() == _socket.ntohs(123)
-    def fn():
-        return _socket.htons(123)
-    f = compile(fn, [])
-    assert f() == _socket.htons(123)
-    def fn():
-        return _socket.ntohl(123)
-    f = compile(fn, [])
-    assert f() == _socket.ntohl(123)
-    def fn():
-        return _socket.htonl(123)
-    f = compile(fn, [])
-    assert f() == _socket.htonl(123)
-
-def INPROGRESStest_NtoH():
-    import _socket
     # This just checks that htons etc. are their own inverse,
     # when looking at the lower 16 or 32 bits.
     def fn1(n):
@@ -560,14 +541,7 @@
              compile(fn4, [int]): 16, compile(fn3, [int]): 16}
     for func, size in sizes.items():
         mask = (1L<<size) - 1
-        for i in (0, 1, 0xffff, ~0xffff, 2, 0x01234567, 0x76543210):
+        # Don't try with 'long' values: type conversion is done
+        # at the interp level, not at the C level
+        for i in (0, 1, 0xffff, 2, 0x01234567, 0x76543210):
             assert i & mask == func(func(i&mask)) & mask
-
-        swapped = func(mask)
-        assert swapped & mask == mask
-        try:
-            func(1L<<34)
-        except OverflowError:
-            pass
-        else:
-            assert False



More information about the Pypy-commit mailing list