Commits

Timo Paulssen committed 0c17239

missing minus, removed "almost_equal".

Comments (0)

Files changed (1)

pypy/module/math/test/test_math.py

             assert func(Z()) == i
 
     def test_ceil(self):
-        eps = 1E-05
-
-        def almost_equal(a, b):
-            return abs(a-b) <= eps
         # adapted from the cpython test case
         import math
         raises(TypeError, math.ceil)
         assert type(math.ceil(0.4)) is int
-        assert almost_equal(math.ceil(0.5), 1)
-        assert almost_equal(math.ceil(1.0), 1)
-        assert almost_equal(math.ceil(1.5), 2)
-        assert almost_equal(math.ceil(-0.5), 0)
-        assert almost_equal(math.ceil(-1.0), -1)
-        assert almost_equal(math.ceil(-1.5), -1)
+        assert math.ceil(0.5) == 1
+        assert math.ceil(1.0) == 1
+        assert math.ceil(1.5) == 2
+        assert math.ceil(-0.5) == 0
+        assert math.ceil(-1.0) == -1
+        assert math.ceil(-1.5) == -1
 
         class TestCeil:
             def __ceil__(self):
                 return 42
         class TestNoCeil:
             pass
-        assert almost_equal(math.ceil(TestCeil()), 42)
+        assert math.ceil(TestCeil()) == 42
         raises(TypeError, math.ceil, TestNoCeil())
  
         t = TestNoCeil()
         assert math.ceil(StrangeCeil()) == "this is a string"
 
     def test_floor(self):
-        eps = 1E-05
-
-        def almost_equal(a, b):
-            return abs(a-b) <= eps
         # adapted from the cpython test case
         import math
         raises(TypeError, math.floor)
         assert type(math.floor(0.4)) is int
-        assert almost_equal(math.floor(0.5), 0)
-        assert almost_equal(math.floor(1.0), 1)
-        assert almost_equal(math.floor(1.5), 1)
-        assert almost_equal(math.floor(-0.5), -1)
-        assert almost_equal(math.floor(-1.0), -1)
-        assert almost_equal(math.floor(-1.5), -2)
-        #assert almost_equal(math.floor(1.23e167), 1.23e167)
-        #assert almost_equal(math.floor(-1.23e167), 1.23e167)
+        assert math.floor(0.5) == 0
+        assert math.floor(1.0) == 1
+        assert math.floor(1.5) == 1
+        assert math.floor(-0.5) == -1
+        assert math.floor(-1.0) == -1
+        assert math.floor(-1.5) == -2
+        assert math.floor(1.23e167) == int(1.23e167)
+        assert math.floor(-1.23e167) == int(-1.23e167)
 
         class TestFloor:
             def __floor__(self):
                 return 42
         class TestNoFloor:
             pass
-        assert almost_equal(math.floor(TestFloor()), 42)
+        assert math.floor(TestFloor()) == 42
         raises(TypeError, math.floor, TestNoFloor())
  
         t = TestNoFloor()
                 return "this is a string"
 
         assert math.floor(StrangeCeil()) == "this is a string"
+
+        assert math.floor(1.23e167) - 1.23e167 == 0.0