[pypy-commit] pypy default: Improve the test: if x == -1 then int(-0.8) == 0, and the second part of

arigo pypy.commits at gmail.com
Wed Aug 24 11:55:09 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r86504:189373c314f3
Date: 2016-08-24 17:54 +0200
http://bitbucket.org/pypy/pypy/changeset/189373c314f3/

Log:	Improve the test: if x == -1 then int(-0.8) == 0, and the second
	part of the test would not be run at all

diff --git a/pypy/module/test_lib_pypy/test_resource.py b/pypy/module/test_lib_pypy/test_resource.py
--- a/pypy/module/test_lib_pypy/test_resource.py
+++ b/pypy/module/test_lib_pypy/test_resource.py
@@ -50,7 +50,7 @@
     resource.setrlimit(resource.RLIMIT_CPU, (x, y))
     # sometimes, x and y are very large (more than 53 bits).
     # for these huge values, int(float(x)) > x...
-    xf = x + 0.2
-    yf = y + 0.3
+    xf = x + (0.2 if x >= 0 else -0.2)
+    yf = y + (0.3 if y >= 0 else -0.3)
     if int(xf) == x and int(yf) == y:
         resource.setrlimit(resource.RLIMIT_CPU, (x, y))  # truncated to ints


More information about the pypy-commit mailing list