Author: Timo Paulssen <timona...@perpetuum-immobile.de> Branch: py3k-ceil-floor Changeset: r59069:0c17239d22b5 Date: 2012-11-23 11:58 +0100 http://bitbucket.org/pypy/pypy/changeset/0c17239d22b5/
Log: missing minus, removed "almost_equal". diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py --- a/pypy/module/math/test/test_math.py +++ b/pypy/module/math/test/test_math.py @@ -290,27 +290,23 @@ 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() @@ -330,29 +326,25 @@ 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() @@ -370,3 +362,5 @@ return "this is a string" assert math.floor(StrangeCeil()) == "this is a string" + + assert math.floor(1.23e167) - 1.23e167 == 0.0 _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit