[Python-checkins] CVS: python/dist/src/Lib/test test_complex.py,1.2,1.3
Tim Peters
tim_one@users.sourceforge.net
Thu, 06 Sep 2001 15:07:52 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv16559/python/Lib/test
Modified Files:
test_complex.py
Log Message:
Rewrite to use test_support's fine fcmp instead -- I didn't know that
existed when I wrote this test.
Index: test_complex.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_complex.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_complex.py 2001/05/29 22:18:09 1.2
--- test_complex.py 2001/09/06 22:07:50 1.3
***************
*** 1,3 ****
! from test_support import TestFailed
from random import random
--- 1,3 ----
! from test_support import TestFailed, fcmp
from random import random
***************
*** 6,25 ****
nerrors = 0
! def check_close_real(x, y, eps=1e-9):
! """Return true iff floats x and y "are close\""""
! # put the one with larger magnitude second
! if abs(x) > abs(y):
! x, y = y, x
! if y == 0:
! return abs(x) < eps
! if x == 0:
! return abs(y) < eps
! # check that relative difference < eps
! return abs((x-y)/y) < eps
!
! def check_close(x, y, eps=1e-9):
"""Return true iff complexes x and y "are close\""""
! return check_close_real(x.real, y.real, eps) and \
! check_close_real(x.imag, y.imag, eps)
def test_div(x, y):
--- 6,12 ----
nerrors = 0
! def check_close(x, y):
"""Return true iff complexes x and y "are close\""""
! return fcmp(x.real, y.real) == 0 == fcmp(x.imag, y.imag)
def test_div(x, y):