summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-07-08 19:21:59 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-07-08 19:21:59 (GMT)
commit0390f504ac81c9eb2b71eea81204284f01b200a2 (patch)
tree75469bce95fe7b358b2e2a1418cab53590323880 /Lib/test/test_decimal.py
parent1a1ea285f6b314278e93e1c737dba5d009b46803 (diff)
downloadcpython-0390f504ac81c9eb2b71eea81204284f01b200a2.zip
cpython-0390f504ac81c9eb2b71eea81204284f01b200a2.tar.gz
cpython-0390f504ac81c9eb2b71eea81204284f01b200a2.tar.bz2
Merged revisions 82646,82649-82650 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82646 | mark.dickinson | 2010-07-08 18:23:40 +0100 (Thu, 08 Jul 2010) | 1 line In test_decimal, convert heuristic for skipping tests into an explicit skiplist. ........ r82649 | mark.dickinson | 2010-07-08 20:03:34 +0100 (Thu, 08 Jul 2010) | 1 line Fix a performance issue in Decimal.pow. Thanks Stefan Krah for finding this. ........ r82650 | mark.dickinson | 2010-07-08 20:09:16 +0100 (Thu, 08 Jul 2010) | 1 line Fix misplaced exactness check that was causing unnecessary work in Decimal.__pow__. ........
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py76
1 files changed, 35 insertions, 41 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index dad63ae..e9fbad4 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -71,10 +71,41 @@ skip_expected = not os.path.isdir(directory)
# list of individual .decTest test ids that correspond to tests that
# we're skipping for one reason or another.
-skipped_test_ids = [
- 'scbx164', # skipping apparently implementation-specific scaleb
- 'scbx165', # tests, pending clarification of scaleb rules.
-]
+skipped_test_ids = set([
+ # Skip implementation-specific scaleb tests.
+ 'scbx164',
+ 'scbx165',
+
+ # For some operations (currently exp, ln, log10, power), the decNumber
+ # reference implementation imposes additional restrictions on the context
+ # and operands. These restrictions are not part of the specification;
+ # however, the effect of these restrictions does show up in some of the
+ # testcases. We skip testcases that violate these restrictions, since
+ # Decimal behaves differently from decNumber for these testcases so these
+ # testcases would otherwise fail.
+ 'expx901',
+ 'expx902',
+ 'expx903',
+ 'expx905',
+ 'lnx901',
+ 'lnx902',
+ 'lnx903',
+ 'lnx905',
+ 'logx901',
+ 'logx902',
+ 'logx903',
+ 'logx905',
+ 'powx1183',
+ 'powx1184',
+ 'powx4001',
+ 'powx4002',
+ 'powx4003',
+ 'powx4005',
+ 'powx4008',
+ 'powx4010',
+ 'powx4012',
+ 'powx4014',
+ ])
# Make sure it actually raises errors when not expected and caught in flags
# Slower, since it runs some things several times.
@@ -165,27 +196,6 @@ LOGICAL_FUNCTIONS = (
'same_quantum',
)
-# For some operations (currently exp, ln, log10, power), the decNumber
-# reference implementation imposes additional restrictions on the
-# context and operands. These restrictions are not part of the
-# specification; however, the effect of these restrictions does show
-# up in some of the testcases. We skip testcases that violate these
-# restrictions, since Decimal behaves differently from decNumber for
-# these testcases so these testcases would otherwise fail.
-
-decNumberRestricted = ('power', 'ln', 'log10', 'exp')
-DEC_MAX_MATH = 999999
-def outside_decNumber_bounds(v, context):
- if (context.prec > DEC_MAX_MATH or
- context.Emax > DEC_MAX_MATH or
- -context.Emin > DEC_MAX_MATH):
- return True
- if not v._is_special and v and (
- v.adjusted() > DEC_MAX_MATH or
- v.adjusted() < 1-2*DEC_MAX_MATH):
- return True
- return False
-
class DecimalTest(unittest.TestCase):
"""Class which tests the Decimal class against the test cases.
@@ -323,22 +333,6 @@ class DecimalTest(unittest.TestCase):
ans = FixQuotes(ans)
- # skip tests that are related to bounds imposed in the decNumber
- # reference implementation
- if fname in decNumberRestricted:
- if fname == 'power':
- if not (vals[1]._isinteger() and
- -1999999997 <= vals[1] <= 999999999):
- if outside_decNumber_bounds(vals[0], self.context) or \
- outside_decNumber_bounds(vals[1], self.context):
- #print "Skipping test %s" % s
- return
- else:
- if outside_decNumber_bounds(vals[0], self.context):
- #print "Skipping test %s" % s
- return
-
-
if EXTENDEDERRORTEST and fname not in ('to_sci_string', 'to_eng_string'):
for error in theirexceptions:
self.context.traps[error] = 1