[Python-checkins] python/nondist/sandbox/decimal test_Decimal.py,
1.12, 1.13
facundobatista at users.sourceforge.net
facundobatista at users.sourceforge.net
Fri Apr 2 21:16:06 EST 2004
Update of /cvsroot/python/python/nondist/sandbox/decimal
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1741
Modified Files:
test_Decimal.py
Log Message:
Adjusted explicit construction test cases.
Index: test_Decimal.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** test_Decimal.py 28 Mar 2004 15:39:38 -0000 1.12
--- test_Decimal.py 3 Apr 2004 02:16:03 -0000 1.13
***************
*** 15,18 ****
--- 15,19 ----
"""
+ # 0.1.5 2003.04.02 fb: Adjusted explicit construction test cases.
# 0.1.4 2003.03.28 fb: Added Use of Context and Decimal Usability test cases.
# Corrected tests using try/except/else.
***************
*** 504,508 ****
#empty
! self.assertRaises(ValueError, Decimal, '')
#int
--- 505,510 ----
#empty
! d = Decimal('')
! self.assertEqual(str(d), 'NaN')
#int
***************
*** 519,523 ****
#just not a number
! self.assertRaises(ValueError, Decimal, 'ugly')
def test_from_float(self):
--- 521,526 ----
#just not a number
! d = Decimal('ugly')
! self.assertEqual(str(d), 'NaN')
def test_from_float(self):
***************
*** 537,541 ****
#empty
! self.assertRaises(ValueError, Decimal.from_float, '')
#with a string
--- 540,544 ----
#empty
! self.assertRaises(TypeError, Decimal.from_float)
#with a string
***************
*** 545,563 ****
self.assertRaises(TypeError, Decimal.from_float, 5)
- #exact float
- d = Decimal.from_float(32.32)
- self.assertEqual(str(d), '32.32')
-
#inexact float, without positions
d = Decimal.from_float(2.2)
! self.assertEqual(str(d), '220000000000000017763568394002504646778106689453125e-50')
! #inexact float, without some positions
! d = Decimal.from_float(2.2, 16)
self.assertEqual(str(d), '2.2000000000000002')
! #inexact float, without less positions
d = Decimal.from_float(2.2, 5)
! self.assertEqual(str(d), '2.2')
def test_from_tuples(self):
--- 548,562 ----
self.assertRaises(TypeError, Decimal.from_float, 5)
#inexact float, without positions
d = Decimal.from_float(2.2)
! self.assertEqual(str(d), '2.20000000000000017763568394002504646778106689453125')
! #inexact float, rounded to some positions
! d = Decimal.from_float(2.2, 17)
self.assertEqual(str(d), '2.2000000000000002')
! #inexact float, rounded to less positions
d = Decimal.from_float(2.2, 5)
! self.assertEqual(str(d), '2.20000')
def test_from_tuples(self):
More information about the Python-checkins
mailing list