[Python-checkins] python/nondist/sandbox/decimal test_Decimal.py, 1.15, 1.16

facundobatista at users.sourceforge.net facundobatista at users.sourceforge.net
Mon Apr 5 18:08:44 EDT 2004


Update of /cvsroot/python/python/nondist/sandbox/decimal
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27419

Modified Files:
	test_Decimal.py 
Log Message:
Adjusted and fixed several test cases.

Index: test_Decimal.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** test_Decimal.py	4 Apr 2004 16:15:12 -0000	1.15
--- test_Decimal.py	5 Apr 2004 22:08:41 -0000	1.16
***************
*** 15,18 ****
--- 15,20 ----
  """
  
+ # 0.1.7  2003.04.05  fb: Adjusted several test cases. Eliminated interaction
+ #                    with float in comparations and min/max test cases.
  # 0.1.6  2003.04.04  fb: Extended explicit construction test case from tuples.
  # 0.1.5  2003.04.02  fb: Adjusted explicit construction test cases.
***************
*** 469,473 ****
  #
  #  - Explicit Construction
! #  - etc...
  #
  
--- 471,478 ----
  #
  #  - Explicit Construction
! #  - Implicit Construction
! #  - Arithmetic Operators
! #  - Use of Context
! #  - Usability
  #
  
***************
*** 714,718 ****
          #inline with other type
          d1 += 5
!         self.assertEqual(d1, Decimal('-6.1'))
  
      def test_subtraction(self):
--- 719,723 ----
          #inline with other type
          d1 += 5
!         self.assertEqual(d1, Decimal('16.1'))
  
      def test_subtraction(self):
***************
*** 733,737 ****
          #with other type, right
          c = 5 - d1
!         self.assertEqual(c, Decimal('6.1'))
          self.assertEqual(type(c), type(d1))
  
--- 738,742 ----
          #with other type, right
          c = 5 - d1
!         self.assertEqual(c, Decimal('16.1'))
          self.assertEqual(type(c), type(d1))
  
***************
*** 742,746 ****
          #inline with other type
          d1 -= 5
!         self.assertEqual(d1, Decimal('-16.1'))
  
      def test_multiplication(self):
--- 747,751 ----
          #inline with other type
          d1 -= 5
!         self.assertEqual(d1, Decimal('-38.3'))
  
      def test_multiplication(self):
***************
*** 770,774 ****
          #inline with other type
          d1 *= 5
!         self.assertEqual(d1, Decimal('-25'))
  
      def test_division(self):
--- 775,779 ----
          #inline with other type
          d1 *= 5
!         self.assertEqual(d1, Decimal('-75'))
  
      def test_division(self):
***************
*** 798,802 ****
          #inline with other type
          d1 /= 4
!         self.assertEqual(d1, Decimal('-1.25'))
  
      def test_floor_division(self):
--- 803,807 ----
          #inline with other type
          d1 /= 4
!         self.assertEqual(d1, Decimal('-0.625'))
  
      def test_floor_division(self):
***************
*** 821,829 ****
  
          #inline with decimal
!         d1 /= d2
          self.assertEqual(d1, Decimal('2'))
  
          #inline with other type
!         d1 /= 4
          self.assertEqual(d1, Decimal('1'))
  
--- 826,834 ----
  
          #inline with decimal
!         d1 //= d2
          self.assertEqual(d1, Decimal('2'))
  
          #inline with other type
!         d1 //= 2
          self.assertEqual(d1, Decimal('1'))
  
***************
*** 854,858 ****
          #inline with other type
          d1 **= 4
!         self.assertEqual(d1, Decimal('625'))
  
      def test_module(self):
--- 859,863 ----
          #inline with other type
          d1 **= 4
!         self.assertEqual(d1, Decimal('390625'))
  
      def test_module(self):
***************
*** 915,921 ****
  
          #test '+'
!         d = Decimal(45)
!         self.assertEqual(+d, d)
!         self.assertEqual(id(+d), id(d))
  
          #test '-'
--- 920,924 ----
  
          #test '+'
!         self.assertEqual(+Decimal(45), Decimal(+45))
  
          #test '-'
***************
*** 998,1013 ****
          self.assertEqual(cmp(dc,45), 0)
  
-         #a Decimal and a float
-         self.failUnless(dc > 23.42)
-         self.failUnless(23.42 < dc)
-         self.failUnless(da == 23.42)
-         self.assertEqual(cmp(dc,23.42), 1)
-         self.assertEqual(cmp(23.42,dc), -1)
-         self.assertEqual(cmp(da,23.42), 0)
- 
          #a Decimal and uncomparable
!         self.assertRaises(TypeError, da == 'ugly')
!         self.assertRaises(TypeError, da == '32.7')
!         self.assertRaises(TypeError, da == object)
  
      def test_copy_methods(self):
--- 1001,1016 ----
          self.assertEqual(cmp(dc,45), 0)
  
          #a Decimal and uncomparable
!         try: da == 'ugly'
!         except TypeError: pass
!         else: self.fail('Did not raised an error!')
! 
!         try: da == '32.7'
!         except TypeError: pass
!         else: self.fail('Did not raised an error!')
! 
!         try: da == object
!         except TypeError: pass
!         else: self.fail('Did not raised an error!')
  
      def test_copy_methods(self):
***************
*** 1036,1043 ****
          self.assertEqual(hash(Decimal(23)), hash(23))
  
!         #the same hash that to an "exact float"
!         self.assertEqual(hash(Decimal('32.32')), hash(32.32))
!         
!         #the same hash that to an "inexact float"
          self.assertEqual(hash(Decimal('23.72')), hash(23.72))
          
--- 1039,1043 ----
          self.assertEqual(hash(Decimal(23)), hash(23))
  
!         #the same hash that a float
          self.assertEqual(hash(Decimal('23.72')), hash(23.72))
          
***************
*** 1049,1054 ****
          l1 = 15
          l2 = 28
-         f1 = 15.32
-         f2 = 28.5
  
          #between Decimals
--- 1049,1052 ----
***************
*** 1064,1073 ****
          self.failUnless(max(d2,l1) is d2)
  
-         #between Decimal and float
-         self.failUnless(min(d1,f2) is d1)
-         self.failUnless(min(f2,d1) is d1)
-         self.failUnless(max(f1,d2) is d2)
-         self.failUnless(max(d2,f1) is d2)
-         
      def test_as_boolean(self):
          '''Test that it can be used as boolean.'''
--- 1062,1065 ----




More information about the Python-checkins mailing list