[pypy-svn] r28406 - pypy/dist/pypy/rpython/test

antocuni at codespeak.net antocuni at codespeak.net
Tue Jun 6 19:22:23 CEST 2006


Author: antocuni
Date: Tue Jun  6 19:22:22 2006
New Revision: 28406

Modified:
   pypy/dist/pypy/rpython/test/test_rint.py
Log:
More ootypesystem tests.



Modified: pypy/dist/pypy/rpython/test/test_rint.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rint.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rint.py	Tue Jun  6 19:22:22 2006
@@ -37,91 +37,6 @@
             print 'BINARY_OPERATIONS:', opname
 
 
-def test_unsigned():
-    def dummy(i):
-        i = r_uint(i)
-        j = r_uint(12)
-        return i < j
-
-    res = interpret(dummy,[0])
-    assert res is True
-
-    res = interpret(dummy, [-1])
-    assert res is False    # -1 ==> 0xffffffff
-
-def test_specializing_int_functions():
-    def f(i):
-        return i + 1
-    f._annspecialcase_ = "specialize:argtype(0)"
-    def g(n):
-        if n > 0:
-            return f(r_longlong(0))
-        else:
-            return f(0)
-    res = interpret(g, [0])
-    assert res == 1
-
-    res = interpret(g, [1])
-    assert res == 1
-
-def test_downcast_int():
-    def f(i):
-        return int(i)
-    res = interpret(f, [r_longlong(0)])
-    assert res == 0
-
-def test_isinstance_vs_int_types():
-    class FakeSpace(object):
-        def wrap(self, x):
-            if x is None:
-                return [None]
-            if isinstance(x, str):
-                return x
-            if isinstance(x, r_longlong):
-                return int(x)
-            return "XXX"
-        wrap._annspecialcase_ = 'specialize:argtype(0)'
-
-    space = FakeSpace()
-    def wrap(x):
-        return space.wrap(x)
-    res = interpret(wrap, [r_longlong(0)])
-    assert res == 0
-
-def test_truediv():
-    import operator
-    def f(n, m):
-        return operator.truediv(n, m)
-    res = interpret(f, [20, 4])
-    assert type(res) is float
-    assert res == 5.0
-
-
-def test_rarithmetic():
-    inttypes = [int, r_uint, r_longlong, r_ulonglong]
-    for inttype in inttypes:
-        c = inttype()
-        def f():
-            return c
-        res = interpret(f, [])
-        assert res == f()
-        assert type(res) == inttype
-
-    for inttype in inttypes:
-        def f():
-            return inttype(0)
-        res = interpret(f, [])
-        assert res == f()
-        assert type(res) == inttype
-
-    for inttype in inttypes:
-        def f(x):
-            return x
-        res = interpret(f, [inttype(0)])
-        assert res == f(inttype(0))
-        assert type(res) == inttype
-
-
 class BaseTestRint(BaseRtypingTest):
     
     def test_char_constant(self):
@@ -176,6 +91,89 @@
         res = self.interpret(dummy, [-123])
         assert self.ll_to_string(res) == '-0173'
 
+    def test_unsigned(self):
+        def dummy(i):
+            i = r_uint(i)
+            j = r_uint(12)
+            return i < j
+
+        res = self.interpret(dummy,[0])
+        assert res is True
+
+        res = self.interpret(dummy, [-1])
+        assert res is False    # -1 ==> 0xffffffff
+
+    def test_specializing_int_functions(self):
+        def f(i):
+            return i + 1
+        f._annspecialcase_ = "specialize:argtype(0)"
+        def g(n):
+            if n > 0:
+                return f(r_longlong(0))
+            else:
+                return f(0)
+        res = self.interpret(g, [0])
+        assert res == 1
+
+        res = self.interpret(g, [1])
+        assert res == 1
+
+    def test_downcast_int(self):
+        def f(i):
+            return int(i)
+        res = self.interpret(f, [r_longlong(0)])
+        assert res == 0
+
+    def test_isinstance_vs_int_types(self):
+        class FakeSpace(object):
+            def wrap(self, x):
+                if x is None:
+                    return [None]
+                if isinstance(x, str):
+                    return x
+                if isinstance(x, r_longlong):
+                    return int(x)
+                return "XXX"
+            wrap._annspecialcase_ = 'specialize:argtype(0)'
+
+        space = FakeSpace()
+        def wrap(x):
+            return space.wrap(x)
+        res = self.interpret(wrap, [r_longlong(0)])
+        assert res == 0
+
+    def test_truediv(self):
+        import operator
+        def f(n, m):
+            return operator.truediv(n, m)
+        res = self.interpret(f, [20, 4])
+        assert type(res) is float
+        assert res == 5.0
+
+
+    def test_rarithmetic(self):
+        inttypes = [int, r_uint, r_longlong, r_ulonglong]
+        for inttype in inttypes:
+            c = inttype()
+            def f():
+                return c
+            res = self.interpret(f, [])
+            assert res == f()
+            assert type(res) == inttype
+
+        for inttype in inttypes:
+            def f():
+                return inttype(0)
+            res = self.interpret(f, [])
+            assert res == f()
+            assert type(res) == inttype
+
+        for inttype in inttypes:
+            def f(x):
+                return x
+            res = self.interpret(f, [inttype(0)])
+            assert res == f(inttype(0))
+            assert type(res) == inttype
 
 class TestLLtype(BaseTestRint, LLRtypeMixin):
     pass



More information about the Pypy-commit mailing list