[Python-checkins] python/nondist/sandbox/decimal Decimal.py, 1.13, 1.14 test_Decimal.py, 1.6, 1.7

eprice at users.sourceforge.net eprice at users.sourceforge.net
Fri Feb 6 11:56:05 EST 2004


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

Modified Files:
	Decimal.py test_Decimal.py 
Log Message:
Added new tests, fix Decimal/test_Decimal to have samequantum.




Index: Decimal.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/decimal/Decimal.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** Decimal.py	6 Feb 2004 16:31:32 -0000	1.13
--- Decimal.py	6 Feb 2004 16:56:03 -0000	1.14
***************
*** 1805,1809 ****
--- 1805,1822 ----
          return self.rescale(exp._exp, rounding, context, watchexp)
  
+     def samequantum(self, other, context=None):
+         """Test whether self and other have the same exponent.
  
+         same as self._exp == other._exp, except NaN == sNaN
+         """
+         if self._isnan() or other._isnan():
+             if self._isnan() and other._isnan():
+                 return True
+             return False
+         if self._isinfinity() or other._isinfinity():
+             if self._isinfinity() and other._isinfinity():
+                 return True
+             return False
+         return self._exp == other._exp
      def rescale(self, exp, rounding = None, context=None, watchexp = 1):
          """Rescales so that the exponent is exp.
***************
*** 2282,2285 ****
--- 2295,2300 ----
      def rescale(self, a, b):
          return a.rescale(b, context=self)
+     def samequantum(self, a, b):
+         return a.samequantum(b, context=self)
      def squareroot(self, a):
          return a.sqrt(context=self)

Index: test_Decimal.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/decimal/test_Decimal.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_Decimal.py	6 Feb 2004 16:31:32 -0000	1.6
--- test_Decimal.py	6 Feb 2004 16:56:03 -0000	1.7
***************
*** 202,205 ****
--- 202,207 ----
          try:
              result = str(funct(*vals))
+             if fname == 'samequantum':
+                 result = str(int(eval(result))) # 'True', 'False' -> '1', '0'
          except ExceptionList, error:
              self.fail("Raised %s in %s" % (error, s))
***************
*** 244,265 ****
          self.context.clamp = clamp
  
-     def test_add(self):
-         """Tests the Decimal class on Cowlishaw's add tests.
- 
-         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
-         """
-         self.eval_file(dir + 'add' + '.decTest')
- 
      def test_abs(self):
          """Tests the Decimal class on Cowlishaw's abs tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'abs' + '.decTest')
  
      def test_base(self):
          """Tests the Decimal class on Cowlishaw's base tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'base' + '.decTest')
--- 246,267 ----
          self.context.clamp = clamp
  
      def test_abs(self):
          """Tests the Decimal class on Cowlishaw's abs tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'abs' + '.decTest')
  
+     def test_add(self):
+         """Tests the Decimal class on Cowlishaw's add tests.
+ 
+         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
+         """
+         self.eval_file(dir + 'add' + '.decTest')
+ 
      def test_base(self):
          """Tests the Decimal class on Cowlishaw's base tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'base' + '.decTest')
***************
*** 268,272 ****
          """Tests the Decimal class on Cowlishaw's clamp tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'clamp' + '.decTest')
--- 270,274 ----
          """Tests the Decimal class on Cowlishaw's clamp tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'clamp' + '.decTest')
***************
*** 275,279 ****
          """Tests the Decimal class on Cowlishaw's compare tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'compare' + '.decTest')
--- 277,281 ----
          """Tests the Decimal class on Cowlishaw's compare tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'compare' + '.decTest')
***************
*** 282,286 ****
          """Tests the Decimal class on Cowlishaw's divide tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'divide' + '.decTest')
--- 284,288 ----
          """Tests the Decimal class on Cowlishaw's divide tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'divide' + '.decTest')
***************
*** 289,293 ****
          """Tests the Decimal class on Cowlishaw's divideint tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'divideint' + '.decTest')
--- 291,295 ----
          """Tests the Decimal class on Cowlishaw's divideint tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'divideint' + '.decTest')
***************
*** 296,314 ****
          """Tests the Decimal class on Cowlishaw's inexact tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'inexact' + '.decTest')
  
-     def test_integer(self):
-         """Tests the Decimal class on Cowlishaw's integer tests.
- 
-         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
-         """
-         self.eval_file(dir + 'integer' + '.decTest')
- 
      def test_max(self):
          """Tests the Decimal class on Cowlishaw's max tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'max' + '.decTest')
--- 298,309 ----
          """Tests the Decimal class on Cowlishaw's inexact tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'inexact' + '.decTest')
  
      def test_max(self):
          """Tests the Decimal class on Cowlishaw's max tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'max' + '.decTest')
***************
*** 317,321 ****
          """Tests the Decimal class on Cowlishaw's min tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'min' + '.decTest')
--- 312,316 ----
          """Tests the Decimal class on Cowlishaw's min tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'min' + '.decTest')
***************
*** 324,328 ****
          """Tests the Decimal class on Cowlishaw's minus tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'minus' + '.decTest')
--- 319,323 ----
          """Tests the Decimal class on Cowlishaw's minus tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'minus' + '.decTest')
***************
*** 331,335 ****
          """Tests the Decimal class on Cowlishaw's multiply tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir+'multiply'+'.decTest')
--- 326,330 ----
          """Tests the Decimal class on Cowlishaw's multiply tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir+'multiply'+'.decTest')
***************
*** 338,342 ****
          """Tests the Decimal class on Cowlishaw's normalize tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'normalize' + '.decTest')
--- 333,337 ----
          """Tests the Decimal class on Cowlishaw's normalize tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'normalize' + '.decTest')
***************
*** 345,349 ****
          """Tests the Decimal class on Cowlishaw's plus tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'plus' + '.decTest')
--- 340,344 ----
          """Tests the Decimal class on Cowlishaw's plus tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'plus' + '.decTest')
***************
*** 352,356 ****
          """Tests the Decimal class on Cowlishaw's power tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'power' + '.decTest')
--- 347,351 ----
          """Tests the Decimal class on Cowlishaw's power tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'power' + '.decTest')
***************
*** 359,363 ****
          """Tests the Decimal class on Cowlishaw's quantize tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'quantize' + '.decTest')
--- 354,358 ----
          """Tests the Decimal class on Cowlishaw's quantize tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'quantize' + '.decTest')
***************
*** 366,370 ****
          """Tests the Decimal class on Cowlishaw's randomBound32 tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'randomBound32' + '.decTest')
--- 361,365 ----
          """Tests the Decimal class on Cowlishaw's randomBound32 tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'randomBound32' + '.decTest')
***************
*** 373,377 ****
          """Tests the Decimal class on Cowlishaw's randoms tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'randoms' + '.decTest')
--- 368,372 ----
          """Tests the Decimal class on Cowlishaw's randoms tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'randoms' + '.decTest')
***************
*** 380,384 ****
          """Tests the Decimal class on Cowlishaw's remainder tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'remainder' + '.decTest')
--- 375,379 ----
          """Tests the Decimal class on Cowlishaw's remainder tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'remainder' + '.decTest')
***************
*** 387,391 ****
          """Tests the Decimal class on Cowlishaw's remainderNear tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'remainderNear' + '.decTest')
--- 382,386 ----
          """Tests the Decimal class on Cowlishaw's remainderNear tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'remainderNear' + '.decTest')
***************
*** 394,405 ****
          """Tests the Decimal class on Cowlishaw's rounding tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'rounding' + '.decTest')
  
      def test_squareroot(self):
          """Tests the Decimal class on Cowlishaw's squareroot tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'squareroot' + '.decTest')
--- 389,407 ----
          """Tests the Decimal class on Cowlishaw's rounding tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'rounding' + '.decTest')
  
+     def test_samequantum(self):
+         """Tests the Decimal class on Cowlishaw's samequantum tests.
+ 
+         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
+         """
+         self.eval_file(dir + 'samequantum' + '.decTest')
+ 
      def test_squareroot(self):
          """Tests the Decimal class on Cowlishaw's squareroot tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'squareroot' + '.decTest')
***************
*** 408,412 ****
          """Tests the Decimal class on Cowlishaw's subtract tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'subtract' + '.decTest')
--- 410,414 ----
          """Tests the Decimal class on Cowlishaw's subtract tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'subtract' + '.decTest')
***************
*** 415,419 ****
          """Tests the Decimal class on Cowlishaw's tointegral tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'tointegral' + '.decTest')
--- 417,421 ----
          """Tests the Decimal class on Cowlishaw's tointegral tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'tointegral' + '.decTest')
***************
*** 422,426 ****
          """Tests the Decimal class on Cowlishaw's trim tests.
  
!         See www2.hursley.ibm.com/decimal/decTest.zip to download the suite.
          """
          self.eval_file(dir + 'trim' + '.decTest')
--- 424,428 ----
          """Tests the Decimal class on Cowlishaw's trim tests.
  
!         See www2.hursley.ibm.com/decimal/dectest.zip to download the suite.
          """
          self.eval_file(dir + 'trim' + '.decTest')




More information about the Python-checkins mailing list