Commits

Armin Rigo committed 8827952

text end-of-lines

Comments (0)

Files changed (1)

pypy/objspace/std/test/test_restricted_int.py

-import unittest, sys
-import testsupport
-from pypy.objspace.std.restricted_int import *
-
-class Test_r_int(unittest.TestCase):
-
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-    def test__add__(self):
-        self.binary_test(lambda x, y: x + y)
-    def test__sub__(self):
-        self.binary_test(lambda x, y: x - y)
-    def test__mul__(self):
-        self.binary_test(lambda x, y: x * y)
-    def test__div__(self):
-        self.binary_test(lambda x, y: x // y)
-    def test__mod__(self):
-        self.binary_test(lambda x, y: x % y)
-    def test__divmod__(self):
-        self.binary_test(divmod)
-    def test__lshift__(self):
-        self.binary_test(lambda x, y: x << y, (1, 2, 3))
-    def test__rshift__(self):
-        self.binary_test(lambda x, y: x >> y, (1, 2, 3))
-    def test__or__(self):
-        self.binary_test(lambda x, y: x | y)
-    def test__and__(self):
-        self.binary_test(lambda x, y: x & y)
-    def test__xor__(self):
-        self.binary_test(lambda x, y: x ^ y)
-    def test__neg__(self):
-        self.unary_test(lambda x: -x)
-    def test__pos__(self):
-        self.unary_test(lambda x: +x)
-    def test__invert__(self):
-        self.unary_test(lambda x: ~x)
-    def test__pow__(self):
-        self.binary_test(lambda x, y: x**y, (2, 3))
-        self.binary_test(lambda x, y: pow(x, y, 42), (2, 3, 5, 1000))
-
-    def unary_test(self, f):
-        for arg in (-10, -1, 0, 3, 12345):
-            res = f(arg)
-            cmp = f(r_int(arg))
-            self.assertEquals(res, cmp)
-        
-    def binary_test(self, f, rargs = None):
-        if not rargs:
-            rargs = (-10, -1, 3, 55)
-        for larg in (-10, -1, 0, 3, 1234):
-            for rarg in rargs:
-                for types in ((int, r_int), (r_int, int), (r_int, r_int)):
-                    res = f(larg, rarg)
-                    left, right = types
-                    cmp = f(left(larg), right(rarg))
-                    self.assertEquals(res, cmp)
-                    
-class Test_r_uint(unittest.TestCase):
-
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-    def test__add__(self):
-        self.binary_test(lambda x, y: x + y)
-    def test__sub__(self):
-        self.binary_test(lambda x, y: x - y)
-    def test__mul__(self):
-        self.binary_test(lambda x, y: x * y)
-    def test__div__(self):
-        self.binary_test(lambda x, y: x // y)
-    def test__mod__(self):
-        self.binary_test(lambda x, y: x % y)
-    def test__divmod__(self):
-        self.binary_test(divmod)
-    def test__lshift__(self):
-        self.binary_test(lambda x, y: x << y, (1, 2, 3))
-    def test__rshift__(self):
-        self.binary_test(lambda x, y: x >> y, (1, 2, 3))
-    def test__or__(self):
-        self.binary_test(lambda x, y: x | y)
-    def test__and__(self):
-        self.binary_test(lambda x, y: x & y)
-    def test__xor__(self):
-        self.binary_test(lambda x, y: x ^ y)
-    def test__neg__(self):
-        self.unary_test(lambda x: -x)
-    def test__pos__(self):
-        self.unary_test(lambda x: +x)
-    def test__invert__(self):
-        self.unary_test(lambda x: ~x)
-    def test__pow__(self):
-        self.binary_test(lambda x, y: x**y, (2, 3))
-        # pow is buggy, dowsn't allow our type
-        #self.binary_test(lambda x, y: pow(x, y, 42), (2, 3, 5, 1000))
-
-    def unary_test(self, f):
-        for arg in (0, 3, 12345):
-            res = f(arg) & 0xffffffffl
-            cmp = f(r_uint(arg))
-            self.assertEquals(res, cmp)
-        
-    def binary_test(self, f, rargs = None):
-        mask = 0xffffffffl
-        if not rargs:
-            rargs = (1, 3, 55)
-        for larg in (0, 1, 2, 3, 1234):
-            for rarg in rargs:
-                for types in ((int, r_uint), (r_uint, int), (r_uint, r_uint)):
-                    res = f(larg, rarg)
-                    left, right = types
-                    cmp = f(left(larg), right(rarg))
-                    if type(res) is tuple:
-                        res = res[0] & mask, res[1] & mask
-                    else:
-                        res = res & mask
-                    self.assertEquals(res, cmp)
-
-if __name__ == '__main__':
-    unittest.main()
+import unittest, sys
+import testsupport
+from pypy.objspace.std.restricted_int import *
+
+class Test_r_int(unittest.TestCase):
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+    def test__add__(self):
+        self.binary_test(lambda x, y: x + y)
+    def test__sub__(self):
+        self.binary_test(lambda x, y: x - y)
+    def test__mul__(self):
+        self.binary_test(lambda x, y: x * y)
+    def test__div__(self):
+        self.binary_test(lambda x, y: x // y)
+    def test__mod__(self):
+        self.binary_test(lambda x, y: x % y)
+    def test__divmod__(self):
+        self.binary_test(divmod)
+    def test__lshift__(self):
+        self.binary_test(lambda x, y: x << y, (1, 2, 3))
+    def test__rshift__(self):
+        self.binary_test(lambda x, y: x >> y, (1, 2, 3))
+    def test__or__(self):
+        self.binary_test(lambda x, y: x | y)
+    def test__and__(self):
+        self.binary_test(lambda x, y: x & y)
+    def test__xor__(self):
+        self.binary_test(lambda x, y: x ^ y)
+    def test__neg__(self):
+        self.unary_test(lambda x: -x)
+    def test__pos__(self):
+        self.unary_test(lambda x: +x)
+    def test__invert__(self):
+        self.unary_test(lambda x: ~x)
+    def test__pow__(self):
+        self.binary_test(lambda x, y: x**y, (2, 3))
+        self.binary_test(lambda x, y: pow(x, y, 42), (2, 3, 5, 1000))
+
+    def unary_test(self, f):
+        for arg in (-10, -1, 0, 3, 12345):
+            res = f(arg)
+            cmp = f(r_int(arg))
+            self.assertEquals(res, cmp)
+        
+    def binary_test(self, f, rargs = None):
+        if not rargs:
+            rargs = (-10, -1, 3, 55)
+        for larg in (-10, -1, 0, 3, 1234):
+            for rarg in rargs:
+                for types in ((int, r_int), (r_int, int), (r_int, r_int)):
+                    res = f(larg, rarg)
+                    left, right = types
+                    cmp = f(left(larg), right(rarg))
+                    self.assertEquals(res, cmp)
+                    
+class Test_r_uint(unittest.TestCase):
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+    def test__add__(self):
+        self.binary_test(lambda x, y: x + y)
+    def test__sub__(self):
+        self.binary_test(lambda x, y: x - y)
+    def test__mul__(self):
+        self.binary_test(lambda x, y: x * y)
+    def test__div__(self):
+        self.binary_test(lambda x, y: x // y)
+    def test__mod__(self):
+        self.binary_test(lambda x, y: x % y)
+    def test__divmod__(self):
+        self.binary_test(divmod)
+    def test__lshift__(self):
+        self.binary_test(lambda x, y: x << y, (1, 2, 3))
+    def test__rshift__(self):
+        self.binary_test(lambda x, y: x >> y, (1, 2, 3))
+    def test__or__(self):
+        self.binary_test(lambda x, y: x | y)
+    def test__and__(self):
+        self.binary_test(lambda x, y: x & y)
+    def test__xor__(self):
+        self.binary_test(lambda x, y: x ^ y)
+    def test__neg__(self):
+        self.unary_test(lambda x: -x)
+    def test__pos__(self):
+        self.unary_test(lambda x: +x)
+    def test__invert__(self):
+        self.unary_test(lambda x: ~x)
+    def test__pow__(self):
+        self.binary_test(lambda x, y: x**y, (2, 3))
+        # pow is buggy, dowsn't allow our type
+        #self.binary_test(lambda x, y: pow(x, y, 42), (2, 3, 5, 1000))
+
+    def unary_test(self, f):
+        for arg in (0, 3, 12345):
+            res = f(arg) & 0xffffffffl
+            cmp = f(r_uint(arg))
+            self.assertEquals(res, cmp)
+        
+    def binary_test(self, f, rargs = None):
+        mask = 0xffffffffl
+        if not rargs:
+            rargs = (1, 3, 55)
+        for larg in (0, 1, 2, 3, 1234):
+            for rarg in rargs:
+                for types in ((int, r_uint), (r_uint, int), (r_uint, r_uint)):
+                    res = f(larg, rarg)
+                    left, right = types
+                    cmp = f(left(larg), right(rarg))
+                    if type(res) is tuple:
+                        res = res[0] & mask, res[1] & mask
+                    else:
+                        res = res & mask
+                    self.assertEquals(res, cmp)
+
+if __name__ == '__main__':
+    unittest.main()